mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2024-12-22 07:00:28 +00:00
buildlab: make work in vservers
This commit is contained in:
parent
43f888ad5e
commit
715129c348
40
buildlab.in
40
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user