bin/mdw-build, bin/mdw-sbuild, bin/mdw-sbuild-server: Additional packages.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 13 Aug 2017 17:36:51 +0000 (18:36 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 13 Aug 2017 17:36:51 +0000 (18:36 +0100)
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
bin/mdw-sbuild
bin/mdw-sbuild-server

index de2ef72..62edc4d 100755 (executable)
@@ -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 ;;
index 5630dab..2fd31ff 100755 (executable)
@@ -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/" ./
index 048fcbe..705592b 100755 (executable)
@@ -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 <<EOF
 ### -*-makefile-*-
@@ -257,6 +273,7 @@ sbuild-wrap = \\
        suite=\$\${full%%-*} target=\$\${full\#*-}; \\
        { echo started >build-status.\$\$full; \\
          sbuild \\
+               --extra-package=pkgs.\$\$target/ \\
                --dist=\$\$suite --build=\$\$host --host=\$\$target \\
                --chroot=\$\$suite-\$\$host --verbose \$1 \$(DSC); \\
          rc=\$\$?; case \$\$rc in \\