Skip to contentSkip to conversation

Makefile: Sort u-boot-initial-env output

PATCH In review Christoph Niedermaier 3 participants 3 messages Mar 1, 2022 – Apr 8, 2022 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Makefile: Sort u-boot-initial-env output

This will sort the default environment file generated by "make u-boot-initial-env", but won't sort the default environment in the compiled u-boot binary. The file u-boot-initial-env is considered to use for the userpace environment access tools [1] in case of that the environments is written the first time into its location. This is done on the one hand for a better overview and comparison of the generated environment file. On the other hand it is to synchronize the output with the script get_default_env.sh, which generated a sorted default environment file. The sorting preserves the order of equal variable names by sorting only the variable name, and disable the last-resort comparison. After sorting, unnoticed blank lines at the end move to the top. Avoid that by removing it before sorting.

[1] https://github.com/sbabic/libubootenv

To: [email protected]
---
V2: - More detailed description of the patch in the commit message
V3: - Add forgotten tags

---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -1
index e6fc80aa6f..603747c3cc 100644
@@ -2441,7 +2441,8 @@ endif
 
 quiet_cmd_genenv = GENENV  $@
 cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@ env/common.o; \
-	sed --in-place -e 's/\x00/\x0A/g' $@
+	sed --in-place -e 's/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' $@; \
+	sort --field-separator== -k1,1 --stable $@ -o $@
 
 u-boot-initial-env: u-boot.bin
 	$(call if_changed,genenv)
Signature · 1 line
2.11.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 25 lines · Christoph Niedermaier

This will sort the default environment file generated by "make u-boot-initial-env", but won't sort the default environment in the compiled u-boot binary. The file u-boot-initial-env is considered to use for the userpace environment access tools [1] in case of that the environments is written the first time into its location. This is done on the one hand for a better overview and comparison of the generated environment file. On the other hand it is to synchronize the output with the script get_default_env.sh, which generated a sorted default environment file. The sorting preserves the order of equal variable names by sorting only the variable name, and disable the last-resort comparison. After sorting, unnoticed blank lines at the end move to the top. Avoid that by removing it before sorting.

[1] https://github.com/sbabic/libubootenv

Quoted 7 lines

To: [email protected]
---
V2: - More detailed description of the patch in the commit message
V3: - Add forgotten tags

---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#2 lore raw
In reply to Christoph Niedermaier
Quoted 18 lines · Christoph Niedermaier

This will sort the default environment file generated by "make u-boot-initial-env", but won't sort the default environment in the compiled u-boot binary. The file u-boot-initial-env is considered to use for the userpace environment access tools [1] in case of that the environments is written the first time into its location. This is done on the one hand for a better overview and comparison of the generated environment file. On the other hand it is to synchronize the output with the script get_default_env.sh, which generated a sorted default environment file. The sorting preserves the order of equal variable names by sorting only the variable name, and disable the last-resort comparison. After sorting, unnoticed blank lines at the end move to the top. Avoid that by removing it before sorting.

[1] https://github.com/sbabic/libubootenv

Quoted 8 lines

To: [email protected]

Applied to u-boot/master, thanks!

Signature · 1 line
Tom