From: Mark Wooding Date: Sun, 22 Sep 2019 14:25:35 +0000 (+0100) Subject: bin/mdw-sbuild-server: Run builds sequentially. X-Git-Url: https://git.distorted.org.uk/~mdw/profile/commitdiff_plain/ba9719ebf12e489e392bb2ea8d00ecc5fe68a5ef bin/mdw-sbuild-server: Run builds sequentially. Otherwise they can interfere with each other, and cause test failures. For example, TrIPE wants to use fixed port numbers in its fancier tests. --- diff --git a/bin/mdw-sbuild-server b/bin/mdw-sbuild-server index 88e4ae7..2bba42a 100755 --- a/bin/mdw-sbuild-server +++ b/bin/mdw-sbuild-server @@ -33,7 +33,6 @@ do done : ${buildroot=$HOME/build} : ${default_targets="wheezy-amd64 wheezy-i386"} -: ${parallel=-j3} : ${DEB_BUILD_OPTIONS=parallel=4}; export DEB_BUILD_OPTIONS ###-------------------------------------------------------------------------- @@ -57,10 +56,24 @@ want_1 () { echo "$1" } +run () { + case $notreally in + t) echo "+ $*" ;; + nil) "$@" ;; + esac +} + +decor () { + tag=$1 marker=$2 + while IFS= read -r line; do + printf "%-21s %c %s\n" "$tag" "$marker" "$line" + done +} + ###-------------------------------------------------------------------------- ### Parse options. -bogusp=nil archp=nil indepp=nil makeopts="" +bogusp=nil archp=nil indepp=nil keepon=nil notreally=nil unset targets while getopts "haint:" opt; do @@ -73,6 +86,7 @@ Options: -h Show this help text. -a Build only architecture-dependent packages. -i Build only architecture-neutral packages. + -k Keep going even if one fails. -n Don't actually do the build. -t TARGET Build in TARGET build environment. @@ -91,7 +105,8 @@ EOF ;; a) archp=t ;; i) indepp=t ;; - n) makeopts="${makeopts+$makeopts }-n" ;; + k) keepon=t ;; + n) notreally=t ;; t) targets="${targets+$targets }$OPTARG" ;; *) bogusp=nil ;; esac @@ -261,46 +276,35 @@ case "$#,$1" in 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 \\ - 0) echo ok >build-status.\$\$full ;; \\ - *) echo failed rc=\$\$rc >build-status.\$\$full ;; \\ - esac; } | \\ - while IFS= read -r line; do \\ - printf "%-21s | %s\n" "\$\$full" "\$\$line"; \\ - done; \\ - read st _ build-status.${i%/*}; done - - ## And we're ready to go. - mkfifo pipeout - cat pipeout& catpid=$! - set +e; make -fbuild.mk $parallel $makeopts -k all >pipeout - rc=$?; set -e - wait $! - rm build.mk pipeout build-status.* - find . -maxdepth 1 -type l -exec rm {} \; + ## Build the builds sequentially. Tests can conflict with each other, + ## e.g., over port numbers. + rc=0 buildopt=$firstopt + for t in $first $rest; do + host=${t##*/} full=${t%/*} + suite=${full%%-*} target=${full#*-} + + ## And we're ready to go. + exec 3>&1 + thisrc=$( + { { { { set +e + run sbuild --extra-package=$pkgs.$target \ + --dist=$suite --build=$host --host=$target \ + --chroot=$suite-$host --verbose $buildopt $dsc \ + 3>&- 4>&- 5>&- + echo $? >&5 + } | + decor "$full" "|" >&4; } 2>&1 | + decor "$full" "*" >&4; } 4>&1 | + cat -u >&3; } 5>&1 &- + case $thisrc in 0) ;; + *) + echo failed rc=$thisrc >$stat; rc=$thisrc + case $keepon in nil) break ;; esac + ;; + esac + buildopt=--no-arch-all + done exit $rc ;; build,*)