From: "'Quirin Gylstorff' via isar-users" <isar-users@googlegroups.com>
To: Anton Mikanovich <amikan@ilbers.de>, isar-users@googlegroups.com
Subject: Re: [PATCH v2 1/3] Add script to generate a recipe for cargo.io crates
Date: Thu, 16 Apr 2026 16:15:02 +0200 [thread overview]
Message-ID: <95a8ad1f-dd7a-4d62-99d1-509347d8aca6@siemens.com> (raw)
In-Reply-To: <a836449c-384f-4a1f-8f34-55f9e64d3305@ilbers.de>
On 4/16/26 3:09 PM, Anton Mikanovich wrote:
> 31.03.2026 11:10, 'Quirin Gylstorff' via isar-users wrote:
>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>>
>> This script allows to create a recipe for building rust crates which
>> are not part of Debian. It uses for this `debcargo package` and follows
>> the process defined in https://rust-team.pages.debian.net/book.
>>
>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>> ---
>> scripts/generate_cargo_crate.sh | 88 +++++++++++++++++++++++++++++++++
>> 1 file changed, 88 insertions(+)
>> create mode 100755 scripts/generate_cargo_crate.sh
>>
>> diff --git a/scripts/generate_cargo_crate.sh b/scripts/
>> generate_cargo_crate.sh
>> new file mode 100755
>> index 00000000..727f7f0e
>> --- /dev/null
>> +++ b/scripts/generate_cargo_crate.sh
>> @@ -0,0 +1,88 @@
>> +#!/bin/bash
>> +# This software is a part of ISAR.
>> +# Copyright (C) 2026 Siemens AG
>> +
>> +usage() {
>> + echo "This script generates a scaffold for rust crates from
>> crates.io."
>> + echo "It uses debcargo to download and generate the debian folder."
>> + echo "USAGE: $0 <CRATE_NAME> [CRATE_VERSION]"
>> +}
>> +
>> +if [ $# -eq 0 ]; then
>> + usage
>> + exit 1
>> +fi
>> +case $1 in
>> + -h|--help)
>> + usage
>> + exit 0
>> + ;;
>> + *)
>> + true
>> + ;;
>> +esac
>> +
>> +package_name=$1
>> +package_version=
>> +if [ $# -gt 1 ]; then
>> + package_version=$2
>> +fi
>> +
>> +export NAME="isar-users isar"
>> +
>> +for dep in jq debcargo curl; do
>> + if ! command -v "$dep" ;then
>> + echo "Could not find tool dependency $dep !"
>> + exit 1
>> + fi
>> +done
>> +
>> +source_name="rust-$package_name"
>> +mkdir -p "$source_name/files"
>> +# generate in the current directory to avoid the following
>> +# debcargo error:
>> +# Invalid cross-device link (os error 18)
>> +TMP_DIR=$(mktemp -d -p .)
>> +pushd "$source_name" || exit 1
>> +debcargo package "$package_name" "$package_version" --directory
>> "$TMP_DIR"
>> +cp -r "${TMP_DIR}"/debian files/
>> +if [ -z "$package_version" ]; then
>> + package_version=$(grep -oP "X-Cargo-Crate-Version:\K.*"
>> "${TMP_DIR}"/debian/control | tr -d "[:blank:]")
>> +fi
>> +rm -rf "$TMP_DIR"
>> +tarball_checksum="$(curl --silent "https://crates.io/api/v1/crates/
>> ${package_name}/${package_version}" | jq ".version.checksum" )"
>> +if [ "${tarball_checksum}" = "null" ] ; then
>> + echo "$package_name in $package_version could not be found in
>> crates.io"
>> + exit 1
>> +fi
>> +cat << EOF >> "${source_name}_${package_version}".bb
>> +# Created by generate_cargo_crate.sh.
>> +# SPDX-License-Identifier: MIT-0
>> +
>> +inherit dpkg
>> +
>> +SRC_URI = "https://crates.io/api/v1/crates/${package_name}/\${PV}/
>> download;downloadfilename=${PN}_${PV}.tar.gz"
>> +SRC_URI += "file://debian"
>> +
>> +SRC_URI[sha256sum] = ${tarball_checksum}
>> +
>> +S = "\${WORKDIR}/${package_name}-\${PV}"
>> +
>> +# In most cases we want to package a library crate from crates.io
>> +PROVIDES += "librust-${package_name}-dev"
>> +
>> +do_prepare_build() {
>> + cp -r \${WORKDIR}/debian \${S}/
>> + cd \${WORKDIR}
>> + tar cJf \${PN}_\${PV}.orig.tar.xz \${TAR_REPRO_OPTS}
>> ${package_name}-\${PV}
>> +}
>> +EOF
>> +
>> +
>> +popd || exit 1
>> +
>> +echo "Finished generating isar scaffold for package $package_name in
>> version $package_version"
>> +echo ""
>> +echo "Next steps:"
>> +echo " - Check if the package builds and add the necessary patches,
>> e.g. relax dependencies to the debian folder."
>> +echo " - Also add the package to Debian by following https://rust-
>> team.pages.debian.net/book/"
>
> Hello Quirin,
>
> Bitbake is already support cargo fetching with SRC_URI like "crate://
> crates.io/name/${package_name}/${PV}".
> Maybe it will be more clear?
We can use it - I didn't like it as we need to set variable
BP="$package_name"
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/95a8ad1f-dd7a-4d62-99d1-509347d8aca6%40siemens.com.
next prev parent reply other threads:[~2026-04-16 14:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 8:10 [PATCH v2 0/3] Add helper and documentation for rust packaging 'Quirin Gylstorff' via isar-users
2026-03-31 8:10 ` [PATCH v2 1/3] Add script to generate a recipe for cargo.io crates 'Quirin Gylstorff' via isar-users
2026-04-16 13:09 ` Anton Mikanovich
2026-04-16 14:15 ` 'Quirin Gylstorff' via isar-users [this message]
2026-03-31 8:10 ` [PATCH v2 2/3] Add example of a rust hello world as isar recipe 'Quirin Gylstorff' via isar-users
2026-03-31 8:10 ` [PATCH v2 3/3] user_manual: add rust section 'Quirin Gylstorff' via isar-users
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=95a8ad1f-dd7a-4d62-99d1-509347d8aca6@siemens.com \
--to=isar-users@googlegroups.com \
--cc=amikan@ilbers.de \
--cc=quirin.gylstorff@siemens.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox