X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fschroot%2Ffiles%2Fsetup-all-dchroots;h=7ff84b40cce3844a42c25817fd75ab931de5284f;hb=49f7c90c52341e0a0666e578f6ca09c7d2d5d55b;hp=e0a4327d5b4d2e459ee9b27f3240c637cf7fe5d2;hpb=7ea56adb1d449e240710f0f7ac47e85ae4c9fb92;p=mirror%2Fdsa-puppet.git diff --git a/modules/schroot/files/setup-all-dchroots b/modules/schroot/files/setup-all-dchroots index e0a4327d5..7ff84b40c 100755 --- a/modules/schroot/files/setup-all-dchroots +++ b/modules/schroot/files/setup-all-dchroots @@ -28,39 +28,111 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -DPKGARCH=$(dpkg --print-architecture) -UNAMEARCH=$(uname -m) +get_suites() { + case "$1" in + amd64|i386|armel|armhf) + echo "sid buster stretch jessie" + ;; + *) + echo "sid buster stretch" + ;; + esac +} -if [ "${1:-}" = "buildd" ]; then - MODE=buildd - if ! [ -d /srv/buildd/ ]; then - echo >&2 "Error: /srv/buildd does not exist or is not a directory." +do_one() { + local a="$1"; shift + local s="$1"; shift + + case "$MODE" in + buildd) + mkdir -p /srv/buildd/unpack + if ! $SILENT setup-dchroot $EXTRAARGS -f -a "$a" -D -d '/srv/buildd/unpack' -K "$s" + then + return 1 + fi + ;; + porterbox) + if ! $SILENT setup-dchroot $EXTRAARGS -f -a "$a" "$s" + then + return 1 + fi + ;; + *) + echo >&2 "Invalid mode $MODE" + exit 1 + esac + return 0 +} + +usage() +{ +cat << EOF +usage: $0 [] [buildd] + +OPTIONS: + -c write config only + -h this help +EOF +} + +########## +# "main" +########## + + +# parse options +########## +EXTRAARGS="" +while getopts "cu" OPTION +do + case $OPTION in + c) + EXTRAARGS="$EXTRAARGS -c" + ;; + h) + usage + exit 0 + ;; + *) + usage >&2 + exit 1 + ;; + esac +done +shift $(($OPTIND - 1)) + +# parse arguments +########## +if [ "$#" -gt 1 ]; then + usage >&2 + exit 1 +elif [ "$#" = 1 ]; then + if [ "${1:-}" = "buildd" ]; then + MODE=buildd + if ! [ -d /srv/buildd/ ]; then + echo >&2 "Error: /srv/buildd does not exist or is not a directory." + exit 1 + fi + else + usage >&2 exit 1 fi else MODE=porterbox fi +# figure out whether to be verbose or not +########## if [ -t 0 ] ; then SILENT="" else SILENT="chronic" fi -get_suites() { - case "$1" in - amd64|i386|armel|armhf) - echo "sid buster stretch jessie" - ;; - *) - echo "sid buster stretch" - ;; - esac -} - -extra="" - -archs="$DPKGARCH" +# get list of archs based on dpkg architecture +########## +DPKGARCH=$(dpkg --print-architecture) +archs="DPKGARCH" case "$DPKGARCH" in amd64) archs="$archs i386" @@ -89,31 +161,6 @@ esac err=0 -do_one() { - local a="$1"; shift - local s="$1"; shift - - case "$MODE" in - buildd) - mkdir -p /srv/buildd/unpack - if ! $SILENT setup-dchroot -f -a "$a" $extra -D -d '/srv/buildd/unpack' -K "$s" - then - return 1 - fi - ;; - porterbox) - if ! $SILENT setup-dchroot -f -a "$a" $extra "$s" - then - return 1 - fi - ;; - *) - echo >&2 "Invalid mode $MODE" - exit 1 - esac - return 0 -} - for a in $archs; do for s in `get_suites "$a"`; do if ! do_one "$a" "$s"; then