[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

apt-install, and packages adding mounts



I ran into a new problem recently.  I added hotplug to the Skolelinux
CD, and because of the apt-install call in hw-detect, it was installed
by base-installer.  But this package seem to mount
/target/proc/bus/usb/ at install time, and this make apt-install fail
when it tries to unmount /target/proc/.

I propose this patch to fix it, making sure all added mount points are
unmounted after the package is installed.  Do you think this could
work?

--- apt-install.~1.15.~	Tue Jan  6 11:20:08 2004
+++ apt-install	Sat Feb 14 00:56:49 2004
@@ -63,6 +63,9 @@
     -o Dpkg::Options::=--root=/target \
     -y --download-only install $@ >> $log 2>&1
 
+# Record the current mounts
+cat /proc/mounts |cut -d" " -f 2 | /target/usr/bin/sort -ru > /tmp/mount.pre
+
 # Some packages (eg. the kernel-image package) require a mounted /proc/
 # Only mount it if it isn't mounted already
 if [ ! -f /target/proc/cmdline ] ; then
@@ -72,6 +75,11 @@
 DEBIAN_FRONTEND=noninteractive \
 chroot /target apt-get --no-download -y install $@ < /dev/null >> $log 2>&1
 
-umount /target/proc
+# Undo the mounts done during installation.
+cat /proc/mounts |cut -d" " -f 2 | /target/usr/bin/sort -ru > /tmp/mount.post
+for dir in `/target/usr/bin/comm -13 /tmp/mount.pre /tmp/mount.post`; do
+    umount $dir
+done
+rm -f /tmp/mount.pre /tmp/mount.post
 
 exit 0



Reply to: