* [PATCH v2 0/3] Add helper and documentation for rust packaging
@ 2026-03-31 8:10 '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
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: 'Quirin Gylstorff' via isar-users @ 2026-03-31 8:10 UTC (permalink / raw)
To: isar-users
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
This adds based on https://rust-team.pages.debian.net/book/ some
documentation add a generator to package rust crates.
The generator is the same as used by Debian but we don't use the
approach from debcargo-conf as `debcargo cargo` executes the following
steps add once:
- fetch source
- generate orig tarball
- generate debian folder
As this is not compatible with the concepts of bitbake recipes we use
the http fetcher and the by `debcargo` generated debian folder. This
approach is intended to build crates stored in a registry(e.g. crates.io).
The crates package generated by this script should be package upstream
to avoid maintaining them forever.
Crates not in a registry need to manually packaged.
Changes v2:
- add MIT-0 license to generated rust recipes
- use BPN instead of PN in rust-hello-isar
- add line for cargo-debstatus to check already packaged dpendencies
Quirin Gylstorff (3):
Add script to generate a recipe for cargo.io crates
Add example of a rust hello world as isar recipe
user_manual: add rust section
doc/user_manual.md | 68 ++++++++++++++
.../recipes-app/rust-hello-isar/files/rules | 27 ++++++
.../files/rust-hello-isar/Cargo.toml | 6 ++
.../files/rust-hello-isar/src/main.rs | 3 +
.../rust-hello-isar/rust-hello-isar_0.1.bb | 22 +++++
scripts/generate_cargo_crate.sh | 88 +++++++++++++++++++
6 files changed, 214 insertions(+)
create mode 100755 meta-isar/recipes-app/rust-hello-isar/files/rules
create mode 100644 meta-isar/recipes-app/rust-hello-isar/files/rust-hello-isar/Cargo.toml
create mode 100644 meta-isar/recipes-app/rust-hello-isar/files/rust-hello-isar/src/main.rs
create mode 100644 meta-isar/recipes-app/rust-hello-isar/rust-hello-isar_0.1.bb
create mode 100755 scripts/generate_cargo_crate.sh
--
2.53.0
--
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/20260331081019.32111-1-Quirin.Gylstorff%40siemens.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/3] Add script to generate a recipe for cargo.io crates
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 ` 'Quirin Gylstorff' via isar-users
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
2 siblings, 0 replies; 4+ messages in thread
From: 'Quirin Gylstorff' via isar-users @ 2026-03-31 8:10 UTC (permalink / raw)
To: isar-users
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/"
--
2.53.0
--
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/20260331081019.32111-2-Quirin.Gylstorff%40siemens.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] Add example of a rust hello world as isar recipe
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-03-31 8:10 ` 'Quirin Gylstorff' via isar-users
2026-03-31 8:10 ` [PATCH v2 3/3] user_manual: add rust section 'Quirin Gylstorff' via isar-users
2 siblings, 0 replies; 4+ messages in thread
From: 'Quirin Gylstorff' via isar-users @ 2026-03-31 8:10 UTC (permalink / raw)
To: isar-users
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
.../recipes-app/rust-hello-isar/files/rules | 27 +++++++++++++++++++
.../files/rust-hello-isar/Cargo.toml | 6 +++++
.../files/rust-hello-isar/src/main.rs | 3 +++
.../rust-hello-isar/rust-hello-isar_0.1.bb | 22 +++++++++++++++
4 files changed, 58 insertions(+)
create mode 100755 meta-isar/recipes-app/rust-hello-isar/files/rules
create mode 100644 meta-isar/recipes-app/rust-hello-isar/files/rust-hello-isar/Cargo.toml
create mode 100644 meta-isar/recipes-app/rust-hello-isar/files/rust-hello-isar/src/main.rs
create mode 100644 meta-isar/recipes-app/rust-hello-isar/rust-hello-isar_0.1.bb
diff --git a/meta-isar/recipes-app/rust-hello-isar/files/rules b/meta-isar/recipes-app/rust-hello-isar/files/rules
new file mode 100755
index 00000000..213cc876
--- /dev/null
+++ b/meta-isar/recipes-app/rust-hello-isar/files/rules
@@ -0,0 +1,27 @@
+#!/usr/bin/make -f
+
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+DPKG_EXPORT_BUILDFLAGS = 1
+include /usr/share/dpkg/default.mk
+include /usr/share/rustc/architecture.mk
+export DEB_HOST_RUST_TYPE
+export PATH:=/usr/share/cargo/bin:$(PATH)
+export CARGO=/usr/share/cargo/bin/cargo
+export CARGO_HOME=$(CURDIR)/debian/cargo_home
+export CARGO_REGISTRY=$(CURDIR)/debian/cargo_registry
+export DEB_CARGO_CRATE=$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM)
+
+%:
+ dh $@ --buildsystem=cargo
+
+execute_after_dh_auto_clean:
+ $(CARGO) clean
+ rm -rf $(CARGO_HOME)
+ rm -rf $(CARGO_REGISTRY)
+ rm -f debian/cargo-checksum.json
+
+execute_before_dh_auto_configure:
+ $(CARGO) prepare-debian $(CARGO_REGISTRY) --link-from-system
+ rm -f Cargo.lock
+ touch debian/cargo-checksum.json
+
diff --git a/meta-isar/recipes-app/rust-hello-isar/files/rust-hello-isar/Cargo.toml b/meta-isar/recipes-app/rust-hello-isar/files/rust-hello-isar/Cargo.toml
new file mode 100644
index 00000000..f761691e
--- /dev/null
+++ b/meta-isar/recipes-app/rust-hello-isar/files/rust-hello-isar/Cargo.toml
@@ -0,0 +1,6 @@
+[package]
+name = "rust-hello-isar"
+version = "0.1.0"
+edition = "2024"
+
+[dependencies]
diff --git a/meta-isar/recipes-app/rust-hello-isar/files/rust-hello-isar/src/main.rs b/meta-isar/recipes-app/rust-hello-isar/files/rust-hello-isar/src/main.rs
new file mode 100644
index 00000000..50469bdf
--- /dev/null
+++ b/meta-isar/recipes-app/rust-hello-isar/files/rust-hello-isar/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+ println!("Hello, isar!");
+}
diff --git a/meta-isar/recipes-app/rust-hello-isar/rust-hello-isar_0.1.bb b/meta-isar/recipes-app/rust-hello-isar/rust-hello-isar_0.1.bb
new file mode 100644
index 00000000..0a20bb4b
--- /dev/null
+++ b/meta-isar/recipes-app/rust-hello-isar/rust-hello-isar_0.1.bb
@@ -0,0 +1,22 @@
+# Sample application
+#
+# This software is a part of ISAR.
+# Copyright (C) 2026 Siemens AG
+
+inherit dpkg
+
+DESCRIPTION = "Hello world example for Rust"
+MAINTAINER = "isar-users <isar-users@googlegroups.com>"
+
+SRC_URI = "file://${BPN} \
+ file://rules"
+
+DEBIAN_BUILD_DEPENDS += "dh-cargo"
+
+S = "${WORKDIR}/${BPN}"
+
+do_prepare_build() {
+ deb_debianize
+ install -m 644 ${WORKDIR}/rules ${S}/debian/rules
+}
+
--
2.53.0
--
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/20260331081019.32111-3-Quirin.Gylstorff%40siemens.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] user_manual: add rust section
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-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 ` 'Quirin Gylstorff' via isar-users
2 siblings, 0 replies; 4+ messages in thread
From: 'Quirin Gylstorff' via isar-users @ 2026-03-31 8:10 UTC (permalink / raw)
To: isar-users
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
doc/user_manual.md | 68 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/doc/user_manual.md b/doc/user_manual.md
index 7520854b..79580702 100644
--- a/doc/user_manual.md
+++ b/doc/user_manual.md
@@ -20,6 +20,7 @@ Copyright (C) 2016-2019, ilbers GmbH
- [Customize and configure image](#customize-and-configure-image)
- [Create a Custom Image Recipe](#create-a-custom-image-recipe)
- [Add a Custom Application](#add-a-custom-application)
+ - [Rust in Isar Builds](#rust-in-isar-builds)
- [Build statistics collection](#build-statistics-collection)
- [Isar Cross-compilation](#isar-cross-compilation)
- [Examining and debugging package generation inside their schroot rootfs](#examining-and-debugging-package-generation-inside-their-schroot-rootfs)
@@ -1039,6 +1040,73 @@ be installed via `IMAGE_INSTALL`. Have a look at `prebuilt-deb`.
---
+## Rust in Isar Builds
+
+This is a collection of recipes and links on how to
+package rust crates.
+
+This document takes most of its input from https://rust-team.pages.debian.net/book
+which contains the practices of the Debian rust team.
+
+### Crates on crates.io
+
+We provide a generator in `scripts/generate_cargo_crate.sh` which
+generates the scaffold for these crates. This follows more or less
+the approach of Debian with https://salsa.debian.org/rust-team/debcargo-conf.
+
+The user steps necessary are the following:
+
+1. Generate the package by calling:
+`scripts/generate_cargo_crate.sh <CRATE_NAME> [CRATE_VERSION]`.
+
+2. Patch to build with the current Debian release, e.g. relax the dependencies
+in `Cargo.toml`
+
+
+### Crates not on crates.io
+
+There is currently no generator and it is recommended to follow the traditional
+packaging approach, see also https://rust-team.pages.debian.net/book/process-workspace.html#general-setup.
+
+A working rules file could look like this:
+```
+#!/usr/bin/make -f
+
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+DPKG_EXPORT_BUILDFLAGS = 1
+include /usr/share/dpkg/default.mk
+include /usr/share/rustc/architecture.mk
+export DEB_HOST_RUST_TYPE
+export PATH:=/usr/share/cargo/bin:$(PATH)
+export CARGO=/usr/share/cargo/bin/cargo
+export CARGO_HOME=$(CURDIR)/debian/cargo_home
+export CARGO_REGISTRY=$(CURDIR)/debian/cargo_registry
+export DEB_CARGO_CRATE=$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM)
+
+%:
+ dh $@ --buildsystem=cargo
+
+execute_after_dh_auto_clean:
+ $(CARGO) clean
+ rm -rf $(CARGO_HOME)
+ rm -rf $(CARGO_REGISTRY)
+ rm -f debian/cargo-checksum.json
+
+execute_before_dh_auto_configure:
+ $(CARGO) prepare-debian $(CARGO_REGISTRY) --link-from-system
+ rm -f Cargo.lock
+ touch debian/cargo-checksum.json
+
+```
+This example works for a cargo application and cannot be reused by other components
+as the file `debian/cargo-checksum.json` is empty.
+
+An example for the initial cargo crate can be found at `meta-isar/recipes-app/rust-hello-isar/`.
+
+Check which packages are already part of Debian by using the tool `cargo-debstatus`.
+
+---
+
## Build statistics collection
While isar is building the system, build statistics is collected in
--
2.53.0
--
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/20260331081019.32111-4-Quirin.Gylstorff%40siemens.com.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-31 8:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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-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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox