From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Evgeni Dobrev <evgeni@studio-punkt.com>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH 1/1] fs: fix /tmp and /run clean-up in POSIX shells
Date: Wed, 26 Jan 2022 23:17:08 +0100 [thread overview]
Message-ID: <20220126221708.GK457876@scaer> (raw)
In-Reply-To: <20220124104116.12902-2-evgeni@studio-punkt.com>
Evgeni, All,
On 2022-01-24 11:41 +0100, Evgeni Dobrev via buildroot spake thusly:
> In POSIX sh, ^ in place of ! in glob bracket expressions
> is undefined.
>
> Signed-off-by: Evgeni Dobrev <evgeni@studio-punkt.com>
> ---
> fs/common.mk | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/common.mk b/fs/common.mk
> index 45beb5ae7b..64a94d9ad8 100644
> --- a/fs/common.mk
> +++ b/fs/common.mk
> @@ -186,7 +186,7 @@ $$(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 "rm -rf $$(TARGET_DIR)/run/* $$(TARGET_DIR)/run/.[!.]* $$(TARGET_DIR)/tmp/* $$(TARGET_DIR)/tmp/.[!.]*" >> $$(FAKEROOT_SCRIPT)
TIL that bracket expressions are actually valid and specified by POSIX.
But we do guarantee that we do have bash as a shell when running
Buildroot, so I think it is fair to also run the fs script with bash:
diff --git a/fs/common.mk b/fs/common.mk
index 45beb5ae7b..f8a6da6bc4 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -172,7 +172,7 @@ $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME): $$(ROOTFS_$(2)_DEPENDENCIES)
$$(BASE_TARGET_DIR)/ \
$$(TARGET_DIR)
- echo '#!/bin/sh' > $$(FAKEROOT_SCRIPT)
+ echo '#!$(SHELL)' > $$(FAKEROOT_SCRIPT)
echo "set -e" >> $$(FAKEROOT_SCRIPT)
echo "chown -h -R 0:0 $$(TARGET_DIR)" >> $$(FAKEROOT_SCRIPT)
However, $(SHELL) is not always correct, so we'd probably need:
diff --git a/Makefile b/Makefile
index 5fc7137e5a..bb9955f5b6 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@
# we want bash as shell
SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
- else echo sh; fi; fi)
+ else which sh; fi; fi)
# Set O variable if not already done on the command line;
# or avoid confusing packages that can use the O=<dir> syntax for out-of-tree
But in the end this is quite more changes than what you propose.
Can we also shorten the command?
echo "rm -rf $$(TARGET_DIR)/{run,tmp}/* $$(TARGET_DIR)/{run,tmp}/.[!.]*" >> $$(FAKEROOT_SCRIPT)
Regards,
Yann E. MORIN.
> $$(call PRINTF,$$(ROOTFS_REPRODUCIBLE)) >> $$(FAKEROOT_SCRIPT)
> $$(call PRINTF,$$(ROOTFS_SELINUX)) >> $$(FAKEROOT_SCRIPT)
> $$(call PRINTF,$$(ROOTFS_$(2)_CMD)) >> $$(FAKEROOT_SCRIPT)
> --
> 2.34.1
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2022-01-26 22:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 10:41 [Buildroot] [PATCH 0/1] fs: fix /tmp and /run clean-up in POSIX shells Evgeni Dobrev via buildroot
2022-01-24 10:41 ` [Buildroot] [PATCH 1/1] " Evgeni Dobrev via buildroot
2022-01-26 22:17 ` Yann E. MORIN [this message]
2022-01-27 10:34 ` Evgeni Dobrev via buildroot
2022-07-27 15:46 ` Yann E. MORIN
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220126221708.GK457876@scaer \
--to=yann.morin.1998@free.fr \
--cc=buildroot@buildroot.org \
--cc=evgeni@studio-punkt.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox