From 8b67003b52bcfeb12af396cd9ea5cb2fc1e98440 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Thu, 16 Aug 2018 09:50:34 +0200 Subject: [PATCH] setup-all-dchroots: copy from tor: -c support Add option to just write config files. Also revamps parameter parsing. --- modules/schroot/files/setup-all-dchroots | 50 +++++++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/modules/schroot/files/setup-all-dchroots b/modules/schroot/files/setup-all-dchroots index e0a4327d5..df7d66a4e 100755 --- a/modules/schroot/files/setup-all-dchroots +++ b/modules/schroot/files/setup-all-dchroots @@ -31,10 +31,48 @@ DPKGARCH=$(dpkg --print-architecture) UNAMEARCH=$(uname -m) -if [ "${1:-}" = "buildd" ]; then - MODE=buildd - if ! [ -d /srv/buildd/ ]; then - echo >&2 "Error: /srv/buildd does not exist or is not a directory." +usage() +{ +cat << EOF +usage: $0 [] [buildd] + +OPTIONS: + -c write config only + -h this help +EOF +} + +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)) + +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 @@ -96,13 +134,13 @@ do_one() { case "$MODE" in buildd) mkdir -p /srv/buildd/unpack - if ! $SILENT setup-dchroot -f -a "$a" $extra -D -d '/srv/buildd/unpack' -K "$s" + if ! $SILENT setup-dchroot $extraargs -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" + if ! $SILENT setup-dchroot $extraargs -f -a "$a" $extra "$s" then return 1 fi -- 2.20.1