11#! /bin/bash
22# vim: noai:ts=4:sw=4
33
4- BASE_DIR=` pwd`
5- DEBOOT_DEB=debootstrap_1.0.55_all.deb
6- DEBOOT_TMP=deboot_working
7- ROOT_DIR=root
4+ # this is the main script for controlling the build environment and such
5+ source configuration
86
97if [ ' clean' == " $1 " ]; then
108 echo " Removing the debian chroot"
11- rm -rf $ROOT_DIR
9+ rm -rf $ROOT_TARGET
1210 rm -rf $DEBOOT_TMP
1311 exit 0;
1412fi
@@ -29,54 +27,32 @@ case "$MACHINE_TYPE" in
2927 ;;
3028esac
3129
32- # this patch from http://blog.tsunanet.net/2013/01/using-debootstrap-with-grsec.html?m=1
33- MOUNT_PATCH=" --- usr/share/debootstrap/functions.orig 2013-11-26 07:15:53.909242727 -0600
34- +++ usr/share/debootstrap/functions 2013-11-26 07:17:39.464665969 -0600
35- @@ -998,12 +998,14 @@
36- umount_on_exit /proc/bus/usb
37- umount_on_exit /proc
38- umount " ' "' " \$ TARGET/proc" ' "' " 2>/dev/null || true
39- - in_target mount -t proc proc /proc
40- +# in_target mount -t proc proc /proc
41- + sudo mount -o bind /proc " ' "' " \$ TARGET/proc" ' "' "
42- if [ -d " ' "' " \$ TARGET/sys" ' "' " ] && \\
43- grep -q '[[:space:]]sysfs' /proc/filesystems 2>/dev/null; then
44- umount_on_exit /sys
45- umount " ' "' " \$ TARGET/sys" ' "' " 2>/dev/null || true
46- - in_target mount -t sysfs sysfs /sys
47- +# in_target mount -t sysfs sysfs /sys
48- + sudo mount -o bin /sys " ' "' " \$ TARGET/sys" ' "' "
49- fi
50- on_exit clear_mtab
51- ;;
52- "
53-
5430mkdir -p $DEBOOT_TMP
5531cd $DEBOOT_TMP
56- wget -c http://ftp.debian.org/debian/pool/main/d/debootstrap /$DEBOOT_DEB
32+ wget -c $DEBOOT_SRC /$DEBOOT_DEB
5733ar -x $DEBOOT_DEB
5834tar -xf data.tar.xz
5935printf ' %s' " $MOUNT_PATCH " | patch --ignore-whitespace --verbose usr/share/debootstrap/functions
6036
6137cd $BASE_DIR
62- mkdir -p $ROOT_DIR
38+ mkdir -p $ROOT_TARGET
6339DEBOOTSTRAP_DIR=$BASE_DIR /$DEBOOT_TMP /usr/share/debootstrap
6440export DEBOOTSTRAP_DIR
65- $BASE_DIR /$DEBOOT_TMP /usr/sbin/debootstrap --arch $ARCH --no-check-gpg wheezy $BASE_DIR /$ROOT_DIR http://http.debian.net/debian
41+ $BASE_DIR /$DEBOOT_TMP /usr/sbin/debootstrap --arch= $ARCH --include= $REQUIRED_PACKAGES -- no-check-gpg $ROOT_SUITE $BASE_DIR /$ROOT_TARGET $ROOT_SOURCE
6642
6743echo Unmounting proc from chroot
68- umount $BASE_DIR /$ROOT_DIR /proc
44+ umount $BASE_DIR /$ROOT_TARGET /proc
6945
7046# stop dpkg from running daemons
7147echo Disabling dpkg daemons
72- cat > $BASE_DIR /$ROOT_DIR /usr/sbin/policy-rc.d << EOF
48+ cat > $BASE_DIR /$ROOT_TARGET /usr/sbin/policy-rc.d << EOF
7349#!/bin/sh
7450exit 101
7551EOF
76- chmod a+x $BASE_DIR /$ROOT_DIR /usr/sbin/policy-rc.d
52+ chmod a+x $BASE_DIR /$ROOT_TARGET /usr/sbin/policy-rc.d
7753
7854# divert ischroot
7955# note that this throws error, my need to be fixed, not sure
8056echo Diverting ischroot
81- chroot $BASE_DIR /$ROOT_DIR dpkg-divert --divert /usr/bin/ischroot.debianutils --rename /usr/bin/ischroot
82- chroot $BASE_DIR /$ROOT_DIR /bin/ln -s /bin/true /usr/bin/ischroot
57+ chroot $BASE_DIR /$ROOT_TARGET dpkg-divert --divert /usr/bin/ischroot.debianutils --rename /usr/bin/ischroot
58+ chroot $BASE_DIR /$ROOT_TARGET /bin/ln -s /bin/true /usr/bin/ischroot
0 commit comments