scripts: setlocalversion: safely extract variables from auto.conf using awk
PATCH 1/1 scripts: setlocalversion: safely extract variables from auto.conf using awk
Moving SPL_LDSCRIPT to Kconfig triggered an unfortunate attempt of command substitution, as the sourced auto.conf may include $(ARCH) which tries to execute a command 'ARCH'.
This showed up as a warning similar to the following:
include/config/auto.conf: line 209: ARCH: command not found
This change does no longer attempt to source auto.conf, but rather passes it through awk to retrieve the values for CONFIG_LOCALVERSION and CONFIG_LOCALVERSION_AUTO. This will also mitigate the risk of unintended command substitution.
---
scripts/setlocalversion | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/setlocalversion +5 -1
@@ -141,7 +141,11 @@ if $scm_only; then fi if test -e include/config/auto.conf; then - . include/config/auto.conf + # We are interested only in CONFIG_LOCALVERSION and + # CONFIG_LOCALVERSION_AUTO, so extract these in a safe + # way (i.e. w/o sourcing auto.conf) + CONFIG_LOCALVERSION=`cat include/config/auto.conf | awk -F '=' '/^CONFIG_LOCALVERSION=/ {print $2}'` + CONFIG_LOCALVERSION_AUTO=`cat include/config/auto.conf | awk -F '=' '/^CONFIG_LOCALVERSION_AUTO=/ {print $2}'` else echo "Error: kernelrelease not valid - run 'make prepare' to update it" exit 1
Signature · 1 line
2.1.4
PATCH 1/1 scripts: setlocalversion: safely extract variables from auto.conf using awk
Quoted 6 lines · Philipp Tomsich
Moving
SPL_LDSCRIPTtoKconfigtriggered an unfortunate attempt of command substitution, as the sourced auto.conf may include $(ARCH) which tries to execute a command 'ARCH'.
This showed up as a warning similar to the following:
include/config/auto.conf: line 209: ARCH: command not found
Quoted 8 lines
This change does no longer attempt to source auto.conf, but rather passes it through awk to retrieve the values for
CONFIG_LOCALVERSIONandCONFIG_LOCALVERSION_AUTO. This will also mitigate the risk of unintended command substitution.Signed-off-by Philipp Tomsich <[email protected]>Reported-by Andy Yan <[email protected]>
I do wonder if we can get this into the kernel as well.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170809/aadf262c/attachment.sig>
Quoted 11 lines
Moving
SPL_LDSCRIPTtoKconfigtriggered an unfortunate attempt of command substitution, as the sourced auto.conf may include $(ARCH) which tries to execute a command 'ARCH'.
This showed up as a warning similar to the following:
include/config/auto.conf: line 209: ARCH: command not foundThis change does no longer attempt to source auto.conf, but rather passes it through awk to retrieve the values for
CONFIG_LOCALVERSIONandCONFIG_LOCALVERSION_AUTO. This will also mitigate the risk of unintended command substitution.
Quoted 8 lines
Signed-off-by Philipp Tomsich <[email protected]>Reported-by Andy Yan <[email protected]>Reviewed-by Tom Rini <[email protected]>---
scripts/setlocalversion | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Applied to u-boot-rockchip, thanks!