]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/porterbox/files/setup-dchroot
%security gets to update their static component
[dsa-puppet.git] / modules / porterbox / files / setup-dchroot
index 5050b6c36716d16f68a1f2feb8b6290f8686d5b7..81732c614cf20d9830032ac5674546dc6794debd 100755 (executable)
@@ -39,6 +39,7 @@ 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
     -c         write config only
     -d dir     place where to build the chroot [${builddir:-$basedir}]
     -f         overwrite config and target tarball
@@ -89,8 +90,8 @@ type=file
 file=$target
 groups=$groupuser
 root-groups=$grouproot
-source-groups=adm
-source-root-groups=adm
+#source-groups=adm
+#source-root-groups=adm
 EOF
 
     if dpkg --compare-versions "$(lsb_release --release --short)" '<' 7; then
@@ -123,6 +124,16 @@ EOF
     esac
 }
 
+do_config() {
+    local tmpschrootconf=$(tempfile)
+    cleanup+=("rm -f $tmpschrootconf")
+    genschrootconf "$suite" "$arch" "$target" > "$tmpschrootconf"
+    if ! [ -e "$schrootconfig" ] || ! diff "$schrootconfig" "$tmpschrootconf" > /dev/null; then
+        mv "$tmpschrootconf" "$schrootconfig"
+        chmod 644 "$schrootconfig"
+    fi
+}
+
 
 set -e
 set -u
@@ -141,11 +152,12 @@ personality="dsa"
 sbuildnames=""
 ubuntu=""
 groupuser="Debian,guest"
-grouproot="adm"
+grouproot=""
+bare=""
 declare -a cleanup
 trap do_cleanup EXIT
 
-while getopts "a:b:cd:fg:hk:m:p:r:su" OPTION
+while getopts "a:b:Bcd:fg:hk:m:p:r:su" OPTION
 do
     case $OPTION in
         a)
@@ -154,6 +166,9 @@ do
         b)
             basedir="$OPTARG"
             ;;
+        B)
+            bare="1"
+            ;;
         c)
             configonly="1"
             ;;
@@ -217,13 +232,23 @@ schrootconfig="/etc/schroot/chroot.d/${tuple}-dchroot"
 #
 # let's go
 #
-genschrootconf "$suite" "$arch" "$target" | tee "$schrootconfig"
 
-if [ -n "$configonly" ]; then exit 0; fi
+if [ -n "$configonly" ]; then
+    do_config
+    exit 0
+fi
 
 rootdir=$(mktemp -d "$builddir/create-$suite-XXXXXX")
 cleanup+=("rm -r $rootdir")
 cleanup+=("umount $rootdir/sys")
+script=/usr/share/debootstrap/scripts/"$suite"
+if ! [ -e "$script" ]; then
+    if [ -z "$ubuntu" ]; then
+        script=/usr/share/debootstrap/scripts/sid
+    else
+        script=/usr/share/debootstrap/scripts/gutsy
+    fi
+fi
 
 set -x
 debootstrap \
@@ -231,8 +256,22 @@ debootstrap \
     --include="apt" \
     --variant=buildd \
     --arch="$arch" \
-    "$suite" "$rootdir" "$mirror"
-echo "$tuple" > $rootdir/etc/debian_chroot
+    "$suite" "$rootdir" "$mirror" "$script"
+echo "$tuple" > "$rootdir/etc/debian_chroot"
+echo "force-unsafe-io" > "$rootdir/etc/dpkg/dpkg.cfg.d/force-unsafe-io"
+
+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
@@ -255,10 +294,15 @@ 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
+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/*"
-umount "$rootdir/sys" || true
+chroot "$rootdir" apt-get clean
+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")
+
+do_config