Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=c089145cf3d0ee7e87c62bd12e27c0618d694c8d

commit c089145cf3d0ee7e87c62bd12e27c0618d694c8d
Author: Michel Hermier <[email protected]>
Date:   Tue Nov 27 16:41:19 2012 +0100

scripts/makepkg

* Make makepkg_chroot to do mount bind from the host (/dev, /proc and
/sys are allways binded to have a proper environement).

diff --git a/scripts/makepkg b/scripts/makepkg
index 2d35cfb..5cd7fda 100755
--- a/scripts/makepkg
+++ b/scripts/makepkg
@@ -2026,18 +2026,22 @@ makepkg_chroot_usage() {
$ECHO "Usage: $0 chroot [options] [command [args]...]"
$ECHO
$ECHO "Options for chroot command:"
-       $ECHO "      --chroot <name>    Enter in the chroot <name>."
-       $ECHO "      --userspec <spec>  See chroot userspec option."
-       $ECHO "      --fakeroot         Enter in fakeroot."
+       $ECHO "      --bind <path>      Bind a path between host and chroot"
+       $ECHO "      --chroot <name>    Enter in the chroot <name>"
+       $ECHO "      --userspec <spec>  See chroot userspec option"
+       $ECHO "      --fakeroot         Enter in fakeroot"
$ECHO "  -h, --help             This help"
}

makepkg_chroot() {
+       local bind_list=('/dev' '/proc' '/sys')
local cmd consumed inchroot infakeroot=0
+       local i ret

while [ $# -gt 0 ]; do
consumed=1
case "$1" in
+               --bind)                 bind_list+=("$2"); consumed=2 ;;
--chroot)               inchroot="$2"; consumed=2 ;;
--userspec)             userspec="$2"; consumed=2 ;;
--fakeroot)             infakeroot=1 ;;
@@ -2067,6 +2071,14 @@ makepkg_chroot() {
error "Cowardly refuse to chroot while in fakeroot!"
return 1
fi
+               for i in "${bind_list[@]}"; do
+                       mkdir -p "$CHROOTDIR/$inchroot/$i"
+                       mount -o bind "$i" "$CHROOTDIR/$inchroot/$i" >/dev/null
+                       if [ "$?" != "0" ]; then
+                               error "An error occurred while attempting to 
mount chroot directories."
+                               exit 1
+                       fi
+               done
cmd+=('INCHROOT=1' 'chroot')
if [ -n "$userspec" ]; then
cmd+=("--userspec=$userspec")
@@ -2080,8 +2092,21 @@ makepkg_chroot() {
fi
cmd+=('fakeroot')
fi
-       "${cmd[@]}" "$@"
-       return $?
+
+       env -- "${cmd[@]}" "$@"
+       ret=$?
+
+       if [ -n "$inchroot" ]; then
+               for i in "${bind_list[@]}"; do
+                       umount "$CHROOTDIR/$inchroot/$i" >/dev/null
+                       if [ "$?" != "0" ]; then
+                               error "An error occurred while attempting to 
mount chroot directories."
+                               exit 1
+                       fi
+               done
+       fi
+
+       return $ret
}

makepkg_clean() {
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to