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

Revision 22692, 2.1 KB checked in by ghudson, 16 years ago (diff)
Document build server scripts. * debathena/scripts/build-server/policy-rc.d, debathena/scripts/build-server/make-chroot: Comment.
  • 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
11VG=/dev/dink
12SUITE=$1
13ARCH=$2
14CHROOT="${SUITE}-${ARCH}-sbuild"
15DEVICE="$VG/$CHROOT"
16SIZE=2G
17
18exittrap() { :; }
19for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done
20trap 'exittrap' EXIT
21
22if fgrep -x "[$CHROOT]" /etc/schroot/schroot.conf; then
23        echo "Chroot $CHROOT already exists." >&2
24        exit 1
25fi
26
27if [ "$ARCH" = "i386" ]; then
28        PERSONALITY=linux32
29elif [ "$ARCH" = "amd64" ]; then
30        PERSONALITY=linux
31else
32        echo "Unrecognized architecture $ARCH." >&2
33        exit 1
34fi
35
36DATA="$(dirname "$0")"
37
38SOURCESD="$DATA/sources.list.d"
39if [ -e "$SOURCESD/debian/$SUITE.list" ]; then
40        SOURCES="$SOURCESD/debian/$SUITE.list"
41        MIRROR=http://localhost:9999/debian
42elif [ -e "$SOURCESD/ubuntu/$SUITE.list" ]; then
43        SOURCES="$SOURCESD/ubuntu/$SUITE.list"
44        MIRROR=http://localhost:9999/ubuntu
45else
46        echo "Unrecognized suite $SUITE." >&2
47        exit 1
48fi
49
50lvcreate --size "$SIZE" --name "$CHROOT" "$VG"
51mkfs.ext3 "$DEVICE"
52tune2fs -c 0 -i 0 "$DEVICE"
53
54exittrap() { umount "$TARGET" || :; rmdir "$TARGET" || :; }
55TARGET=$(mktemp -dt make-chroot.XXXXXX)
56mount "$DEVICE" "$TARGET"
57debootstrap --variant=buildd --include=apt-utils,gnupg,build-essential,fakeroot --foreign --arch "$ARCH" "$SUITE" "$TARGET" "$MIRROR"
58install -m a=rx,u+w "$DATA/policy-rc.d" "$TARGET/usr/sbin/"
59umount "$TARGET"
60rmdir "$TARGET"
61exittrap() { :; }
62
63cat >> /etc/schroot/schroot.conf <<EOF
64
65[$CHROOT]
66type=lvm-snapshot
67description=$CHROOT
68priority=3
69groups=root,sbuild
70root-groups=root,sbuild
71source-groups=root
72device=$DEVICE
73mount-options=-o noatime
74lvm-snapshot-options=--size $SIZE
75personality=$PERSONALITY
76run-setup-scripts=true
77run-exec-scripts=true
78EOF
79
80schroot --chroot="${CHROOT}-source" --directory=/ -- /bin/sh -e - \
81    8< "$SOURCES" \
82    9< "$DATA/debathena-archive.asc" \
83    <<EOF
84/debootstrap/debootstrap --second-stage
85cat <&8 > /etc/apt/sources.list
86! type apt-key >/dev/null || apt-key add - <&9
87apt-get -q -y update
88apt-get -q -y dist-upgrade
89EOF
Note: See TracBrowser for help on using the repository browser.