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 build the chroot/tarball [$basedir]
54 cnt=$((${#cleanup[*]}-1))
55 for i in $(seq ${cnt} -1 0); do
56 ${cleanup[$i]} || true
61 local suite="$1"; shift
62 local arch="$1"; shift
63 local target="$1"; shift
64 local extra="${1:-}"; shift || true
66 if [ -n "$extra" ]; then
67 local suite="${suite}-${extra}"
71 [${suite}_${arch}-dchroot]
72 description=Debian $suite chroot for $arch
78 source-root-groups=adm
79 script-config=dsa/config
82 if [ "$THISARCH" = "$arch" ]; then
87 echo "personality=linux32"
95 genschrootconf "experimental" "$arch" "$target"
101 if [ -z "$extra" ]; then
102 genschrootconf "$suite" "$arch" "$target" "backports"
112 if [ -e /etc/schroot/dsa/default-mirror ]; then
113 mirror=$(cat /etc/schroot/dsa/default-mirror )
115 mirror="${mirror:-cdn.debian.net}"
117 basedir="/srv/chroot"
121 while getopts "a:b:fhm:" OPTION
146 shift $(($OPTIND - 1))
148 if [ "$#" != 1 ]; then
153 tuple="${suite}_${arch}"
155 [ -d "$basedir" ] || die "Error: $basedir does not exist (or is not a directory)."
157 target="$basedir/$tuple.tar.gz"
158 ! [ -e "$target" ] || [ -n "$force" ] || die "Error: $target already exists."
160 schrootconfig="/etc/schroot/chroot.d/${tuple}-dchroot"
161 ! [ -e "$schrootconfig" ] || [ -n "$force" ] || die "Error: $schrootconfig already exists."
167 genschrootconf "$suite" "$arch" "$target" | tee "$schrootconfig"
169 rootdir=$(mktemp -d "$basedir/create-$suite-XXXXXX")
170 cleanup+=("rm -r $rootdir")
171 cleanup+=("umount $rootdir/sys")
175 --keyring /usr/share/keyrings/debian-archive-keyring.gpg \
179 "$suite" "$rootdir" "http://$mirror/debian"
180 echo "$tuple" > $rootdir/etc/debian_chroot
182 chroot "$rootdir" apt-get update
183 chroot "$rootdir" apt-get install -y --no-install-recommends policyrcd-script-zg2
184 cat > "$rootdir/usr/local/sbin/policy-rc.d" << 'EOF'
187 # policy-rc.d script for chroots.
188 # Copyright (c) 2007 Peter Palfrader <peter@palfrader.org>
195 echo "Not running services in chroot."
201 chmod +x "$rootdir/usr/local/sbin/policy-rc.d"
202 chroot "$rootdir" apt-get install -y --no-install-recommends zsh locales-all build-essential vim fakeroot devscripts gdb
203 rm -f "$rootdir/etc/apt/sources.list" "$rootdir/etc/apt/sources.list.d/*"
204 umount "$rootdir/sys" || true
206 (cd "$rootdir" && tar caf "$target" .)