Skip to content

Commit 42317c7

Browse files
committed
split configuration variables off into their own script
1 parent dfd7926 commit 42317c7

File tree

2 files changed

+51
-35
lines changed

2 files changed

+51
-35
lines changed

configuration

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# this file contains the configuration variables for the main script
2+
# vim: noai:ts=4:sw=4
3+
4+
# basically our working directory
5+
BASE_DIR=`pwd`
6+
7+
# target and sources for our chroor
8+
ROOT_TARGET=build_environment
9+
ROOT_SUITE=wheezy
10+
ROOT_SOURCE=http://http.debian.net/debian
11+
REQUIRED_PACKAGES=gcc-arm-linux-gnueabihf,ccache,git,kernel-wedge,libncursesw5-dev
12+
13+
# debootstrap sources and working directory
14+
DEBOOT_DEB=debootstrap_1.0.55_all.deb
15+
DEBOOT_SRC=http://ftp.debian.org/debian/pool/main/d/debootstrap
16+
DEBOOT_TMP=deboot_working
17+
18+
# this patch from http://blog.tsunanet.net/2013/01/using-debootstrap-with-grsec.html?m=1
19+
# it fixed deboot throwing an error when it tries to mount the proc system
20+
MOUNT_PATCH="--- usr/share/debootstrap/functions.orig 2013-11-26 07:15:53.909242727 -0600
21+
+++ usr/share/debootstrap/functions 2013-11-26 07:17:39.464665969 -0600
22+
@@ -998,12 +998,14 @@
23+
umount_on_exit /proc/bus/usb
24+
umount_on_exit /proc
25+
umount "'"'"\$TARGET/proc"'"'" 2>/dev/null || true
26+
- in_target mount -t proc proc /proc
27+
+# in_target mount -t proc proc /proc
28+
+ sudo mount -o bind /proc "'"'"\$TARGET/proc"'"'"
29+
if [ -d "'"'"\$TARGET/sys"'"'" ] && \\
30+
grep -q '[[:space:]]sysfs' /proc/filesystems 2>/dev/null; then
31+
umount_on_exit /sys
32+
umount "'"'"\$TARGET/sys"'"'" 2>/dev/null || true
33+
- in_target mount -t sysfs sysfs /sys
34+
+# in_target mount -t sysfs sysfs /sys
35+
+ sudo mount -o bin /sys "'"'"\$TARGET/sys"'"'"
36+
fi
37+
on_exit clear_mtab
38+
;;
39+
"
40+

setup.sh

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
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

97
if [ '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;
1412
fi
@@ -29,54 +27,32 @@ case "$MACHINE_TYPE" in
2927
;;
3028
esac
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-
5430
mkdir -p $DEBOOT_TMP
5531
cd $DEBOOT_TMP
56-
wget -c http://ftp.debian.org/debian/pool/main/d/debootstrap/$DEBOOT_DEB
32+
wget -c $DEBOOT_SRC/$DEBOOT_DEB
5733
ar -x $DEBOOT_DEB
5834
tar -xf data.tar.xz
5935
printf '%s' "$MOUNT_PATCH"|patch --ignore-whitespace --verbose usr/share/debootstrap/functions
6036

6137
cd $BASE_DIR
62-
mkdir -p $ROOT_DIR
38+
mkdir -p $ROOT_TARGET
6339
DEBOOTSTRAP_DIR=$BASE_DIR/$DEBOOT_TMP/usr/share/debootstrap
6440
export 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

6743
echo 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
7147
echo 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
7450
exit 101
7551
EOF
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
8056
echo 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

Comments
 (0)