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
45 various defaults. Run -D -h. Also creates more aliases.
46 -d dir place where to build the chroot [${builddir:-$basedir}]
47 -f overwrite config and target tarball
48 -g GROUPS groups that should have access to the schroot [$groupuser]
49 -K keep old tarballs around for a while (4 iterations)
50 -k KEYRING use an alternate keyring [$keyring]
51 -o USER users that should have access to the schroot [$users]
52 -O USER users that should have root in the schroot [$usersroot]
53 -p PERS use a different sbuild personality [$personality]
54 -r GROUPS groups that should have root in the schroot [$grouproot]
55 -s use sbuild compatible naming scheme [$sbuildnames]
56 -S SUFFIX conffile suffix [$suffix]
69 cnt=$((${#cleanup[*]}-1))
70 for i in $(seq ${cnt} -1 0); do
71 ${cleanup[$i]} || true
76 local suite="$1"; shift
77 local arch="$1"; shift
78 local target="$1"; shift
79 local extra="${1:-}"; shift || true
81 if [ -n "$extra" ]; then
82 local suite="${suite}-${extra}"
85 if [ -n "$sbuildnames" ]; then
86 local name="${suite}-${arch}-sbuild"
88 local name="${suite}_${arch}-dchroot"
94 description=[${name}] Debian $suite chroot for $arch
98 [ -n "$groupuser" ] && echo "groups=$groupuser"
99 [ -n "$grouproot" ] && echo "root-groups=$grouproot"
100 [ -n "$users" ] && echo "users=$users"
101 [ -n "$usersroot" ] && echo "root-users=$usersroot"
103 echo "profile=$personality"
105 if [ "$THISARCH" = "$arch" ] && [ -z "$buildd" ]; then
106 echo "aliases=$suite"
109 armel|armhf|i386|powerpc|s390|sparc)
110 echo "personality=linux32"
117 genschrootconf "experimental" "$arch" "$target"
119 #experimental|jessie)
124 if [ -z "$extra" ] && [ -z "$ubuntu" ]; then
125 genschrootconf "$suite" "$arch" "$target" "backports"
126 [ -n "$buildd" ] && genschrootconf "$suite" "$arch" "$target" "backports-sloppy"
127 [ -n "$buildd" ] && genschrootconf "$suite" "$arch" "$target" "lts"
128 [ -n "$buildd" ] && genschrootconf "$suite" "$arch" "$target" "proposed-updates"
129 [ -n "$buildd" ] && genschrootconf "$suite" "$arch" "$target" "security"
136 local tmpschrootconf=$(tempfile)
137 cleanup+=("rm -f $tmpschrootconf")
138 genschrootconf "$suite" "$arch" "$target" > "$tmpschrootconf"
139 if ! [ -e "$schrootconfig" ] || ! diff "$schrootconfig" "$tmpschrootconf" > /dev/null; then
140 mv "$tmpschrootconf" "$schrootconfig"
141 chmod 644 "$schrootconfig"
150 if [ -e /etc/schroot/dsa/default-mirror ]; then
151 mirror=$(cat /etc/schroot/dsa/default-mirror )
153 mirror="${mirror:-http://ftp.debian.org/debian}"
156 basedir="/srv/chroot"
158 keyring=/usr/share/keyrings/debian-archive-keyring.gpg
162 groupuser="Debian,guest"
174 while getopts "a:b:Bcd:Dfg:hKk:m:o:O:p:r:sS:u" OPTION
229 personality="$OPTARG"
249 shift $(($OPTIND - 1))
251 if [ "$#" != 1 ]; then
256 tuple="${suite}_${arch}"
258 builddir=${builddir:-$basedir}
259 [ -d "$basedir" ] || die "Error: $basedir does not exist (or is not a directory)."
260 [ -d "$builddir" ] || die "Error: $builddir does not exist (or is not a directory)."
262 target="$basedir/$tuple.tar.gz"
263 ! [ -e "$target" ] || [ -n "$force" ] || die "Error: $target already exists."
265 schrootconfig="/etc/schroot/chroot.d/${tuple}-$suffix"
266 ! [ -e "$schrootconfig" ] || [ -n "$force" ] || die "Error: $schrootconfig already exists."
273 if [ -n "$configonly" ]; then
278 rootdir=$(mktemp -d "$builddir/create-$suite-XXXXXX")
279 cleanup+=("rm -r $rootdir")
280 cleanup+=("umount $rootdir/sys")
281 script=/usr/share/debootstrap/scripts/"$suite"
282 if ! [ -e "$script" ]; then
283 if [ -z "$ubuntu" ]; then
284 script=/usr/share/debootstrap/scripts/sid
286 script=/usr/share/debootstrap/scripts/gutsy
292 --keyring "$keyring" \
296 "$suite" "$rootdir" "$mirror" "$script"
297 echo "$tuple" > "$rootdir/etc/debian_chroot"
298 echo "force-unsafe-io" > "$rootdir/etc/dpkg/dpkg.cfg.d/force-unsafe-io"
299 echo "force-confnew" > "$rootdir/etc/dpkg/dpkg.cfg.d/force-confnew"
301 cleanup+=("umount $rootdir/dev")
302 case "$(uname -s)" in
306 mount -t devfs none "$rootdir/dev"
309 echo >&2 "Warning: Unexpected uname -s output."
314 chroot "$rootdir" apt-get update
315 chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends policyrcd-script-zg2
316 cat > "$rootdir/usr/local/sbin/policy-rc.d" << 'EOF'
319 # policy-rc.d script for chroots.
320 # Copyright (c) 2007 Peter Palfrader <peter@palfrader.org>
327 echo "Not running services in chroot."
333 chmod +x "$rootdir/usr/local/sbin/policy-rc.d"
334 [ -z "$bare" ] && [ -z "$ubuntu" ] && chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends locales-all
335 chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends build-essential
336 [ -z "$bare" ] && chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends zsh less vim fakeroot devscripts gdb
337 rm -f "$rootdir/etc/apt/sources.list" "$rootdir/etc/apt/sources.list.d/*"
338 chroot "$rootdir" apt-get clean
339 umount "$rootdir/dev" 2>/dev/null || true
340 umount "$rootdir/sys" 2>/dev/null || true
342 tartmp=$(tempfile --directory "$basedir" --suffix=".tar.gz")
343 cleanup+=("rm -f $tartmp")
347 if ! [ -z "$keep" ]; then
348 savelog -l -c 4 "$target"
350 mv "$tartmp" "$target"