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

Revision 24264, 2.4 KB checked in by broder, 15 years ago (diff)
Explicitly specify to install apt in build chroots. debootstrap's gimpy dependency resolution doesn't always seem to be able to figure out to do that on its own.
  • Property svn:executable set to *
RevLine 
[22687]1#!/bin/sh
[22692]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
[22687]9set -xe
10
[22727]11: ${VG=/dev/dink}
[22687]12SUITE=$1
13ARCH=$2
14CHROOT="${SUITE}-${ARCH}-sbuild"
15DEVICE="$VG/$CHROOT"
[24021]16SIZE=4G
[22687]17
18exittrap() { :; }
19for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done
20trap 'exittrap' EXIT
21
[23147]22if fgrep -qxRs "[$CHROOT]" /etc/schroot/schroot.conf /etc/schroot/chroot.d; then
[22687]23        echo "Chroot $CHROOT already exists." >&2
24        exit 1
25fi
26
[23147]27if [ -d /etc/schroot/chroot.d ]; then
28        CONF=/etc/schroot/chroot.d/$CHROOT
29else
30        CONF=/etc/schroot/schroot.conf
31fi
32
[22687]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"
[24264]63debootstrap --variant=buildd --include=apt,apt-utils,gnupg,build-essential,fakeroot --arch "$ARCH" "$SUITE" "$TARGET" "$MIRROR"
[22687]64install -m a=rx,u+w "$DATA/policy-rc.d" "$TARGET/usr/sbin/"
[22928]65mkdir -p "$TARGET/dev/pts"
66mkdir -p "$TARGET/dev/shm"
67mkdir -p "$TARGET/afs"
68mkdir -p "$TARGET/mit"
[22687]69umount "$TARGET"
70rmdir "$TARGET"
71exittrap() { :; }
72
[23147]73! [ -s "$CONF" ] || echo >> "$CONF"
74cat >> "$CONF" <<EOF
[22687]75[$CHROOT]
[24258]76type=block-device
[24193]77union-type=aufs
[22687]78description=$CHROOT
79groups=root,sbuild
80root-groups=root,sbuild
81source-groups=root
82device=$DEVICE
83personality=$PERSONALITY
84EOF
85
[22928]86schroot --chroot="${CHROOT}-source" --directory=/ -- /bin/sh -xe - \
[22687]87    8< "$SOURCES" \
88    9< "$DATA/debathena-archive.asc" \
89    <<EOF
[22928]90#/debootstrap/debootstrap --second-stage
[24144]91dpkg-divert --local --rename --add /sbin/initctl
92ln -s /bin/true /sbin/initctl
[22696]93debconf-set-selections <<SELECTIONS
94debconf debconf/frontend        select  Noninteractive
95SELECTIONS
[22687]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.