summaryrefslogtreecommitdiff
path: root/debootstrap.sh
blob: 659c166677a99abfd3232a77dea4011306f67690 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh

set -e
set -x

# will use about 2.1 GB
DEBDIR=/tmp/debian-chroot

RELEASE=stretch
MIRROR=http://httpredir.debian.org/debian/
ARCH=${ARCH:-x86_64}

[ -f "build.sh" ] || exit 1

case "$ARCH" in
    x86_64)
        DEBARCH=amd64 ;;
    i386)
        DEBARCH=i386 ;;
    *)
        echo "Unsupported architecture"
        exit 1
esac

if [ $(pgrep -c apt-cacher-ng) -gt 0 ]; then
    MIRROR="http://localhost:3142/httpredir.debian.org/debian"
fi

debootstrap --arch=$DEBARCH $RELEASE "$DEBDIR" "$MIRROR"
echo "deb-src $MIRROR $RELEASE main" >> "$DEBDIR/etc/apt/sources.list"

cp -a * "$DEBDIR/usr/src"

mknod "$DEBDIR/dev/loop0" b 7 0
chroot "$DEBDIR" /usr/src/build.sh