X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fporterbox%2Ffiles%2Fsetup-dchroot;h=130feac70fb6fbd3989b00225954f1d132efd1c1;hb=7bb415b6547466ac679232f79496d371feb41417;hp=0cba6fa12f1e5af1958e1dc22e0e269757aca444;hpb=1af943401cb3dea6a550030e3c6ad3043c463e03;p=mirror%2Fdsa-puppet.git diff --git a/modules/porterbox/files/setup-dchroot b/modules/porterbox/files/setup-dchroot index 0cba6fa12..130feac70 100755 --- a/modules/porterbox/files/setup-dchroot +++ b/modules/porterbox/files/setup-dchroot @@ -38,9 +38,15 @@ usage: $0 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. - -h this help. + -b basedir place where to put the tarball [$basedir] + -c write config only + -d dir place where to build the chroot [${builddir:-$basedir}] + -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 + -u Ubuntu target + -h this help EOF } @@ -67,38 +73,49 @@ 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=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" - else - case "$arch" in - i386) - echo "personality=linux32" - ;; - esac fi + case "$arch" in + armel|armhf|i386|powerpc|s390|sparc) + echo "personality=linux32" + ;; + esac echo case "$suite" in sid) genschrootconf "experimental" "$arch" "$target" ;; - experimental) + experimental|jessie) : ;; *) - if [ -z "$extra" ]; then + if [ -z "$extra" ] && [ -z "$ubuntu" ]; then genschrootconf "$suite" "$arch" "$target" "backports" fi esac @@ -112,13 +129,19 @@ arch="$THISARCH" if [ -e /etc/schroot/dsa/default-mirror ]; then mirror=$(cat /etc/schroot/dsa/default-mirror ) fi -mirror="${mirror:-cdn.debian.net}" +mirror="${mirror:-http://cdn.debian.net/debian}" +configonly="" force="" basedir="/srv/chroot" +builddir="" +keyring=/usr/share/keyrings/debian-archive-keyring.gpg +personality="dsa" +sbuildnames="" +ubuntu="" declare -a cleanup trap do_cleanup EXIT -while getopts "a:b:fhm:" OPTION +while getopts "a:b:cd:fhk:m:p:su" OPTION do case $OPTION in a) @@ -127,16 +150,34 @@ do b) basedir="$OPTARG" ;; + c) + configonly="1" + ;; + d) + builddir="$OPTARG" + ;; f) force="1" ;; h) - help + usage exit 0 ;; + k) + keyring="$OPTARG" + ;; m) mirror="$OPTARG" ;; + p) + personality="$OPTARG" + ;; + s) + sbuildnames="1" + ;; + u) + ubuntu="1" + ;; *) usage >&2 exit 1 @@ -152,7 +193,9 @@ fi suite="$1"; shift tuple="${suite}_${arch}" +builddir=${builddir:-$basedir} [ -d "$basedir" ] || die "Error: $basedir does not exist (or is not a directory)." +[ -d "$builddir" ] || die "Error: $builddir does not exist (or is not a directory)." target="$basedir/$tuple.tar.gz" ! [ -e "$target" ] || [ -n "$force" ] || die "Error: $target already exists." @@ -166,17 +209,19 @@ schrootconfig="/etc/schroot/chroot.d/${tuple}-dchroot" # genschrootconf "$suite" "$arch" "$target" | tee "$schrootconfig" -rootdir=$(mktemp -d "$basedir/create-$suite-XXXXXX") +if [ -n "$configonly" ]; then exit 0; fi + +rootdir=$(mktemp -d "$builddir/create-$suite-XXXXXX") cleanup+=("rm -r $rootdir") cleanup+=("umount $rootdir/sys") set -x debootstrap \ - --keyring /usr/share/keyrings/debian-archive-keyring.gpg \ + --keyring "$keyring" \ --include="apt" \ --variant=buildd \ --arch="$arch" \ - "$suite" "$rootdir" "http://$mirror/debian" + "$suite" "$rootdir" "$mirror" echo "$tuple" > $rootdir/etc/debian_chroot chroot "$rootdir" apt-get update @@ -199,8 +244,11 @@ while true; do done EOF chmod +x "$rootdir/usr/local/sbin/policy-rc.d" -chroot "$rootdir" apt-get install -y --no-install-recommends zsh locales-all build-essential vim fakeroot devscripts gdb +[ -z "$ubuntu" ] && chroot "$rootdir" apt-get install -y --no-install-recommends locales-all +chroot "$rootdir" apt-get install -y --no-install-recommends zsh build-essential less vim fakeroot devscripts gdb 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")