xbps-src: improve multiple mount/umount chroot handling.

This commit is contained in:
Juan RP 2010-05-17 12:09:44 +02:00
parent 4f8c08b27e
commit 9e285b9608
1 changed files with 16 additions and 2 deletions

View File

@ -28,6 +28,8 @@
# Actually this needs the xbps-base-chroot package installed. # Actually this needs the xbps-base-chroot package installed.
# #
trap "echo && chroot_handler_interrupted $?" INT QUIT TERM KILL
[ -n "$base_chroot" ] && return 0 [ -n "$base_chroot" ] && return 0
if [ "${chroot_cmd}" = "chroot" ]; then if [ "${chroot_cmd}" = "chroot" ]; then
@ -222,6 +224,16 @@ _mount()
return $? return $?
} }
chroot_handler_interrupted()
{
local rv="$1"
if [ -f ${XBPS_MASTERDIR}/.xbps_chroot_working ]; then
rm -f ${XBPS_MASTERDIR}/.xbps_chroot_working
fi
return $rv
}
xbps_chroot_handler() xbps_chroot_handler()
{ {
local action="$1" pkg="$2" norm_builddir="$3" rv=0 local action="$1" pkg="$2" norm_builddir="$3" rv=0
@ -260,13 +272,15 @@ xbps_chroot_handler()
if [ "$action" = "chroot" ]; then if [ "$action" = "chroot" ]; then
env in_chroot=yes IN_CHROOT=1 LANG=C PATH=$path \ env in_chroot=yes IN_CHROOT=1 LANG=C PATH=$path \
${chroot_cmd} $XBPS_MASTERDIR /bin/sh || rv=$? ${chroot_cmd} $XBPS_MASTERDIR /bin/sh || \
rv=$?
else else
[ "$norm_builddir" = "yes" ] && \ [ "$norm_builddir" = "yes" ] && \
action="-C $action" action="-C $action"
env in_chroot=yes LANG=C PATH=$path _ORIGINPKG="$pkg" \ env in_chroot=yes LANG=C PATH=$path _ORIGINPKG="$pkg" \
${chroot_cmd} $XBPS_MASTERDIR sh -c \ ${chroot_cmd} $XBPS_MASTERDIR sh -c \
"cd /xbps/srcpkgs/$pkg && xbps-src $action" || rv=$? "cd /xbps/srcpkgs/$pkg && xbps-src $action" || \
rv=$?
fi fi
rm -f ${XBPS_MASTERDIR}/.xbps_chroot_working rm -f ${XBPS_MASTERDIR}/.xbps_chroot_working