kconfig: add -e and -u options to *conf-cfg.sh scripts
PATCH 1/2 kconfig: add -e and -u options to *conf-cfg.sh scripts
Set -e to make these scripts fail on the first error.
Set -u because these scripts are invoked by Makefile, and do not work properly without necessary variables defined.
Both options are described in POSIX. [1]
[1]: https://pubs.opengroup.org/onlinepubs/009604499/utilities/set.html
---
scripts/kconfig/gconf-cfg.sh | 2 ++ scripts/kconfig/mconf-cfg.sh | 2 ++ scripts/kconfig/nconf-cfg.sh | 2 ++ scripts/kconfig/qconf-cfg.sh | 2 ++ 4 files changed, 8 insertions(+)
scripts/kconfig/gconf-cfg.sh +2 -0
@@ -1,6 +1,8 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 +set -eu + cflags=$1 libs=$2
scripts/kconfig/mconf-cfg.sh +2 -0
@@ -1,6 +1,8 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 +set -eu + cflags=$1 libs=$2
scripts/kconfig/nconf-cfg.sh +2 -0
@@ -1,6 +1,8 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 +set -eu + cflags=$1 libs=$2
scripts/kconfig/qconf-cfg.sh +2 -0
@@ -1,6 +1,8 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 +set -eu + cflags=$1 libs=$2 bin=$3
Signature · 1 line
2.43.0
PATCH 2/2 kbuild: package: add -e and -u options to shell scripts
Set -e to make these scripts fail on the first error.
Set -u because these scripts are invoked by Makefile, and do not work properly without necessary variables defined.
Remove the explicit "test -n ..." from scripts/package/install-extmod-build.
Both options are described in POSIX. [1]
[1]: https://pubs.opengroup.org/onlinepubs/009604499/utilities/set.html
---
scripts/package/builddeb | 2 +- scripts/package/buildtar | 2 +- scripts/package/gen-diff-patch | 2 ++ scripts/package/install-extmod-build | 5 +---- scripts/package/mkdebian | 2 +- scripts/package/mkspec | 2 ++ 6 files changed, 8 insertions(+), 7 deletions(-)
scripts/package/builddeb +1 -1
@@ -10,7 +10,7 @@ # specified in KDEB_HOOKDIR) that will be called on package install and # removal. -set -e +set -eu is_enabled() { grep -q "^$1=y" include/config/auto.conf
scripts/package/buildtar +1 -1
@@ -11,7 +11,7 @@ # Wichert Akkerman <[email protected]>. # -set -e +set -eu # # Some variables and settings used throughout the script
scripts/package/gen-diff-patch +2 -0
@@ -1,6 +1,8 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-only +set -eu + diff_patch=$1 mkdir -p "$(dirname "${diff_patch}")"
scripts/package/install-extmod-build +1 -4
@@ -1,13 +1,10 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0-only -set -e +set -eu destdir=${1} -test -n "${srctree}" -test -n "${SRCARCH}" - is_enabled() { grep -q "^$1=y" include/config/auto.conf }
scripts/package/mkdebian +1 -1
@@ -4,7 +4,7 @@ # # Simple script to generate a debian/ directory for a Linux kernel. -set -e +set -eu is_enabled() { grep -q "^$1=y" include/config/auto.conf
scripts/package/mkspec +2 -0
@@ -9,6 +9,8 @@ # Patched for non-x86 by Opencon (L) 2002 <[email protected]> # +set -eu + output=$1 mkdir -p "$(dirname "${output}")"
Signature · 1 line
2.43.0
Re: [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
Quoted 5 lines · Masahiro Yamada
Set -e to make these scripts fail on the first error.
Set -u because these scripts are invoked by
Makefile, and do not work properly without necessary variables defined.
Quoted 8 lines
Remove the explicit "test -n ..." from
scripts/package/install-extmod-build.Both options are described in POSIX. [1]
[1]: https://pubs.opengroup.org/onlinepubs/009604499/utilities/set.html
Signed-off-by Masahiro Yamada <[email protected]>---
Re: [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
In reply to Masahiro YamadaQuoted 6 lines · Masahiro Yamada
Set -e to make these scripts fail on the first error.
Set -u because these scripts are invoked by
Makefile, and do not work properly without necessary variables defined.
Quoted 8 lines
Remove the explicit "test -n ..." from
scripts/package/install-extmod-build.Both options are described in POSIX. [1]
[1]: https://pubs.opengroup.org/onlinepubs/009604499/utilities/set.html
Signed-off-by Masahiro Yamada <[email protected]>---
Setting -u needs more careful review and test.
This patch will break 'make deb-pkg'.
./scripts/package/mkdebian: 150: KDEB_PKGVERSION: parameter not set
To set -u, scripts/package/mkdebian needs code refactoring.
I will keep scripts/package/mkdebian untouched.
Signature · 2 lines
Best Regards Masahiro Yamada
Re: [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
Quoted 29 lines · Masahiro Yamada
Quoted 6 lines · Masahiro Yamada
Set -e to make these scripts fail on the first error.
Set -u because these scripts are invoked by
Makefile, and do not work properly without necessary variables defined.Quoted 8 lines
Remove the explicit "test -n ..." from
scripts/package/install-extmod-build.Both options are described in POSIX. [1]
[1]: https://pubs.opengroup.org/onlinepubs/009604499/utilities/set.html
Signed-off-by Masahiro Yamada <[email protected]>---
Setting -u needs more careful review and test.
This patch will break 'make deb-pkg'.
./scripts/package/mkdebian: 150:KDEB_PKGVERSION: parameter not set
Quoted 5 lines
To set -u,
scripts/package/mkdebianneeds code refactoring.I will keep
scripts/package/mkdebianuntouched.
uh, I missed that during the review. Do you want to refactor mkdebian in large scale, or is an explicit fallback definition possibly acceptable for you?
scripts/package/mkdebian +12 -0
@@ -7,5 +7,17 @@ set -eu +# Optional user-specified environment variables + +# Set target Debian architecture (skip auto-detection) +: "${KBUILD_DEBARCH:=}" + +# Set target Debian distribution (skipping auto-detection) +: "${KDEB_CHANGELOG_DIST:=}" + +# Overwrite the automatically determined package version. +: ${KDEB_PKGVERSION:=} + + is_enabled() { grep -q "^$1=y" include/config/auto.conf }
Kind regards,
Nicolas
Re: [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
Quoted 54 lines · Nicolas Schier
Quoted 29 lines · Masahiro Yamada
Quoted 6 lines · Masahiro Yamada
Set -e to make these scripts fail on the first error.
Set -u because these scripts are invoked by
Makefile, and do not work properly without necessary variables defined.Quoted 8 lines
Remove the explicit "test -n ..." from
scripts/package/install-extmod-build.Both options are described in POSIX. [1]
[1]: https://pubs.opengroup.org/onlinepubs/009604499/utilities/set.html
Signed-off-by Masahiro Yamada <[email protected]>---
Setting -u needs more careful review and test.
This patch will break 'make deb-pkg'.
./scripts/package/mkdebian: 150:KDEB_PKGVERSION: parameter not setQuoted 5 lines
To set -u,
scripts/package/mkdebianneeds code refactoring.I will keep
scripts/package/mkdebianuntouched.uh, I missed that during the review. Do you want to refactor mkdebian in large scale, or is an explicit fallback definition possibly acceptable for you?
scripts/package/mkdebian +5
-0@@ -7,5 +7,17 @@ set -eu +# Optional user-specified environment variables + +# Set target Debian architecture (skip auto-detection) +: "${KBUILD_DEBARCH:=}" +
scripts/package/mkdebian line 23
Quoted 10 lines
scripts/package/mkdebian +7
-0+# Set target Debian distribution (skipping auto-detection) +: "${KDEB_CHANGELOG_DIST:=}" + +# Overwrite the automatically determined package version. +: ${KDEB_PKGVERSION:=} + + is_enabled() { grep -q "^$1=y" include/config/auto.conf }
It depends on the code.
I would fix
if [ -n "$KDEB_PKGVERSION" ]; then
to
if [ "${KDEB_PKGVERSION:+set}" = set ]; thenor
if [ "${KDEB_PKGVERSION:+set}" ]; then
--
Best Regards
Masahiro Yamada
Re: [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
Quoted 80 lines · On Mon, Jun 17, 2024 at 01:52:23AM +0900 Masahiro Yamada wrote:
Quoted 54 lines · Nicolas Schier
Quoted 29 lines · Masahiro Yamada
Quoted 6 lines · Masahiro Yamada
Set -e to make these scripts fail on the first error.
Set -u because these scripts are invoked by
Makefile, and do not work properly without necessary variables defined.Quoted 8 lines
Remove the explicit "test -n ..." from
scripts/package/install-extmod-build.Both options are described in POSIX. [1]
[1]: https://pubs.opengroup.org/onlinepubs/009604499/utilities/set.html
Signed-off-by Masahiro Yamada <[email protected]>---
Setting -u needs more careful review and test.
This patch will break 'make deb-pkg'.
./scripts/package/mkdebian: 150:KDEB_PKGVERSION: parameter not setQuoted 5 lines
To set -u,
scripts/package/mkdebianneeds code refactoring.I will keep
scripts/package/mkdebianuntouched.uh, I missed that during the review. Do you want to refactor mkdebian in large scale, or is an explicit fallback definition possibly acceptable for you?
scripts/package/mkdebian +5
-0@@ -7,5 +7,17 @@ set -eu +# Optional user-specified environment variables + +# Set target Debian architecture (skip auto-detection) +: "${KBUILD_DEBARCH:=}" +scripts/package/mkdebian line 23
Quoted 10 lines
scripts/package/mkdebian +7
-0+# Set target Debian distribution (skipping auto-detection) +: "${KDEB_CHANGELOG_DIST:=}" + +# Overwrite the automatically determined package version. +: ${KDEB_PKGVERSION:=} + + is_enabled() { grep -q "^$1=y" include/config/auto.conf }It depends on the code.
I would fix
if [ -n "$KDEB_PKGVERSION" ]; then
Quoted 6 lines
to
if [ "${KDEB_PKGVERSION:+set}" = set ]; thenor
if [ "${KDEB_PKGVERSION:+set}" ]; then
ah, yes that's probaly better than the default value assigments, Please ignore my patch.
Kind regards,
Nicolas
Quoted 11 lines · Masahiro Yamada
Set -e to make these scripts fail on the first error.
Set -u because these scripts are invoked by
Makefile, and do not work properly without necessary variables defined.Both options are described in POSIX. [1]
[1]: https://pubs.opengroup.org/onlinepubs/009604499/utilities/set.html
Signed-off-by Masahiro Yamada <[email protected]>---
Thanks, I think 'set -eu' is really a good thing. Would like to see it in even more scripts below scripts/.
Kind regards,
Nicolas