[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH v2] gen_build_files: Use C locale when calling sed on globbed files
From:       Khem Raj <raj.khem () gmail ! com>
Date:       2021-05-12 20:01:35
Message-ID: 20210512200135.2978484-1-raj.khem () gmail ! com
[Download RAW message or body]

When include/applets.h is re-generated

it generates code macros in include/applets.h e.g.

IF_XZCAT(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat))
...
IF_CHVT(APPLET_NOEXEC(chvt, chvt, BB_DIR_USR_BIN, BB_SUID_DROP, chvt))
...

sed is used to process source files like below to feed into this header
generation

sed -n 's@^//applet:@@p' "$srctree"/*/*.c "$srctree"/*/*/*.c

this means we let shell decide the order of .c files being fed into sed
tool, applets.h has code snippets thats generated out of code fragments
from these .c files and the order of the generated code depends on the
order of .c files being fed to sed and then piped to generate tool, even
though the generated code is logically same, it does result in re-odered
code in applets.h based on which shell was used during build on exact busybox
sources since sort order is different based on chosen locale and also default shell
being bash or dash

This sets the environment variable LC_ALL to the value C, which will
enforce bytewise sorting, irrespective of the shell

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
v2: Describe the change a bit more

 scripts/gen_build_files.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/gen_build_files.sh b/scripts/gen_build_files.sh
index 92de681ac..8b5b15a1b 100755
--- a/scripts/gen_build_files.sh
+++ b/scripts/gen_build_files.sh
@@ -4,6 +4,8 @@
 # but users complain that many sed implementations
 # are misinterpreting --.
 
+export LC_ALL=C
+
 test $# -ge 2 || { echo "Syntax: $0 SRCTREE OBJTREE"; exit 1; }
 
 # cd to objtree
-- 
2.31.1

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic