public inbox for development@lists.ipfire.org
 help / color / mirror / Atom feed
* [PATCH] Config: Don't interpret file names as regular expressions
@ 2024-12-07 11:50 Michael Tremer
  2024-12-07 13:04 ` Adolf Belka
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Tremer @ 2024-12-07 11:50 UTC (permalink / raw)
  To: development

[-- Attachment #1: Type: text/plain, Size: 1576 bytes --]

When we are searching for changes in rootfiles, we walk through each
file that we have found in the build and check if it exists in the
rootfile. That check interpreted filenames as regular expressions which
caused a problem in the case of "/usr/bin/[".

This patch changes that grep will only search for an exact string match
(-F) and the string must be the entire line (-x).

Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
---
 lfs/Config | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lfs/Config b/lfs/Config
index 1a59ebe1e..8547f69c6 100644
--- a/lfs/Config
+++ b/lfs/Config
@@ -292,13 +292,13 @@ define POSTBUILD
 		fi; \
 		sed -e "s/BUILDTARGET/$(BUILDTARGET)/g" -e "s/KVER/$(KVER)/g" -e "s/xxxMACHINExxx/$(BUILD_ARCH)/g" $$ROOTFILE > $(TARGET)_rootfile; \
 		while read -r line; do \
-			if grep -qG "^#$$line$$" $(TARGET)_rootfile; then echo "#$$line" >> $(TARGET); \
-			elif grep -qG "^$$line$$" $(TARGET)_rootfile ; then echo "$$line" >> $(TARGET); \
+			if grep -qFx "#$$line" $(TARGET)_rootfile; then echo "#$$line" >> $(TARGET); \
+			elif grep -qFx "$$line" $(TARGET)_rootfile ; then echo "$$line" >> $(TARGET); \
 			else echo "+$$line" >> $(TARGET); \
 			fi; \
 		done < $(TARGET)_diff; \
 		grep -v "^#" $(TARGET)_rootfile | while read -r line; do \
-			if ! grep -qG "^$$line$$" $(TARGET)_diff ; then echo "-$$line" >> $(TARGET); \
+			if ! grep -qFx "$$line" $(TARGET)_diff ; then echo "-$$line" >> $(TARGET); \
 			fi; \
 		done; \
 		rm -f $(TARGET)_rootfile; \
-- 
2.39.5


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

* Re: [PATCH] Config: Don't interpret file names as regular expressions
  2024-12-07 11:50 [PATCH] Config: Don't interpret file names as regular expressions Michael Tremer
@ 2024-12-07 13:04 ` Adolf Belka
  0 siblings, 0 replies; 2+ messages in thread
From: Adolf Belka @ 2024-12-07 13:04 UTC (permalink / raw)
  To: development

[-- Attachment #1: Type: text/plain, Size: 1737 bytes --]

Reviewed-by: Adolf Belka <adolf.belka(a)ipfire.org>

On 07/12/2024 12:50, Michael Tremer wrote:
> When we are searching for changes in rootfiles, we walk through each
> file that we have found in the build and check if it exists in the
> rootfile. That check interpreted filenames as regular expressions which
> caused a problem in the case of "/usr/bin/[".
>
> This patch changes that grep will only search for an exact string match
> (-F) and the string must be the entire line (-x).
>
> Signed-off-by: Michael Tremer <michael.tremer(a)ipfire.org>
> ---
>   lfs/Config | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lfs/Config b/lfs/Config
> index 1a59ebe1e..8547f69c6 100644
> --- a/lfs/Config
> +++ b/lfs/Config
> @@ -292,13 +292,13 @@ define POSTBUILD
>   		fi; \
>   		sed -e "s/BUILDTARGET/$(BUILDTARGET)/g" -e "s/KVER/$(KVER)/g" -e "s/xxxMACHINExxx/$(BUILD_ARCH)/g" $$ROOTFILE > $(TARGET)_rootfile; \
>   		while read -r line; do \
> -			if grep -qG "^#$$line$$" $(TARGET)_rootfile; then echo "#$$line" >> $(TARGET); \
> -			elif grep -qG "^$$line$$" $(TARGET)_rootfile ; then echo "$$line" >> $(TARGET); \
> +			if grep -qFx "#$$line" $(TARGET)_rootfile; then echo "#$$line" >> $(TARGET); \
> +			elif grep -qFx "$$line" $(TARGET)_rootfile ; then echo "$$line" >> $(TARGET); \
>   			else echo "+$$line" >> $(TARGET); \
>   			fi; \
>   		done < $(TARGET)_diff; \
>   		grep -v "^#" $(TARGET)_rootfile | while read -r line; do \
> -			if ! grep -qG "^$$line$$" $(TARGET)_diff ; then echo "-$$line" >> $(TARGET); \
> +			if ! grep -qFx "$$line" $(TARGET)_diff ; then echo "-$$line" >> $(TARGET); \
>   			fi; \
>   		done; \
>   		rm -f $(TARGET)_rootfile; \

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

end of thread, other threads:[~2024-12-07 13:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-07 11:50 [PATCH] Config: Don't interpret file names as regular expressions Michael Tremer
2024-12-07 13:04 ` Adolf Belka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox