From 9e285b9608df664e4c06f8fba70ba0546924633a Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 17 May 2010 12:09:44 +0200 Subject: [PATCH] xbps-src: improve multiple mount/umount chroot handling. --- xbps-src/shutils/chroot.sh.in | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/xbps-src/shutils/chroot.sh.in b/xbps-src/shutils/chroot.sh.in index c0e1332168..443cab5a1b 100644 --- a/xbps-src/shutils/chroot.sh.in +++ b/xbps-src/shutils/chroot.sh.in @@ -28,6 +28,8 @@ # Actually this needs the xbps-base-chroot package installed. # +trap "echo && chroot_handler_interrupted $?" INT QUIT TERM KILL + [ -n "$base_chroot" ] && return 0 if [ "${chroot_cmd}" = "chroot" ]; then @@ -222,6 +224,16 @@ _mount() 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() { local action="$1" pkg="$2" norm_builddir="$3" rv=0 @@ -260,13 +272,15 @@ xbps_chroot_handler() if [ "$action" = "chroot" ]; then 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 [ "$norm_builddir" = "yes" ] && \ action="-C $action" env in_chroot=yes LANG=C PATH=$path _ORIGINPKG="$pkg" \ ${chroot_cmd} $XBPS_MASTERDIR sh -c \ - "cd /xbps/srcpkgs/$pkg && xbps-src $action" || rv=$? + "cd /xbps/srcpkgs/$pkg && xbps-src $action" || \ + rv=$? fi rm -f ${XBPS_MASTERDIR}/.xbps_chroot_working