[pbs-devel] [PATCH proxmox] build.sh: allow building multiple crates

Christoph Heiss c.heiss at proxmox.com
Tue Apr 15 14:00:05 CEST 2025


Instead of just looking at the first argument, iterate over all of them
and build them one by one.

Useful if e.g. applying patch series or generally working with multiple
crates in this repo, to then be able to run e.g.

  $ ./build.sh proxmox-log proxmox-serde

Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
 build.sh | 62 +++++++++++++++++++++++++++++---------------------------
 1 file changed, 32 insertions(+), 30 deletions(-)

diff --git a/build.sh b/build.sh
index 7aa0a85b..9857905a 100755
--- a/build.sh
+++ b/build.sh
@@ -1,36 +1,38 @@
-#!/bin/sh
+#!/bin/bash
 
 set -e
 
 export CARGO=/usr/bin/cargo
 export RUSTC=/usr/bin/rustc
 
-CRATE=$1
-BUILDCMD=${BUILDCMD:-"dpkg-buildpackage -b -uc -us"}
-BUILDDIR="${BUILDDIR:-"build"}"
-
-mkdir -p "${BUILDDIR}"
-echo system >"${BUILDDIR}"/rust-toolchain
-rm -rf ""${BUILDDIR}"/${CRATE}"
-
-CONTROL="$PWD/${CRATE}/debian/control"
-
-if [ -e "$CONTROL" ]; then
-    # check but only warn, debcargo fails anyway if crates are missing
-    dpkg-checkbuilddeps $PWD/${CRATE}/debian/control || true
-    [ "x$NOCONTROL" = 'x' ] && rm -f "$PWD/${CRATE}/debian/control"
-fi
-
-debcargo package \
-    --config "$PWD/${CRATE}/debian/debcargo.toml" \
-    --changelog-ready \
-    --no-overlay-write-back \
-    --directory "$PWD/"${BUILDDIR}"/${CRATE}" \
-    "${CRATE}" \
-    "$(dpkg-parsechangelog -l "${CRATE}/debian/changelog" -SVersion | sed -e 's/-.*//')"
-
-cd ""${BUILDDIR}"/${CRATE}"
-rm -f debian/source/format.debcargo.hint
-${BUILDCMD}
-
-[ "x$NOCONTROL" = "x" ] && cp debian/control "$CONTROL"
+for CRATE in "$@"; do
+    BUILDCMD=${BUILDCMD:-"dpkg-buildpackage -b -uc -us"}
+    BUILDDIR="${BUILDDIR:-"build"}"
+
+    mkdir -p "${BUILDDIR}"
+    echo system >"${BUILDDIR}"/rust-toolchain
+    rm -rf ""${BUILDDIR}"/${CRATE}"
+
+    CONTROL="$PWD/${CRATE}/debian/control"
+
+    if [ -e "$CONTROL" ]; then
+	# check but only warn, debcargo fails anyway if crates are missing
+	dpkg-checkbuilddeps $PWD/${CRATE}/debian/control || true
+	[ "x$NOCONTROL" = 'x' ] && rm -f "$PWD/${CRATE}/debian/control"
+    fi
+
+    debcargo package \
+	--config "$PWD/${CRATE}/debian/debcargo.toml" \
+	--changelog-ready \
+	--no-overlay-write-back \
+	--directory "$PWD/"${BUILDDIR}"/${CRATE}" \
+	"${CRATE}" \
+	"$(dpkg-parsechangelog -l "${CRATE}/debian/changelog" -SVersion | sed -e 's/-.*//')"
+
+    pushd ""${BUILDDIR}"/${CRATE}"
+    rm -f debian/source/format.debcargo.hint
+    ${BUILDCMD}
+
+    [ "x$NOCONTROL" = "x" ] && cp debian/control "$CONTROL"
+    popd
+done
-- 
2.48.1





More information about the pbs-devel mailing list