source: trunk/debathena/scripts/build-server/make-chroot @ 24258

Revision 24258, 2.4 KB checked in by broder, 14 years ago (diff)
Fix typo in schroot config generated by make-chroot
  • Property svn:executable set to *
Line 
1#!/bin/sh
2
3# Usage: make-chroot SUITE ARCH
4
5# Constructs a chroot environment for the Debian/Ubuntu version SUITE
6# and architecture ARCH, and sets up schroot configuration for it.
7# Assumes an approx cache is running at localhost:9999.
8
9set -xe
10
11: ${VG=/dev/dink}
12SUITE=$1
13ARCH=$2
14CHROOT="${SUITE}-${ARCH}-sbuild"
15DEVICE="$VG/$CHROOT"
16SIZE=4G
17
18exittrap() { :; }
19for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done
20trap 'exittrap' EXIT
21
22if fgrep -qxRs "[$CHROOT]" /etc/schroot/schroot.conf /etc/schroot/chroot.d; then
23        echo "Chroot $CHROOT already exists." >&2
24        exit 1
25fi
26
27if [ -d /etc/schroot/chroot.d ]; then
28        CONF=/etc/schroot/chroot.d/$CHROOT
29else
30        CONF=/etc/schroot/schroot.conf
31fi
32
33if [ "$ARCH" = "i386" ]; then
34        PERSONALITY=linux32
35elif [ "$ARCH" = "amd64" ]; then
36        PERSONALITY=linux
37else
38        echo "Unrecognized architecture $ARCH." >&2
39        exit 1
40fi
41
42DATA="$(dirname "$0")"
43
44SOURCESD="$DATA/sources.list.d"
45if [ -e "$SOURCESD/debian/$SUITE.list" ]; then
46        SOURCES="$SOURCESD/debian/$SUITE.list"
47        MIRROR=http://localhost:9999/debian
48elif [ -e "$SOURCESD/ubuntu/$SUITE.list" ]; then
49        SOURCES="$SOURCESD/ubuntu/$SUITE.list"
50        MIRROR=http://localhost:9999/ubuntu
51else
52        echo "Unrecognized suite $SUITE." >&2
53        exit 1
54fi
55
56lvcreate --size "$SIZE" --name "$CHROOT" "$VG"
57mkfs.ext3 "$DEVICE"
58tune2fs -c 0 -i 0 "$DEVICE"
59
60exittrap() { umount "$TARGET" || :; rmdir "$TARGET" || :; }
61TARGET=$(mktemp -dt make-chroot.XXXXXX)
62mount "$DEVICE" "$TARGET"
63debootstrap --variant=buildd --include=apt-utils,gnupg,build-essential,fakeroot --arch "$ARCH" "$SUITE" "$TARGET" "$MIRROR"
64install -m a=rx,u+w "$DATA/policy-rc.d" "$TARGET/usr/sbin/"
65mkdir -p "$TARGET/dev/pts"
66mkdir -p "$TARGET/dev/shm"
67mkdir -p "$TARGET/afs"
68mkdir -p "$TARGET/mit"
69umount "$TARGET"
70rmdir "$TARGET"
71exittrap() { :; }
72
73! [ -s "$CONF" ] || echo >> "$CONF"
74cat >> "$CONF" <<EOF
75[$CHROOT]
76type=block-device
77union-type=aufs
78description=$CHROOT
79groups=root,sbuild
80root-groups=root,sbuild
81source-groups=root
82device=$DEVICE
83personality=$PERSONALITY
84EOF
85
86schroot --chroot="${CHROOT}-source" --directory=/ -- /bin/sh -xe - \
87    8< "$SOURCES" \
88    9< "$DATA/debathena-archive.asc" \
89    <<EOF
90#/debootstrap/debootstrap --second-stage
91dpkg-divert --local --rename --add /sbin/initctl
92ln -s /bin/true /sbin/initctl
93debconf-set-selections <<SELECTIONS
94debconf debconf/frontend        select  Noninteractive
95SELECTIONS
96cat <&8 > /etc/apt/sources.list
97! type apt-key >/dev/null || apt-key add - <&9
98apt-get -q -y update
99apt-get -q -y dist-upgrade
100EOF
Note: See TracBrowser for help on using the repository browser.