image: Add /sysroot as a toplevel bind mount to the real root

This allows tools to see and operate on the "real" root conveniently;
for example, ostree clearly needs to operate on /ostree/repo.
This commit is contained in:
Colin Walters 2011-10-27 16:59:01 -04:00
parent cb04d99b76
commit d145b0426c
3 changed files with 11 additions and 3 deletions

View File

@ -144,8 +144,10 @@ if ! test -d ${OBJ}; then
rm ostree/gnomeos-origin/debian-setup.sh rm ostree/gnomeos-origin/debian-setup.sh
(cd ostree/gnomeos-origin; find . '!' -type p | grep -v '^.$' | $OSTREE commit -s 'Run debian-setup.sh' --repo=../repo --from-stdin) (cd ostree/gnomeos-origin; find . '!' -type p | grep -v '^.$' | $OSTREE commit -s 'Run debian-setup.sh' --repo=../repo --from-stdin)
cp -p ${SRCDIR}/chroot_break ostree/gnomeos-origin/sbin/chroot_break # This is the name for the real rootfs, not the chroot
(cd ostree/gnomeos-origin; $OSTREE commit -s 'Add chroot_break' --repo=../repo --add=sbin/chroot_break) (cd ostree/gnomeos-origin;
mkdir sysroot;
$OSTREE commit -s 'Add sysroot' --repo=../repo --add=sysroot)
(cd ostree; (cd ostree;
rev=$($OSTREE rev-parse --repo=repo master) rev=$($OSTREE rev-parse --repo=repo master)

View File

@ -45,4 +45,4 @@ fi
kv=`uname -r` kv=`uname -r`
kernel=/boot/vmlinuz-${kv} kernel=/boot/vmlinuz-${kv}
exec qemu-kvm -kernel ${kernel} -initrd gnomeos-initrd.img -hda gnomeos-fs.img -append "root=/dev/sda ostree=current" exec qemu-kvm -kernel ${kernel} -initrd gnomeos-initrd.img -hda gnomeos-fs.img -append "root=/dev/sda ostree=current $1"

View File

@ -219,6 +219,12 @@ static int switchroot(const char *newroot, const char *subroot)
} }
} }
snprintf(destpath, sizeof(destpath), "%s/sysroot", subroot_path);
if (mount(newroot, destpath, NULL, MS_BIND, NULL) < 0) {
perrorv("Failed bind mount sysroot");
return -1;
}
if (chdir(newroot)) { if (chdir(newroot)) {
perrorv("failed to change directory to %s", newroot); perrorv("failed to change directory to %s", newroot);
return -1; return -1;