From 6cf97414024dc9990deba102761ae5951da0200d Mon Sep 17 00:00:00 2001 Message-Id: <6cf97414024dc9990deba102761ae5951da0200d.1718315269.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 13 Aug 2017 18:36:51 +0100 Subject: [PATCH] bin/mdw-build, bin/mdw-sbuild, bin/mdw-sbuild-server: Additional packages. Organization: Straylight/Edgeware From: Mark Wooding Support supplying additional packages to the builder, in `dist-BUILD.pkgs'. Release builds don't do this, for obvious reasons. There's an annoying fiddle where we have to separate out the supplied packages into per-architecture sets because sbuild is too stupid to do this for itself and ends up using the wrong architecture. --- bin/mdw-build | 5 +++++ bin/mdw-sbuild | 8 ++++++-- bin/mdw-sbuild-server | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/bin/mdw-build b/bin/mdw-build index de2ef72..62edc4d 100755 --- a/bin/mdw-build +++ b/bin/mdw-build @@ -411,6 +411,11 @@ EOF yes,release) case $sign in yes) sbuildargs="-k$signkey $sbuildargs" ;; esac ;; + yes,*) + if [ -d $toppath/dist-$build.pkgs ]; then + sbuildargs="-p$toppath/dist-$build.pkgs $sbuildargs" + fi + ;; esac case $sbuild,$build,$sign in yes,*) run mdw-sbuild $sbuildargs ;; diff --git a/bin/mdw-sbuild b/bin/mdw-sbuild index 5630dab..2fd31ff 100755 --- a/bin/mdw-sbuild +++ b/bin/mdw-sbuild @@ -34,8 +34,8 @@ fail_usage () { usage >&2; exit 1; } ### Parse options. bogusp=nil noactp=nil signp=nil -unset buildopts -while getopts "haik:nt:" opt; do +unset buildopts pkgs +while getopts "haik:np:t:" opt; do case $opt in h) usage @@ -47,6 +47,7 @@ Options: -i Build only architecture-neutral packages. -k KEYID Sign the result using KEYID. -n Don't actually do the build. + -p DIR Upload additional packages from DIR. -t TARGET Build in TARGET build environment. EOF exit 0 @@ -55,6 +56,7 @@ EOF i) buildopts="${buildopts+$buildopts }-i" ;; k) signp=t keyid=$OPTARG ;; n) buildopts="${buildopts+$buildopts }-n" noactp=t ;; + p) pkgs=$OPTARG ;; t) buildopts="${buildopts+$buildopts }-t$OPTARG" ;; *) bogusp=t ;; esac @@ -66,6 +68,7 @@ case $# in esac case $bogusp in t) fail_usage ;; esac case $noactp in t) signp=nil ;; esac +case ${pkgs-/hack} in /*) ;; *) pkgs=$(pwd)/$pkgs ;; esac ###-------------------------------------------------------------------------- ### Main program. @@ -94,6 +97,7 @@ dsc=${pkg}_${ver}.dsc ## upload the sources, run the build, and collect the results. builddir=$(ssh "$host" mdw-sbuild-server dir "$pkg/$ver") dcmd rsync -a "$dsc" "$host:$builddir/" +case ${pkgs+t} in t) rsync -a "$pkgs/" "$host:$builddir/pkgs/" ;; esac set +e; ssh "$host" mdw-sbuild-server $buildopts build "$builddir" rc=$?; set -e rsync -a "$host:$builddir/" ./ diff --git a/bin/mdw-sbuild-server b/bin/mdw-sbuild-server index 048fcbe..705592b 100755 --- a/bin/mdw-sbuild-server +++ b/bin/mdw-sbuild-server @@ -137,6 +137,7 @@ case "$#,$1" in ## racing with another process, but that's why we're trying in a loop. if mkdir "$ver#$nn" >/dev/null 2>&1; then winp=t + cd "$ver#$nn" break fi @@ -149,6 +150,9 @@ case "$#,$1" in ## Make sure we actually succeeded. case $winp in t) ;; *) fail "failed to create build directory" ;; esac + ## Make an empty directory for dependency packages. + mkdir -p pkgs/ + ## Done. echo "$buildroot/$dist#$nn" ;; @@ -245,6 +249,18 @@ case "$#,$1" in nil) firstopt="$firstopt --debbuildopt=-A" ;; esac + ## Sort out the additional packages. This is rather annoying, because + ## sbuild(1) does this in a really stupid way. + rm -rf pkgs.* + for a in $buildarchs; do + mkdir pkgs.$a + for f in $(dpkg-scanpackages -a$a pkgs/ | + sed -n '/^Filename: /s///p') + do + ln $f pkgs.$a/ + done + done + ## Build a cheesy makefile to run these in parallel. cat >build.mk <build-status.\$\$full; \\ sbuild \\ + --extra-package=pkgs.\$\$target/ \\ --dist=\$\$suite --build=\$\$host --host=\$\$target \\ --chroot=\$\$suite-\$\$host --verbose \$1 \$(DSC); \\ rc=\$\$?; case \$\$rc in \\ -- [mdw]