From 694d027400f95183ba968465b9ba352aa45cbc9e Mon Sep 17 00:00:00 2001 From: Dimitar Zhekov Date: Thu, 17 Jun 2004 10:26:27 +0000 Subject: [PATCH] Dimitar Zhekov: hacked Build-Target a bit to umount chrooted directories on exit Clifford Wolf: check if we are the only users before doing the umounts [2004051009185026946] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@3232 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- scripts/Build-Target | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/Build-Target b/scripts/Build-Target index 0e5006c6b..c573ff7d3 100755 --- a/scripts/Build-Target +++ b/scripts/Build-Target @@ -355,6 +355,22 @@ pkgloop_action() { $cmd_buildpkg } +# Try to umount any directories mounted by Build-Pkg -chroot +# if we are the last process using them. +# +umount_chroot() { + exec 201> /dev/null + if [ -z "$( fuser "${build_logs}/*.log" )" ]; then + umount -d -f $build_rock/{loop,config,download} 2> /dev/null + umount -d -f -l $build_rock/{loop,config,download} 2> /dev/null + umount -d -f $build_root/proc 2> /dev/null + umount -d -f -l $build_root/proc 2> /dev/null + fi +} + +# must trap outside the group command +trap 'umount_chroot' EXIT + { ln -sf build_target_$$.log ${build_logs}/build_target.log ./scripts/Build-Tools -1 -cfg $config