X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fporterbox%2Ffiles%2Fsetup-dchroot;h=0ab99d16b437b7be7d28595930047c62cee03a7e;hb=66c96fd4a905aae93e85f19842fb8ddea5465c74;hp=5565ba153ad687104dd611fcb9a90ea7005a296b;hpb=f917864f8ef558ad045de075b5c0e7635b0ad86f;p=mirror%2Fdsa-puppet.git diff --git a/modules/porterbox/files/setup-dchroot b/modules/porterbox/files/setup-dchroot index 5565ba153..0ab99d16b 100755 --- a/modules/porterbox/files/setup-dchroot +++ b/modules/porterbox/files/setup-dchroot @@ -39,9 +39,12 @@ OPTIONS: -a ARCH debootstrap arch [$arch] -m MIRROR http mirror to use [$mirror] -b basedir place where to build the chroot/tarball [$basedir] - -f overwrite stuff. - -c write config only. - -h this help. + -c write config only + -f overwrite config and target tarball + -k KEYRING use an alternate keyring [$keyring] + -p PERS use a different sbuild personality [$personality] + -s use sbuild compatible naming scheme + -h this help EOF } @@ -68,18 +71,30 @@ genschrootconf() { local suite="${suite}-${extra}" fi + if [ -n "$sbuildnames" ]; then + local name="${suite}-${arch}-sbuild" + else + local name="${suite}_${arch}-dchroot" + fi + + cat << EOF -[${suite}_${arch}-dchroot] -description=[${suite}_${arch}-dchroot] Debian $suite chroot for $arch +[${name}] +description=[${name}] Debian $suite chroot for $arch type=file file=$target groups=Debian,guest root-groups=adm source-groups=adm source-root-groups=adm -script-config=dsa/config EOF + if dpkg --compare-versions "$(lsb_release --release --short)" '<' 7; then + echo "script-config=$personality/config" + else + echo "profile=$personality" + fi + if [ "$THISARCH" = "$arch" ]; then echo "aliases=$suite" fi @@ -116,10 +131,13 @@ mirror="${mirror:-http://cdn.debian.net/debian}" configonly="" force="" basedir="/srv/chroot" +keyring=/usr/share/keyrings/debian-archive-keyring.gpg +personality="dsa" +sbuildnames="" declare -a cleanup trap do_cleanup EXIT -while getopts "a:b:cfhm:" OPTION +while getopts "a:b:cfhk:m:p:s" OPTION do case $OPTION in a) @@ -138,9 +156,18 @@ do help exit 0 ;; + k) + keyring="$OPTARG" + ;; m) mirror="$OPTARG" ;; + p) + personality="$OPTARG" + ;; + s) + sbuildnames="1" + ;; *) usage >&2 exit 1 @@ -178,7 +205,7 @@ cleanup+=("umount $rootdir/sys") set -x debootstrap \ - --keyring /usr/share/keyrings/debian-archive-keyring.gpg \ + --keyring "$keyring" \ --include="apt" \ --variant=buildd \ --arch="$arch" \ @@ -209,4 +236,6 @@ chroot "$rootdir" apt-get install -y --no-install-recommends zsh locales-all bui rm -f "$rootdir/etc/apt/sources.list" "$rootdir/etc/apt/sources.list.d/*" umount "$rootdir/sys" || true -(cd "$rootdir" && tar caf "$target" .) +tartmp=$(tempfile --directory "$basedir" --suffix=".tar.gz") +cleanup+=("rm -f $tartmp") +(cd "$rootdir" && tar caf "$tartmp" . && mv "$tartmp" "$target")