Allow supplying a different schroot personality
[mirror/dsa-puppet.git] / modules / porterbox / files / setup-dchroot
index db098d1..0ab99d1 100755 (executable)
@@ -42,6 +42,8 @@ OPTIONS:
     -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
 }
@@ -69,9 +71,16 @@ 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
@@ -81,9 +90,9 @@ source-root-groups=adm
 EOF
 
     if dpkg --compare-versions "$(lsb_release --release --short)" '<' 7; then
-        echo "script-config=dsa/config"
+        echo "script-config=$personality/config"
     else
-        echo "profile=dsa"
+        echo "profile=$personality"
     fi
 
     if [ "$THISARCH" = "$arch" ]; then
@@ -123,10 +132,12 @@ 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:cfhk:m:" OPTION
+while getopts "a:b:cfhk:m:p:s" OPTION
 do
     case $OPTION in
         a)
@@ -151,6 +162,12 @@ do
         m)
             mirror="$OPTARG"
             ;;
+        p)
+            personality="$OPTARG"
+            ;;
+        s)
+            sbuildnames="1"
+            ;;
         *)
             usage >&2
             exit 1
@@ -219,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")