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
79 if [ -n "$sbuildnames" ]; then
80 local name="${suite}-${arch}-sbuild"
82 local name="${suite}_${arch}-dchroot"
90 local suite="$1"; shift
91 local arch="$1"; shift
92 local target="$1"; shift
93 local extra="${1:-}"; shift || true
96 if [ -n "$extra" ]; then
97 local suite="${suite}-${extra}"
100 local name="$(genname "$suite" "$arch")"
102 local fullname="$name"
106 # FreeBSD only allows relatively short paths to mountpoints
107 # therefore saving a few charakters making the chroot dir fit
108 name=${name/kfreebsd-amd64/k-a}
109 name=${name/kfreebsd-i386/k-i}
115 description=[${fullname}] Debian $suite chroot for $arch
119 [ -n "$groupuser" ] && echo "groups=$groupuser"
120 [ -n "$grouproot" ] && echo "root-groups=$grouproot"
121 [ -n "$users" ] && echo "users=$users"
122 [ -n "$usersroot" ] && echo "root-users=$usersroot"
124 echo "profile=$personality"
126 if [ "$THISARCH" = "$arch" ] && [ -z "$buildd" ]; then
127 if [ -z "$aliases" ] ; then
130 aliases="$aliases,$suite"
133 if [ -n "$aliases" ] ; then
134 echo "aliases=$aliases"
137 armel|armhf|i386|mips|mipsel|powerpc|s390|sparc)
138 echo "personality=linux32"
145 genschrootconf "experimental" "$arch" "$target"
151 if [ -z "$extra" ] && [ -z "$ubuntu" ]; then
152 genschrootconf "$suite" "$arch" "$target" "backports"
153 if [ -n "$buildd" ] ; then
154 genschrootconf "$suite" "$arch" "$target" "backports-sloppy"
155 genschrootconf "$suite" "$arch" "$target" "proposed-updates"
156 genschrootconf "$suite" "$arch" "$target" "security"
159 genschrootconf "$suite" "$arch" "$target" "kfreebsd"
160 genschrootconf "$suite" "$arch" "$target" "kfreebsd-security"
170 local tmpschrootconf=$(tempfile)
171 cleanup+=("rm -f $tmpschrootconf")
172 genschrootconf "$suite" "$arch" "$target" > "$tmpschrootconf"
173 if ! [ -e "$schrootconfig" ] || ! diff "$schrootconfig" "$tmpschrootconf" > /dev/null; then
174 mv "$tmpschrootconf" "$schrootconfig"
175 chmod 644 "$schrootconfig"
184 if [ -e /etc/schroot/dsa/default-mirror ]; then
185 mirror=$(cat /etc/schroot/dsa/default-mirror )
187 mirror="${mirror:-http://ftp.debian.org/debian}"
190 basedir="/srv/chroot"
192 keyring=/usr/share/keyrings/debian-archive-keyring.gpg
196 groupuser="Debian,guest,d-i"
198 include="apt,fakeroot"
209 while getopts "a:b:Bcd:Dfg:hI:Kk:m:o:O:p:r:sS:u" OPTION
230 users="buildd,buildd2"
231 usersroot="buildd,buildd2"
249 include="$include,$OPTARG"
267 personality="$OPTARG"
287 shift $(($OPTIND - 1))
289 if [ "$#" != 1 ]; then
294 tuple="${suite}_${arch}"
296 if [ -z "${builddir:-}" ]; then
297 builddir=${builddir:-$basedir}
298 for u in schroot-unpack unpack; do
299 # if one of these directories exists and is on a different filesystem, prefer it.
300 candidate="$builddir/$u"
301 if [ -e "$candidate" ] &&
302 [ "$(stat -f --printf '%i\n' "$builddir" )" != "$(stat -f --printf '%i\n' "$candidate")" ]; then
303 builddir="$candidate"
307 [ -d "$basedir" ] || die "Error: $basedir does not exist (or is not a directory)."
308 [ -d "$builddir" ] || die "Error: $builddir does not exist (or is not a directory)."
310 target="$basedir/$tuple.tar.gz"
311 ! [ -e "$target" ] || [ -n "$force" ] || die "Error: $target already exists."
313 schrootconfig="/etc/schroot/chroot.d/${tuple}-$suffix"
314 ! [ -e "$schrootconfig" ] || [ -n "$force" ] || die "Error: $schrootconfig already exists."
321 suite_alias="$suite-kfreebsd"
332 if [ -n "$configonly" ]; then
337 rootdir=$(mktemp -d "$builddir/create-$suite-XXXXXX")
338 cleanup+=("rm -r $rootdir")
339 cleanup+=("umount $rootdir/sys")
340 script=/usr/share/debootstrap/scripts/"$suite"
341 if ! [ -e "$script" ]; then
342 if [ -z "$ubuntu" ]; then
343 script=/usr/share/debootstrap/scripts/sid
345 script=/usr/share/debootstrap/scripts/gutsy
351 --keyring "$keyring" \
352 --include="$include" \
356 "$suite_alias" "$rootdir" "$mirror" "$script"
357 echo "$tuple" > "$rootdir/etc/debian_chroot"
358 echo "force-unsafe-io" > "$rootdir/etc/dpkg/dpkg.cfg.d/force-unsafe-io"
359 echo "force-confnew" > "$rootdir/etc/dpkg/dpkg.cfg.d/force-confnew"
361 cleanup+=("umount $rootdir/dev")
362 case "$(uname -s)" in
366 mount -t devfs none "$rootdir/dev"
369 echo >&2 "Warning: Unexpected uname -s output."
374 chroot "$rootdir" apt-get update
375 chroot "$rootdir" apt-get install -y --no-install-recommends policyrcd-script-zg2
376 cat > "$rootdir/usr/local/sbin/policy-rc.d" << 'EOF'
379 # policy-rc.d script for chroots.
380 # Copyright (c) 2007 Peter Palfrader <peter@palfrader.org>
387 echo "Not running services in chroot."
393 chmod +x "$rootdir/usr/local/sbin/policy-rc.d"
394 [ -z "$bare" ] && [ -z "$ubuntu" ] && chroot "$rootdir" apt-get install -y --no-install-recommends locales-all
395 chroot "$rootdir" apt-get install -y --no-install-recommends build-essential
396 [ -z "$bare" ] && chroot "$rootdir" apt-get install -y --no-install-recommends zsh less vim fakeroot devscripts gdb
397 if [ -n "$buildd" ] ; then
399 wheezy|jessie|stretch)
400 chroot "$rootdir" apt-get install -y --no-install-recommends apt-transport-https ca-certificates
403 chroot "$rootdir" apt-get install -y --no-install-recommends ca-certificates
407 if [ -n "$ubuntu" ]; then
408 echo "deb $mirror ${suite}-updates main" >> "$rootdir/etc/apt/sources.list"
409 echo "deb $mirror ${suite}-security main" >> "$rootdir/etc/apt/sources.list"
410 chroot "$rootdir" apt-get update
411 chroot "$rootdir" apt-get dist-upgrade -y
413 rm -f "$rootdir/etc/apt/sources.list" "$rootdir/etc/apt/sources.list.d/*"
414 chroot "$rootdir" apt-get clean
415 umount "$rootdir/dev" 2>/dev/null || true
416 umount "$rootdir/sys" 2>/dev/null || true
418 tartmp=$(tempfile --directory "$basedir" --suffix=".tar.gz")
419 cleanup+=("rm -f $tartmp")
422 chmod 0755 "$rootdir"
424 if ! [ -z "$keep" ]; then
425 savelog -l -c 2 "$target"
427 mv "$tartmp" "$target"