]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/porterbox/files/setup-dchroot
Do not savelog with -d
[dsa-puppet.git] / modules / porterbox / files / setup-dchroot
index 61d91b2d4c9dc79b33022e6f70ae8f1f0e8912ff..39f1e19c1d14c98216451a39ab93172b8fd68e79 100755 (executable)
@@ -39,14 +39,20 @@ OPTIONS:
     -a ARCH    debootstrap arch [$arch]
     -m MIRROR  http mirror to use [$mirror]
     -b basedir place where to put the tarball [$basedir]
+    -B         install less stuff into chroot [$bare]
     -c         write config only
+    -D         set up a buildd schroot - changes conffile name and various defaults.  Run -D -h)."
     -d dir     place where to build the chroot [${builddir:-$basedir}]
     -f         overwrite config and target tarball
     -g GROUPS  groups that should have access to the schroot [$groupuser]
+    -K         keep old tarballs around for a while (4 iterations)
     -k KEYRING use an alternate keyring [$keyring]
+    -o USER    users that should have access to the schroot [$users]
+    -O USER    users that should have root in the schroot [$usersroot]
     -p PERS    use a different sbuild personality [$personality]
     -r GROUPS  groups that should have root in the schroot [$grouproot]
-    -s         use sbuild compatible naming scheme
+    -s         use sbuild compatible naming scheme [$sbuildnames]
+    -S SUFFIX  conffile suffix [$suffix]
     -u         Ubuntu target
     -h         this help
 EOF
@@ -87,17 +93,13 @@ cat << EOF
 description=[${name}] Debian $suite chroot for $arch
 type=file
 file=$target
-groups=$groupuser
-root-groups=$grouproot
-#source-groups=adm
-#source-root-groups=adm
 EOF
+[ -n "$groupuser" ] && echo "groups=$groupuser"
+[ -n "$grouproot" ] && echo "root-groups=$grouproot"
+[ -n "$users" ] &&     echo "users=$users"
+[ -n "$usersroot" ] && echo "root-users=$usersroot"
 
-    if dpkg --compare-versions "$(lsb_release --release --short)" '<' 7; then
-        echo "script-config=$personality/config"
-    else
-        echo "profile=$personality"
-    fi
+    echo "profile=$personality"
 
     if [ "$THISARCH" = "$arch" ]; then
         echo "aliases=$suite"
@@ -152,10 +154,16 @@ sbuildnames=""
 ubuntu=""
 groupuser="Debian,guest"
 grouproot=""
+users=""
+usersroot=""
+bare=""
+keep=""
+suffix="dchroot"
 declare -a cleanup
+cleanup+=(":")
 trap do_cleanup EXIT
 
-while getopts "a:b:cd:fg:hk:m:p:r:su" OPTION
+while getopts "a:b:Bcd:Dfg:hKk:m:o:O:p:r:sS:u" OPTION
 do
     case $OPTION in
         a)
@@ -164,9 +172,22 @@ do
         b)
             basedir="$OPTARG"
             ;;
+        B)
+            bare="1"
+            ;;
         c)
             configonly="1"
             ;;
+        D)
+            sbuildnames="0"
+            bare="1"
+            groupuser=""
+            grouproot=""
+            users="buildd"
+            usersroot="buildd"
+            personality="buildd-dsa"
+            suffix="sbuild"
+            ;;
         d)
             builddir="$OPTARG"
             ;;
@@ -180,12 +201,21 @@ do
             usage
             exit 0
             ;;
+        K)
+            keep="4"
+            ;;
         k)
             keyring="$OPTARG"
             ;;
         m)
             mirror="$OPTARG"
             ;;
+        o)
+            users="$OPTARG"
+            ;;
+        O)
+            usersroot="$OPTARG"
+            ;;
         p)
             personality="$OPTARG"
             ;;
@@ -195,6 +225,9 @@ do
         s)
             sbuildnames="1"
             ;;
+        S)
+            suffix="$OPTARG"
+            ;;
         u)
             ubuntu="1"
             ;;
@@ -220,7 +253,7 @@ builddir=${builddir:-$basedir}
 target="$basedir/$tuple.tar.gz"
 ! [ -e "$target" ] || [ -n "$force" ] || die "Error: $target already exists."
 
-schrootconfig="/etc/schroot/chroot.d/${tuple}-dchroot"
+schrootconfig="/etc/schroot/chroot.d/${tuple}-$suffix"
 ! [ -e "$schrootconfig" ] || [ -n "$force" ] || die "Error: $schrootconfig already exists."
 
 
@@ -254,6 +287,20 @@ debootstrap \
     "$suite" "$rootdir" "$mirror" "$script"
 echo "$tuple" > "$rootdir/etc/debian_chroot"
 echo "force-unsafe-io" > "$rootdir/etc/dpkg/dpkg.cfg.d/force-unsafe-io"
+echo "force-confnew" > "$rootdir/etc/dpkg/dpkg.cfg.d/force-confnew"
+
+cleanup+=("umount $rootdir/dev")
+case "$(uname -s)" in
+  Linux)
+    ;;
+  GNU/kFreeBSD)
+    mount -t devfs none "$rootdir/dev"
+    ;;
+  *)
+    echo >&2 "Warning: Unexpected uname -s output."
+    ;;
+esac
+
 
 chroot "$rootdir" apt-get update
 chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends policyrcd-script-zg2
@@ -275,14 +322,23 @@ while true; do
 done
 EOF
 chmod +x "$rootdir/usr/local/sbin/policy-rc.d"
-[ -z "$ubuntu" ] && chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends locales-all
-chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends zsh build-essential less vim fakeroot devscripts gdb
+[ -z "$bare" ] && [ -z "$ubuntu" ] && chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends locales-all
+chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends build-essential
+[ -z "$bare" ] && chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends zsh less vim fakeroot devscripts gdb
 rm -f "$rootdir/etc/apt/sources.list" "$rootdir/etc/apt/sources.list.d/*"
 chroot "$rootdir" apt-get clean
-umount "$rootdir/sys" || true
+umount "$rootdir/dev" 2>/dev/null || true
+umount "$rootdir/sys" 2>/dev/null || true
 
 tartmp=$(tempfile --directory "$basedir" --suffix=".tar.gz")
 cleanup+=("rm -f $tartmp")
-(cd "$rootdir" && tar caf "$tartmp" . && mv "$tartmp" "$target")
+(
+  cd "$rootdir"
+  tar caf "$tartmp" .
+  if ! [ -z "$keep" ]; then
+    savelog -l -c 4 "$target"
+  fi
+  mv "$tartmp" "$target"
+)
 
 do_config