Instead of applying it only for the final `chroot`, this adds a chroot helper function to apply it appropriately for every chroot, including making sure that we find `chroot` in our current host `PATH` in case it's in a strange place.
Signed-off-by: Andrew "Tianon" Page <admwiggin@gmail.com>
| ... | ... |
@@ -15,6 +15,16 @@ done |
| 15 | 15 |
suite="$1" |
| 16 | 16 |
shift |
| 17 | 17 |
|
| 18 |
+# get path to "chroot" in our current PATH |
|
| 19 |
+chrootPath="$(type -P chroot)" |
|
| 20 |
+rootfs_chroot() {
|
|
| 21 |
+ # "chroot" doesn't set PATH, so we need to set it explicitly to something our new debootstrap chroot can use appropriately! |
|
| 22 |
+ |
|
| 23 |
+ # set PATH and chroot away! |
|
| 24 |
+ PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' \ |
|
| 25 |
+ "$chrootPath" "$rootfsDir" "$@" |
|
| 26 |
+} |
|
| 27 |
+ |
|
| 18 | 28 |
# allow for DEBOOTSTRAP=qemu-debootstrap ./mkimage.sh ... |
| 19 | 29 |
: ${DEBOOTSTRAP:=debootstrap}
|
| 20 | 30 |
|
| ... | ... |
@@ -41,13 +51,13 @@ chmod +x "$rootfsDir/usr/sbin/policy-rc.d" |
| 41 | 41 |
# prevent upstart scripts from running during install/update |
| 42 | 42 |
( |
| 43 | 43 |
set -x |
| 44 |
- chroot "$rootfsDir" dpkg-divert --local --rename --add /sbin/initctl |
|
| 44 |
+ rootfs_chroot dpkg-divert --local --rename --add /sbin/initctl |
|
| 45 | 45 |
cp -a "$rootfsDir/usr/sbin/policy-rc.d" "$rootfsDir/sbin/initctl" |
| 46 | 46 |
sed -i 's/^exit.*/exit 0/' "$rootfsDir/sbin/initctl" |
| 47 | 47 |
) |
| 48 | 48 |
|
| 49 | 49 |
# shrink a little, since apt makes us cache-fat (wheezy: ~157.5MB vs ~120MB) |
| 50 |
-( set -x; chroot "$rootfsDir" apt-get clean ) |
|
| 50 |
+( set -x; rootfs_chroot apt-get clean ) |
|
| 51 | 51 |
|
| 52 | 52 |
# this file is one APT creates to make sure we don't "autoremove" our currently |
| 53 | 53 |
# in-use kernel, which doesn't really apply to debootstraps/Docker images that |
| ... | ... |
@@ -189,10 +199,9 @@ fi |
| 189 | 189 |
|
| 190 | 190 |
( |
| 191 | 191 |
set -x |
| 192 |
- export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
|
| 193 | 192 |
|
| 194 | 193 |
# make sure we're fully up-to-date |
| 195 |
- chroot "$rootfsDir" bash -c 'apt-get update && apt-get dist-upgrade -y' |
|
| 194 |
+ rootfs_chroot sh -xc 'apt-get update && apt-get dist-upgrade -y' |
|
| 196 | 195 |
|
| 197 | 196 |
# delete all the apt list files since they're big and get stale quickly |
| 198 | 197 |
rm -rf "$rootfsDir/var/lib/apt/lists"/* |