aboutsummaryrefslogtreecommitdiffstats
path: root/Tools/portbuild
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2005-02-12 11:38:08 +0800
committerkris <kris@FreeBSD.org>2005-02-12 11:38:08 +0800
commit22adbba73a0ba9b0934955cab641bd073be8f01f (patch)
tree0ea1a4fb297bf9ac55f3c7ca8c5928a831e0634a /Tools/portbuild
parented72c6bbe2575f567b39bed997492598e50205c6 (diff)
downloadfreebsd-ports-gnome-22adbba73a0ba9b0934955cab641bd073be8f01f.tar.gz
freebsd-ports-gnome-22adbba73a0ba9b0934955cab641bd073be8f01f.tar.zst
freebsd-ports-gnome-22adbba73a0ba9b0934955cab641bd073be8f01f.zip
* Instead of using umount -f to unmount things, first use fstat to
look for processes holding open references within the FS and kill them, then use regular umount. This is necessary now that devfs cannot be force-unmounted, and has the benefit that processes can't hang around holding references to files between port builds. * Reduce possibility for error by testing for presence of executable ldconfig inside the chroot before attempting to run it (e.g. it may not be there if the chroot was not completely initialized)
Diffstat (limited to 'Tools/portbuild')
-rwxr-xr-xTools/portbuild/scripts/clean-chroot51
1 files changed, 44 insertions, 7 deletions
diff --git a/Tools/portbuild/scripts/clean-chroot b/Tools/portbuild/scripts/clean-chroot
index 3911470fd284..eba3889f8db8 100755
--- a/Tools/portbuild/scripts/clean-chroot
+++ b/Tools/portbuild/scripts/clean-chroot
@@ -1,5 +1,37 @@
#!/bin/sh
+kill_procs()
+{
+ dir=$1
+
+ pids="XXX"
+ while [ ! -z "${pids}" ]; do
+ pids=$(fstat -f "$dir" | tail +2 | awk '{print $3}' | sort -u)
+ if [ ! -z "${pids}" ]; then
+ echo "Killing off pids in ${dir}"
+ ps -p $pids
+ kill -KILL ${pids} 2> /dev/null
+ sleep 2
+ fi
+ done
+}
+
+cleanup_mount() {
+ chroot=$1
+ mount=$2
+
+ if [ -d ${chroot}${mount} ]; then
+ mdir=$(fstat -f ${chroot}${mount} | head -2 | tail -1 | awk '{print $5}')
+ if [ "${mdir}" = "MOUNT" ]; then
+ umount ${chroot}${mount} || echo "Cleanup of ${chroot}${mount} failed!"
+ fi
+ if [ "${mdir}" = "${chroot}${mount}" ]; then
+ kill_procs ${chroot}${mount}
+ umount ${chroot}${mount} || echo "Cleanup of ${chroot}${mount} failed!"
+ fi
+ fi
+}
+
arch=$1
branch=$2
chroot=$3
@@ -8,6 +40,10 @@ noclean=$4
# directories to clean
cleandirs="/usr/local /usr/X11R6 /compat /var/db/pkg"
+if [ ! -d "${chroot}" ]; then
+ exit 0
+fi
+
if [ `realpath ${chroot}` = "/" ]; then
# Don't spam the root file system if something has gone wrong!
exit 1
@@ -16,13 +52,14 @@ fi
#umount ${chroot}/proc
if [ ${arch} = "i386" ]; then
- chroot ${chroot} umount -f /compat/linux/proc
+ cleanup_mount ${chroot} /compat/linux/proc
fi
+
+for i in /a/ports /usr/opt/doc /usr/src /dev; do
+ cleanup_mount ${chroot} ${i}
+done
-umount -f ${chroot}/a/ports 2> /dev/null
-umount -f ${chroot}/usr/opt/doc 2> /dev/null
-umount -f ${chroot}/usr/src 2> /dev/null
-umount -f ${chroot}/dev 2> /dev/null
+#kill_procs ${chroot}
if [ $noclean = 0 ]; then
rm -rf ${chroot}/tmp/*
@@ -32,9 +69,9 @@ if [ $noclean = 0 ]; then
rm -rf ${chroot}${dir} >/dev/null 2>&1
fi
done
- chroot ${chroot} /sbin/ldconfig -R
+ test -x ${chroot}/sbin/ldconfig && chroot ${chroot} /sbin/ldconfig -R
if [ ${arch} = "i386" ]; then
- chroot ${chroot} /sbin/ldconfig -aout -R
+ test -x ${chroot}/sbin/ldconfig && chroot ${chroot} /sbin/ldconfig -aout -R
fi
rm -rf ${chroot}/var/db/pkg/*
rm -rf ${chroot}/used