File tree Expand file tree Collapse file tree 3 files changed +26
-29
lines changed
Expand file tree Collapse file tree 3 files changed +26
-29
lines changed Original file line number Diff line number Diff line change @@ -38,18 +38,22 @@ case "$1" in
3838 exit 0
3939 ;;
4040 setup)
41+ echo " Setting up PATH"
42+ set_path
4143 echo " Creating the deboot, chroot, and kernel directories"
4244 create_directories
4345 echo " Setting up deboot"
4446 get_deboot
45- echo " Patching deboot"
46- patch_deboot
47+ # could probably split deboot into the two stages it takes
4748 echo " Creating the chroot build environment"
4849 deboot_chroot
50+ # we need to set up locales and probably bind stuff like proc and pts here
4951 echo " Upgrading the chroot system"
5052 upgrade_chroot
5153 echo " Installing build tools"
5254 install_build_tools
55+ echo " Restoring PATH"
56+ reset_path
5357 ;;
5458 update)
5559 echo " Upgrading the chroot system"
@@ -58,25 +62,3 @@ case "$1" in
5862esac
5963exit 0
6064
61- cd $BASE_DIR
62- mkdir -p $ROOT_TARGET
63- DEBOOTSTRAP_DIR=$BASE_DIR /$DEBOOT_DIR /usr/share/debootstrap
64- export DEBOOTSTRAP_DIR
65- $BASE_DIR /$DEBOOT_DIR /usr/sbin/debootstrap --arch=$ROOT_ARCH --include=$REQUIRED_PACKAGES --no-check-gpg $ROOT_SUITE $BASE_DIR /$ROOT_TARGET $ROOT_SOURCE
66-
67- echo Unmounting proc from chroot
68- umount $BASE_DIR /$ROOT_TARGET /proc
69-
70- # stop dpkg from running daemons
71- echo Disabling dpkg daemons
72- cat > $BASE_DIR /$ROOT_TARGET /usr/sbin/policy-rc.d << EOF
73- #!/bin/sh
74- exit 101
75- EOF
76- chmod a+x $BASE_DIR /$ROOT_TARGET /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_TARGET dpkg-divert --divert /usr/bin/ischroot.debianutils --rename /usr/bin/ischroot
82- chroot $BASE_DIR /$ROOT_TARGET /bin/ln -s /bin/true /usr/bin/ischroot
Original file line number Diff line number Diff line change 2323# if you want the script to dump everything in a different
2424# location from where the script is run
2525BASE_DIR=`pwd`
26-
26+ #this is the path that will be used while the script is running
27+ #it should contain paths to keep the host system and the chroot
28+ #functional
29+ DUAL_PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
2730# target and sources for our chroot
2831ROOT_TARGET=build_environment
2932#ROOT_SUITE=wheezy
@@ -32,7 +35,7 @@ ROOT_SUITE=saucy
3235ROOT_SOURCE=http://archive.ubuntu.com/ubuntu/
3336# these packages will be installed into the chroot build environment
3437# and are needed to build the kernel
35- REQUIRED_PACKAGES=gcc-arm-linux-gnueabihf ccache kernel-wedge libncursesw5-dev
38+ REQUIRED_PACKAGES=gcc-arm-linux-gnueabihf\ ccache\ kernel-wedge\ libncursesw5-dev
3639
3740# the script should be able to figure this out, but you can override
3841# or set it manually here, leaving it blank is fine
Original file line number Diff line number Diff line change @@ -33,22 +33,34 @@ create_directories ()
3333 mkdir -p $BASE_DIR /$KERNEL_DIR
3434}
3535
36+ # do path magic
37+ ORIGINAL_PATH=$PATH
38+ set_path ()
39+ {
40+ ORIGINAL_PATH=$PATH ;
41+ PATH=$DUAL_PATH ;
42+ }
43+ reset_path ()
44+ {
45+ PATH=$ORIGINAL_PATH
46+ }
3647# this function gets the debootstrap package and unpacks it into the appropriate directory, all ready to be used
3748get_deboot ()
3849{
3950 cd $BASE_DIR /$DEBOOT_DIR ;
4051 wget -c $DEBOOT_SRC /$DEBOOT_DEB ;
4152 ar -x $DEBOOT_DEB ;
42- tar -xzf data.tar.gz ;
53+ tar -xf data.tar.xz ;
4354 cd $BASE_DIR ;
4455}
4556
4657# this function just creates the chroot environment
4758deboot_chroot ()
4859{
4960 # do the bootstrap
50- DEBOOTSTRAP_DIR=$BASE_DIR /$DEBOOT_DIR /usr/share/debootstrap $BASE_DIR /$DEBOOT_DIR /usr/sbin/debootstrap --variant=buildd --arch=$ROOT_ARCH --no-check-gpg $ROOT_SUITE $BASE_DIR /$ROOT_TARGET $ROOT_SOURCE ;
51-
61+ DEBOOTSTRAP_DIR=$BASE_DIR /$DEBOOT_DIR /usr/share/debootstrap $BASE_DIR /$DEBOOT_DIR /usr/sbin/debootstrap --foreign --arch=$ROOT_ARCH --variant=buildd --no-check-gpg $ROOT_SUITE $BASE_DIR /$ROOT_TARGET $ROOT_SOURCE ;
62+ # do the second stage bootstrap
63+ chroot $BASE_DIR /$ROOT_TARGET /debootstrap/debootstrap --second-stage;
5264 # deboot feels the need to mount proc, we don't need it here
5365 umount $BASE_DIR /$ROOT_TARGET /proc;
5466
You can’t perform that action at this time.
0 commit comments