diff --git a/xbps-src/libexec/xbps-src-chroot-helper.sh.in b/xbps-src/libexec/xbps-src-chroot-helper.sh.in index 74f94259dc..d4ac67a411 100644 --- a/xbps-src/libexec/xbps-src-chroot-helper.sh.in +++ b/xbps-src/libexec/xbps-src-chroot-helper.sh.in @@ -98,8 +98,9 @@ umount_chroot_fs() done # Remove created dirs - [ -f ${XBPS_MASTERDIR}/.xbps_mount_bind_done ] && continue - [ -d ${XBPS_MASTERDIR}/xbps ] && rmdir ${XBPS_MASTERDIR}/xbps + if [ ! -f ${XBPS_MASTERDIR}/.xbps_mount_bind_done ]; then + [ -d ${XBPS_MASTERDIR}/xbps ] && rmdir ${XBPS_MASTERDIR}/xbps + fi } if [ $# -ne 1 ]; then diff --git a/xbps-src/shutils/chroot.sh.in b/xbps-src/shutils/chroot.sh.in index f963c1560f..b6fb6067aa 100644 --- a/xbps-src/shutils/chroot.sh.in +++ b/xbps-src/shutils/chroot.sh.in @@ -28,10 +28,6 @@ # Actually this needs the xbps-base-chroot package installed. # -# Umount stuff if SIGINT or SIGQUIT was caught -trap "MASTERDIR=${XBPS_MASTERDIR} ${sudo_cmd} \ - @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount && exit $?" INT QUIT - [ -n "$base_chroot" ] && return 0 if [ "${chroot_cmd}" = "chroot" ]; then @@ -277,8 +273,7 @@ xbps_chroot_handler() 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=$? && _umount && return $rv + "cd /xbps/srcpkgs/$pkg && xbps-src $action" || return $? fi msg_normal "Exiting from the chroot on $XBPS_MASTERDIR." diff --git a/xbps-src/xbps-src.sh.in b/xbps-src/xbps-src.sh.in index df9d979553..b791c37d74 100644 --- a/xbps-src/xbps-src.sh.in +++ b/xbps-src/xbps-src.sh.in @@ -23,8 +23,6 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #- -trap "echo && exit 1" INT QUIT - : ${XBPS_CONFIG_FILE:=@@XBPS_INSTALL_ETCDIR@@/xbps-src.conf} : ${progname:=$(basename $0)} @@ -35,6 +33,18 @@ trap "echo && exit 1" INT QUIT : ${xbps_machine:=$(uname -m)} : ${XBPS_UTILS_REQVER:=20100511} +trap 'sighandler_exit $?' 0 INT QUIT + +sighandler_exit() +{ + # Always unmount in case, we failed before! + if [ -z "$in_chroot" ]; then + @@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-helper umount + fi + [ -n "$1" ] && exit $1 + exit $? +} + usage() { cat << _EOF