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]
43 -d dir place where to build the chroot [${builddir:-$basedir}]
44 -f overwrite config and target tarball
45 -g GROUPS groups that should have access to the schroot [$groupuser]
46 -k KEYRING use an alternate keyring [$keyring]
47 -p PERS use a different sbuild personality [$personality]
48 -r GROUPS groups that should have root in the schroot [$grouproot]
49 -s use sbuild compatible naming scheme
62 cnt=$((${#cleanup[*]}-1))
63 for i in $(seq ${cnt} -1 0); do
64 ${cleanup[$i]} || true
69 local suite="$1"; shift
70 local arch="$1"; shift
71 local target="$1"; shift
72 local extra="${1:-}"; shift || true
74 if [ -n "$extra" ]; then
75 local suite="${suite}-${extra}"
78 if [ -n "$sbuildnames" ]; then
79 local name="${suite}-${arch}-sbuild"
81 local name="${suite}_${arch}-dchroot"
87 description=[${name}] Debian $suite chroot for $arch
91 root-groups=$grouproot
93 source-root-groups=adm
96 if dpkg --compare-versions "$(lsb_release --release --short)" '<' 7; then
97 echo "script-config=$personality/config"
99 echo "profile=$personality"
102 if [ "$THISARCH" = "$arch" ]; then
103 echo "aliases=$suite"
106 armel|armhf|i386|powerpc|s390|sparc)
107 echo "personality=linux32"
114 genschrootconf "experimental" "$arch" "$target"
120 if [ -z "$extra" ] && [ -z "$ubuntu" ]; then
121 genschrootconf "$suite" "$arch" "$target" "backports"
131 if [ -e /etc/schroot/dsa/default-mirror ]; then
132 mirror=$(cat /etc/schroot/dsa/default-mirror )
134 mirror="${mirror:-http://cdn.debian.net/debian}"
137 basedir="/srv/chroot"
139 keyring=/usr/share/keyrings/debian-archive-keyring.gpg
143 groupuser="Debian,guest"
148 while getopts "a:b:cd:fg:hk:m:p:r:su" OPTION
180 personality="$OPTARG"
197 shift $(($OPTIND - 1))
199 if [ "$#" != 1 ]; then
204 tuple="${suite}_${arch}"
206 builddir=${builddir:-$basedir}
207 [ -d "$basedir" ] || die "Error: $basedir does not exist (or is not a directory)."
208 [ -d "$builddir" ] || die "Error: $builddir does not exist (or is not a directory)."
210 target="$basedir/$tuple.tar.gz"
211 ! [ -e "$target" ] || [ -n "$force" ] || die "Error: $target already exists."
213 schrootconfig="/etc/schroot/chroot.d/${tuple}-dchroot"
214 ! [ -e "$schrootconfig" ] || [ -n "$force" ] || die "Error: $schrootconfig already exists."
220 genschrootconf "$suite" "$arch" "$target" | tee "$schrootconfig"
222 if [ -n "$configonly" ]; then exit 0; fi
224 rootdir=$(mktemp -d "$builddir/create-$suite-XXXXXX")
225 cleanup+=("rm -r $rootdir")
226 cleanup+=("umount $rootdir/sys")
230 --keyring "$keyring" \
234 "$suite" "$rootdir" "$mirror"
235 echo "$tuple" > $rootdir/etc/debian_chroot
237 chroot "$rootdir" apt-get update
238 chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends policyrcd-script-zg2
239 cat > "$rootdir/usr/local/sbin/policy-rc.d" << 'EOF'
242 # policy-rc.d script for chroots.
243 # Copyright (c) 2007 Peter Palfrader <peter@palfrader.org>
250 echo "Not running services in chroot."
256 chmod +x "$rootdir/usr/local/sbin/policy-rc.d"
257 [ -z "$ubuntu" ] && chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends locales-all
258 chroot "$rootdir" apt-get install -y --force-yes --no-install-recommends zsh build-essential less vim fakeroot devscripts gdb
259 rm -f "$rootdir/etc/apt/sources.list" "$rootdir/etc/apt/sources.list.d/*"
260 umount "$rootdir/sys" || true
262 tartmp=$(tempfile --directory "$basedir" --suffix=".tar.gz")
263 cleanup+=("rm -f $tartmp")
264 (cd "$rootdir" && tar caf "$tartmp" . && mv "$tartmp" "$target")