Skip to content

Commit 4ab6c43

Browse files
committed
first commit
0 parents  commit 4ab6c43

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

README.md

Whitespace-only changes.

setup.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
# vim: noai:ts=4:sw=4
3+
4+
BASE_DIR=`pwd`
5+
DEBOOT_DEB=debootstrap_1.0.55_all.deb
6+
DEBOOT_TMP=deboot_working
7+
ROOT_DIR=root
8+
9+
if [ 'clean' == "$1" ]; then
10+
echo "Removing the debian chroot"
11+
rm -rf $ROOT_DIR
12+
rm -rf $DEBOOT_TMP
13+
exit 0;
14+
fi
15+
16+
MACHINE_TYPE=`uname -m`
17+
case "$MACHINE_TYPE" in
18+
i?86)
19+
echo "Selecting i386 architecture"
20+
ARCH=i386
21+
;;
22+
x86_64)
23+
echo "Selecting amd64 architecture"
24+
ARCH=amd64
25+
;;
26+
*)
27+
echo "Your machine is not supported by this script"
28+
exit 1
29+
;;
30+
esac
31+
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+
54+
mkdir -p $DEBOOT_TMP
55+
cd $DEBOOT_TMP
56+
wget -c http://ftp.debian.org/debian/pool/main/d/debootstrap/$DEBOOT_DEB
57+
ar -x $DEBOOT_DEB
58+
tar -xf data.tar.xz
59+
printf '%s' "$MOUNT_PATCH"|patch --ignore-whitespace --verbose usr/share/debootstrap/functions
60+
61+
cd $BASE_DIR
62+
mkdir -p $ROOT_DIR
63+
DEBOOTSTRAP_DIR=$BASE_DIR/$DEBOOT_TMP/usr/share/debootstrap
64+
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
66+
67+
echo Unmounting proc from chroot
68+
umount $BASE_DIR/$ROOT_DIR/proc
69+
70+
#stop dpkg from running daemons
71+
echo Disabling dpkg daemons
72+
cat > $BASE_DIR/$ROOT_DIR/usr/sbin/policy-rc.d <<EOF
73+
#!/bin/sh
74+
exit 101
75+
EOF
76+
chmod a+x $BASE_DIR/$ROOT_DIR/usr/sbin/policy-rc.d
77+
78+
#divert ischroot
79+
#note that this throws error, my need to be fixed, not sure
80+
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

0 commit comments

Comments
 (0)