Hi,

trap solves this problem.
When the script exits with an error during the chroot phase, the script goes
to a clean function that also umount /proc.
I made some tests but the patch is probably not flawless...

Cheers,
Hadar


On 10/20/06, Bas Wijnen <[EMAIL PROTECTED]> wrote:

Package: live-package
Version: 0.99.10-1

When make-live finishes, it leaves debian-live/chroot/lib/init/rw/
mounted.
It also often does this when it is aborted.  Also, debian-live/chroot/proc
is
mounted if the hook script is aborted (that is, if it exits non-0).

Any mounts in the chroot should be properly cleaned up on exit (no matter
how,
except of course via a KILL signal).

Thanks,
Bas

--
I encourage people to send encrypted e-mail (see http://www.gnupg.org).
If you have problems reading my e-mail, use a better reader.
Please send the central message of e-mails as plain text
   in the message body, not as HTML and definitely not as MS Word.
Please do not use the MS Word format for attachments either.
For more information, see http://pcbcn10.phys.rug.nl/e-mail.html

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFORRmFShl+2J8z5URAnWRAJ9wA2xmpHRWHiucw8jTVE4jdwbbXQCfRCgr
N8EFZrXZfGZSg+j/JaIwm40=
=Ru7f
-----END PGP SIGNATURE-----


_______________________________________________
Debian-live-devel mailing list
Debian-live-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/mailman/listinfo/debian-live-devel


--- /usr/share/make-live/scripts/13chroot.sh	2007-03-04 14:55:40.000000000 +0200
+++ /home/hadar/dev/13chroot.sh	2007-03-04 15:24:04.000000000 +0200
@@ -9,10 +9,8 @@
 # This is free software, and you are welcome to redistribute it
 # under certain conditions; see COPYING for details.
 
-Chroot ()
+Preconfigrure()
 {
-	if [ ! -f "${LIVE_ROOT}"/.stage/chroot ]
-	then
 		# Configure chroot
 		lh_patchchroot apply
 		lh_patchrunlevel apply
@@ -27,6 +25,9 @@
 		lh_setupapt custom initial
 		lh_configapt apply-proxy
 		lh_configapt apply-recommends
+}
+Install()
+{
 
 		# Install aptitude
 		lh_installapt
@@ -59,26 +60,46 @@
 
 		lh_manifest
 
-		lh_cleanapt
 
-		# Workaround binfmt-support /proc locking
-		umount "${LIVE_CHROOT}"/proc/sys/fs/binfmt_misc > /dev/null || true
+}
+Clean()
+{
+	lh_cleanapt
+
+	# Workaround binfmt-support /proc locking
+	umount "${LIVE_CHROOT}"/proc/sys/fs/binfmt_misc > /dev/null || true
 
-		# Unmount proc
-		umount "${LIVE_CHROOT}"/proc
+	# Unmount proc
+	umount "${LIVE_CHROOT}"/proc
 
-		# Deconfigure network
-		lh_patchnetwork deapply
+	# Deconfigure network
+	lh_patchnetwork deapply
 
-		# Deconfigure chroot
-		lh_patchrunlevel deapply
-		lh_patchchroot deapply
+	# Deconfigure chroot
+	lh_patchrunlevel deapply
+	lh_patchchroot deapply
+}
 
-		# Touching stage file
-		touch "${LIVE_ROOT}"/.stage/chroot
-	fi
 
-	# Check depends
+Chroot ()
+{
+	if [ ! -f "${LIVE_ROOT}"/.stage/chroot ]
+	then
+		#make sure to clean up even when things fails
+		trap Clean EXIT
+		
+		Preconfigrure
+		Install
+		Clean
+		
+		#untrap
+		trap "" EXIT
+	fi
+	
+	# Touching stage file
+	touch "${LIVE_ROOT}"/.stage/chroot
+	
+		# Check depends
 	if [ "`grep dosfstools ${LIVE_ROOT}/packages.txt`" ]
 	then
 		KEEP_DOSFSTOOLS="true"
@@ -103,4 +124,5 @@
 	then
 		KEEP_SYSLINUX="true"
 	fi
+	
 }

Reply via email to