All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] fs/common.mk: use find instead of shell glob patterns
@ 2022-03-10 10:18 Mathieu Mirmont via buildroot
  2022-03-10 10:45 ` David Laight
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Mathieu Mirmont via buildroot @ 2022-03-10 10:18 UTC (permalink / raw)
  To: buildroot


[-- Attachment #1.1: Type: text/plain, Size: 1786 bytes --]

Different shells can have different behaviours when it comes to
globbing patterns. The dash shell (/bin/sh) on Debian testing switched
to a different fnmatch/glob implementation that results in this new
behaviour:

Using bash:
$ mkdir /tmp/foo
$ echo /tmp/foo/.[^.]*
/tmp/foo/.[^.]*

Using dash:
$ mkdir /tmp/foo
$ echo /tmp/foo/.[^.]*
/tmp/foo/..

The current FAKEROOT script uses this shell glob pattern which now
fails on recent Debian testing systems:

rm: refusing to remove '.' or '..' directory: skipping '/build/buildroot-fs/cpio/target/run/..'
rm: refusing to remove '.' or '..' directory: skipping '/build/buildroot-fs/cpio/target/tmp/..'

It seems safer to use `find | xargs rm` here instead of relying on
shell globbing patterns.

Signed-off-by: Mathieu Mirmont <mat@parad0x.org>
---
 fs/common.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/common.mk b/fs/common.mk
index 45beb5ae7b..37eafac4f7 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -186,7 +186,8 @@ $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES)
 
 	$$(foreach hook,$$(ROOTFS_$(2)_PRE_GEN_HOOKS),\
 		$$(call PRINTF,$$($$(hook))) >> $$(FAKEROOT_SCRIPT)$$(sep))
-	echo "rm -rf $$(TARGET_DIR)/run/* $$(TARGET_DIR)/run/.[^.]* $$(TARGET_DIR)/tmp/* $$(TARGET_DIR)/tmp/.[^.]*" >> $$(FAKEROOT_SCRIPT)
+	echo "find $$(TARGET_DIR)/run/ -mindepth 1 -prune -print0 | xargs -0r rm -rf --" >> $$(FAKEROOT_SCRIPT)
+	echo "find $$(TARGET_DIR)/tmp/ -mindepth 1 -prune -print0 | xargs -0r rm -rf --" >> $$(FAKEROOT_SCRIPT)
 	$$(call PRINTF,$$(ROOTFS_REPRODUCIBLE)) >> $$(FAKEROOT_SCRIPT)
 	$$(call PRINTF,$$(ROOTFS_SELINUX)) >> $$(FAKEROOT_SCRIPT)
 	$$(call PRINTF,$$(ROOTFS_$(2)_CMD)) >> $$(FAKEROOT_SCRIPT)
-- 
2.34.1


[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-03-19 19:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-10 10:18 [Buildroot] [PATCH 1/1] fs/common.mk: use find instead of shell glob patterns Mathieu Mirmont via buildroot
2022-03-10 10:45 ` David Laight
2022-03-10 11:33   ` Mat via buildroot
2022-03-10 11:52     ` David Laight
2022-03-10 12:11       ` Mathieu Mirmont via buildroot
2022-03-10 13:47         ` David Laight
2022-03-10 15:42           ` Mathieu Mirmont via buildroot
2022-03-10 11:22 ` Edgar Bonet
2022-03-10 11:31   ` David Laight
2022-03-10 12:02 ` [Buildroot] [PATCH v2] fs/common.mk: fix the globing pattern Mathieu Mirmont via buildroot
2022-03-12 16:19   ` Yann E. MORIN
2022-03-12 16:52 ` [Buildroot] [PATCH 1/1] fs/common.mk: use find instead of shell glob patterns Yann E. MORIN
2022-03-19 19:01 ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.