On Wednesday 24 October 2007, Otavio Salvador wrote:
> Maarten ter Huurne <[EMAIL PROTECTED]> writes:
> > It treats any whitespace in the exclusion file as a separator, which
> > means means it's impossible to exclude a file or directory that
> > contains a space in its name. I don't think any Debian package uses
> > spaces in file names, so I guess this is not a problem.
>
> To work around your problem you can use something like (untested):
>
> while read line
> do
>         ...
> done < EXCLUDE
>
> It should work fine.

The "while" construct indeed leaves the spaces in tact during iteration. 
However, when using the variable that contains a space, a lot of things can 
go wrong. I think I've found a reasonable solution now, it is in the 
attached patch. Please review it.

Bye,
                Maarten
--- lh_binary_chroot.org	2007-10-24 16:52:33.000000000 +0200
+++ lh_binary_chroot	2007-10-25 02:08:18.000000000 +0200
@@ -78,6 +78,21 @@
 ${LH_ROOT_COMMAND} cp -a chroot chroot.tmp
 ${LH_ROOT_COMMAND} mv chroot.tmp chroot/chroot
 
+if [ -f config/binary_rootfs/exclude ]
+then
+	while read EXCLUDE
+	do
+		if [ -e chroot/chroot/"${EXCLUDE}" ]
+		then
+			# Run "rm" inside the chroot so it cannot possibly remove host files.
+			# The "Chroot" function fails if ${EXCLUDE} contains a space, so use chroot directly.
+			chroot chroot /bin/rm -rf "chroot/${EXCLUDE}"
+		else
+			Echo_warning "Excluded path does not exist: ${EXCLUDE}"
+		fi
+	done < config/binary_rootfs/exclude
+fi
+
 if [ -n "${LH_ROOT_COMMAND}" ]
 then
 	${LH_ROOT_COMMAND} chown -R $(whoami):$(whoami) chroot

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
debian-live-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/debian-live-devel

Reply via email to