4 ## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
5 ## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
8 # Copyright (c) 2013 Peter Palfrader
10 # Permission is hereby granted, free of charge, to any person
11 # obtaining a copy of this software and associated documentation
12 # files (the "Software"), to deal in the Software without
13 # restriction, including without limitation the rights to use,
14 # copy, modify, merge, publish, distribute, sublicense, and/or sell
15 # copies of the Software, and to permit persons to whom the
16 # Software is furnished to do so, subject to the following
19 # The above copyright notice and this permission notice shall be
20 # included in all copies or substantial portions of the Software.
22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
24 # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
27 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 # OTHER DEALINGS IN THE SOFTWARE.
31 THISARCH=$(dpkg --print-architecture)
39 -a ARCH debootstrap arch [$arch]
40 -m MIRROR http mirror to use [$mirror]
41 -b basedir place where to put the tarball [$basedir]
42 -B install less stuff into chroot [$bare]
44 -D set up a buildd schroot - changes conffile name and various defaults. Run -D -h)."
45 -d dir place where to build the chroot [${builddir:-$basedir}]
46 -f overwrite config and target tarball
47 -g GROUPS groups that should have access to the schroot [$groupuser]
48 -K keep old tarballs around for a while (4 iterations)
49 -k KEYRING use an alternate keyring [$keyring]
50 -o USER users that should have access to the schroot [$users]
51 -O USER users that should have root in the schroot [$usersroot]
52 -p PERS use a different sbuild personality [$personality]
53 -r GROUPS groups that should have root in the schroot [$grouproot]
54 -s use sbuild compatible naming scheme [$sbuildnames]
55 -S SUFFIX conffile suffix [$suffix]
68 cnt=$((${#cleanup[*]}-1))
69 for i in $(seq ${cnt} -1 0); do
70 ${cleanup[$i]} || true
75 local suite="$1"; shift
76 local arch="$1"; shift
77 local target="$1"; shift
78 local extra="${1:-}"; shift || true
80 if [ -n "$extra" ]; then
81 local suite="${suite}-${extra}"
84 if [ -n "$sbuildnames" ]; then
85 local name="${suite}-${arch}-sbuild"
87 local name="${suite}_${arch}-dchroot"
93 description=[${name}] Debian $suite chroot for $arch
97 [ -n "$groupuser" ] && echo "groups=$groupuser"
98 [ -n "$grouproot" ] && echo "root-groups=$grouproot"
99 [ -n "$users" ] && echo "users=$users"
100 [ -n "$usersroot" ] && echo "root-users=$usersroot"
102 echo "profile=$personality"
104 if [ "$THISARCH" = "$arch" ]; then
105 echo "aliases=$suite"
108 armel|armhf|i386|powerpc|s390|sparc)
109 echo "personality=linux32"
116 genschrootconf "experimental" "$arch" "$target"
122 if [ -z "$extra" ] && [ -z "$ubuntu" ]; then
123 genschrootconf "$suite" "$arch" "$target" "backports"
129 local tmpschrootconf=$(tempfile)
130 cleanup+=("rm -f $tmpschrootconf")
131 genschrootconf "$suite" "$arch" "$target" > "$tmpschrootconf"
132 if ! [ -e "$schrootconfig" ] || ! diff "$schrootconfig" "$tmpschrootconf" > /dev/null; then
133 mv "$tmpschrootconf" "$schrootconfig"
134 chmod 644 "$schrootconfig"
143 if [ -e /etc/schroot/dsa/default-mirror ]; then
144 mirror=$(cat /etc/schroot/dsa/default-mirror )
146 mirror="${mirror:-http://cdn.debian.net/debian}"
149 basedir="/srv/chroot"
151 keyring=/usr/share/keyrings/debian-archive-keyring.gpg
155 groupuser="Debian,guest"
166 while getopts "a:b:Bcd:Dfg:hKk:m:o:O:p:r:sS:u" OPTION
220 personality="$OPTARG"
240 shift $(($OPTIND - 1))
242 if [ "$#" != 1 ]; then
247 tuple="${suite}_${arch}"
249 builddir=${builddir:-$basedir}
250 [ -d "$basedir" ] || die "Error: $basedir does not exist (or is not a directory)."
251 [ -d "$builddir" ] || die "Error: $builddir does not exist (or is not a directory)."
253 target="$basedir/$tuple.tar.gz"
254 ! [ -e "$target" ] || [ -n "$force" ] || die "Error: $target already exists."
256 schrootconfig="/etc/schroot/chroot.d/${tuple}-$suffix"
257 ! [ -e "$schrootconfig" ] || [ -n "$force" ] || die "Error: $schrootconfig already exists."
264 if [ -n "$configonly" ]; then
269 rootdir=$(mktemp -d "$builddir/create-$suite-XXXXXX")
270 cleanup+=("rm -r $rootdir")
271 cleanup+=("umount $rootdir/sys")
272 script=/usr/share/debootstrap/scripts/"$suite"
273 if ! [ -e "$script" ]; then
274 if [ -z "$ubuntu" ]; then
275 script=/usr/share/debootstrap/scripts/sid
277 script=/usr/share/debootstrap/scripts/gutsy
283 --keyring "$keyring" \
287 "$suite" "$rootdir" "$mirror" "$script"
288 echo "$tuple" > "$rootdir/etc/debian_chroot"
289 echo "force-unsafe-io" > "$rootdir/etc/dpkg/dpkg.cfg.d/force-unsafe-io"
291 cleanup+=("umount $rootdir/dev")
292 case "$(uname -s)" in
296 mount -t devfs none "$rootdir/dev"
299 echo >&2 "Warning: Unexpected uname -s output."
304 chroot "$rootdir" apt-get update
305 chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends policyrcd-script-zg2
306 cat > "$rootdir/usr/local/sbin/policy-rc.d" << 'EOF'
309 # policy-rc.d script for chroots.
310 # Copyright (c) 2007 Peter Palfrader <peter@palfrader.org>
317 echo "Not running services in chroot."
323 chmod +x "$rootdir/usr/local/sbin/policy-rc.d"
324 [ -z "$bare" ] && [ -z "$ubuntu" ] && chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends locales-all
325 chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends build-essential
326 [ -z "$bare" ] && chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends zsh less vim fakeroot devscripts gdb
327 rm -f "$rootdir/etc/apt/sources.list" "$rootdir/etc/apt/sources.list.d/*"
328 chroot "$rootdir" apt-get clean
329 umount "$rootdir/dev" 2>/dev/null || true
330 umount "$rootdir/sys" 2>/dev/null || true
332 tartmp=$(tempfile --directory "$basedir" --suffix=".tar.gz")
333 cleanup+=("rm -f $tartmp")
337 if ! [ -z "$keep" ]; then
338 savelog -d -l -c 4 "$target"
340 mv "$tartmp" "$target"