3 # Simple wrapper for debootstrap, run in the docker build context
5 FAKEROOT=`which fakeroot 2> /dev/null`
13 # fakeroot is needed to run the bootstrap stage
15 if [ -z $FAKEROOT ]; then
16 echo "Please install fakeroot to enable bootstraping" >&2
20 # We check in order for
22 # - DEBOOTSTRAP_DIR pointing at a development checkout
23 # - PATH for the debootstrap script (installed)
25 # If neither option works then we checkout debootstrap from its
26 # upstream SCM and run it from there.
29 if [ -z $DEBOOTSTRAP_DIR ]; then
30 DEBOOTSTRAP=`which debootstrap 2> /dev/null`
31 if [ -z $DEBOOTSTRAP ]; then
32 echo "No debootstrap installed, attempting to install from SCM"
33 DEBOOTSTRAP_SOURCE=https://anonscm.debian.org/git/d-i/debootstrap.git
34 git clone ${DEBOOTSTRAP_SOURCE} ./debootstrap.git
35 export DEBOOTSTRAP_DIR=./debootstrap.git
36 DEBOOTSTRAP=./debootstrap.git/debootstrap
39 DEBOOTSTRAP=${DEBOOTSTRAP_DIR}/debootstrap
40 if [ ! -f $DEBOOTSTRAP ]; then
41 echo "Couldn't find script at ${DEBOOTSTRAP}" >&2
47 # Finally check to see if any qemu's are installed
49 BINFMT_DIR=/proc/sys/fs/binfmt_misc
50 if [ ! -e $BINFMT_DIR ]; then
51 echo "binfmt_misc needs enabling for a QEMU bootstrap to work" >&2
54 # DEB_ARCH and QEMU arch names are not totally aligned
78 if [ ! -e "${BINFMT_DIR}/$QEMU" ]; then
79 echo "No binfmt_misc rule to run $QEMU, can't bootstrap" >&2
84 echo "Building a rootfs using ${FAKEROOT} and ${DEBOOTSTRAP} ${DEB_ARCH}/${DEB_TYPE}"
86 ${FAKEROOT} ${DEBOOTSTRAP} --variant=buildd --foreign --arch=$DEB_ARCH $DEB_TYPE . http://httpredir.debian.org/debian || exit 1