more setup-dchroot features
authorPeter Palfrader <peter@palfrader.org>
Fri, 10 May 2013 12:24:53 +0000 (14:24 +0200)
committerPeter Palfrader <peter@palfrader.org>
Fri, 10 May 2013 12:24:53 +0000 (14:24 +0200)
modules/porterbox/files/setup-dchroot

index 0ab99d1..130feac 100755 (executable)
@@ -38,12 +38,14 @@ usage: $0 <suite>
 OPTIONS:
     -a ARCH    debootstrap arch [$arch]
     -m MIRROR  http mirror to use [$mirror]
-    -b basedir place where to build the chroot/tarball [$basedir]
+    -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
 }
@@ -113,7 +115,7 @@ EOF
             :
             ;;
         *)
-            if [ -z "$extra" ]; then
+            if [ -z "$extra" ] && [ -z "$ubuntu" ]; then
                 genschrootconf "$suite" "$arch" "$target" "backports"
             fi
     esac
@@ -131,13 +133,15 @@ 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:cfhk:m:p:s" OPTION
+while getopts "a:b:cd:fhk:m:p:su" OPTION
 do
     case $OPTION in
         a)
@@ -149,11 +153,14 @@ do
         c)
             configonly="1"
             ;;
+        d)
+            builddir="$OPTARG"
+            ;;
         f)
             force="1"
             ;;
         h)
-            help
+            usage
             exit 0
             ;;
         k)
@@ -168,6 +175,9 @@ do
         s)
             sbuildnames="1"
             ;;
+        u)
+            ubuntu="1"
+            ;;
         *)
             usage >&2
             exit 1
@@ -183,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."
@@ -199,7 +211,7 @@ genschrootconf "$suite" "$arch" "$target" | tee "$schrootconfig"
 
 if [ -n "$configonly" ]; then exit 0; fi
 
-rootdir=$(mktemp -d "$basedir/create-$suite-XXXXXX")
+rootdir=$(mktemp -d "$builddir/create-$suite-XXXXXX")
 cleanup+=("rm -r $rootdir")
 cleanup+=("umount $rootdir/sys")
 
@@ -232,7 +244,8 @@ 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 less 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