diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-09-30 06:42:58 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-09-30 06:42:58 +0000 |
commit | 715129c348846128bf63cadcfc84825df250b3b8 (patch) | |
tree | 6e673d5386d930db765ce992386221015768a332 | |
parent | 43f888ad5e92b2242f512992c71902100956a87a (diff) | |
download | abuild-715129c348846128bf63cadcfc84825df250b3b8.tar.gz abuild-715129c348846128bf63cadcfc84825df250b3b8.tar.bz2 abuild-715129c348846128bf63cadcfc84825df250b3b8.tar.xz abuild-715129c348846128bf63cadcfc84825df250b3b8.zip |
buildlab: make work in vservers
-rwxr-xr-x | buildlab.in | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/buildlab.in b/buildlab.in index a9dcce8..c555596 100755 --- a/buildlab.in +++ b/buildlab.in @@ -54,6 +54,37 @@ runpart() { $part || die "$part failed" } +is_vserver() { + egrep -q '^VxID:[[:space:]]*[0-9]+' /proc/self/status +} + +do_chroot_open() { + local path="$1" + if is_vserver; then + # vserver does not allow us mount or create devices + # but we can create hard links as long as chroot is + # on same filesystem as real root + rmdir "$path"/proc "$path"/sys "$path"/dev 2>/dev/null + ln /dev "$path"/dev + ln /proc "$path"/proc + ln /sys "$path"/sys + + else + mkdir -p "$path"/dev "$path"/proc "$path"/sys + mount -o bind /dev "$path"/dev || return 1 + mount -o bind /proc "$path"/proc + mount -o bind /sys "$path"/sys + fi +} + +do_chroot_close() { + local path="$1" + if is_vserver; then + rmdir "$path"/dev "$path"/proc "$path"/sys + else + umount "$path"/dev "$path"/proc "$path"/sys + fi +} do_chroot_action() { local path="$1" @@ -61,10 +92,7 @@ do_chroot_action() { msg "Doing chroot action '$command' in '$path'..." - mount -o bind /dev "$path"/dev - mount -o bind /proc "$path"/proc - mount -o bind /sys "$path"/sys - + do_chroot_open "$path" || return 1 shift; # XXX: we have to do this because busybox clobbers us, bleah. @@ -72,9 +100,7 @@ do_chroot_action() { chroot "$path" /bin/sh /.chroot-action.sh rm "$path"/.chroot-action.sh - umount "$path"/dev - umount "$path"/proc - umount "$path"/sys + do_chroot_close } update_chroot() { |