* [PATCH 1/2] kconfig: add -e and -u options to *conf-cfg.sh scripts
@ 2024-06-11 16:08 Masahiro Yamada
2024-06-11 16:08 ` [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts Masahiro Yamada
2024-06-12 19:28 ` [PATCH 1/2] kconfig: add -e and -u options to *conf-cfg.sh scripts Nicolas Schier
0 siblings, 2 replies; 8+ messages in thread
From: Masahiro Yamada @ 2024-06-11 16:08 UTC (permalink / raw)
To: linux-kbuild; +Cc: linux-kernel, 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 <masahiroy@kernel.org>
---
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(+)
diff --git a/scripts/kconfig/gconf-cfg.sh b/scripts/kconfig/gconf-cfg.sh
index 040d8f338820..fc954c0538fa 100755
--- a/scripts/kconfig/gconf-cfg.sh
+++ b/scripts/kconfig/gconf-cfg.sh
@@ -1,6 +1,8 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
+set -eu
+
cflags=$1
libs=$2
diff --git a/scripts/kconfig/mconf-cfg.sh b/scripts/kconfig/mconf-cfg.sh
index 1e61f50a5905..1bc304dc2f7d 100755
--- a/scripts/kconfig/mconf-cfg.sh
+++ b/scripts/kconfig/mconf-cfg.sh
@@ -1,6 +1,8 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
+set -eu
+
cflags=$1
libs=$2
diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh
index f871a2160e36..a20290b1a37d 100755
--- a/scripts/kconfig/nconf-cfg.sh
+++ b/scripts/kconfig/nconf-cfg.sh
@@ -1,6 +1,8 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
+set -eu
+
cflags=$1
libs=$2
diff --git a/scripts/kconfig/qconf-cfg.sh b/scripts/kconfig/qconf-cfg.sh
index 0e113b0f2455..bb2df66363a8 100755
--- a/scripts/kconfig/qconf-cfg.sh
+++ b/scripts/kconfig/qconf-cfg.sh
@@ -1,6 +1,8 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
+set -eu
+
cflags=$1
libs=$2
bin=$3
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
2024-06-11 16:08 [PATCH 1/2] kconfig: add -e and -u options to *conf-cfg.sh scripts Masahiro Yamada
@ 2024-06-11 16:08 ` Masahiro Yamada
2024-06-12 19:33 ` Nicolas Schier
2024-06-16 15:21 ` Masahiro Yamada
2024-06-12 19:28 ` [PATCH 1/2] kconfig: add -e and -u options to *conf-cfg.sh scripts Nicolas Schier
1 sibling, 2 replies; 8+ messages in thread
From: Masahiro Yamada @ 2024-06-11 16:08 UTC (permalink / raw)
To: linux-kbuild
Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor, Nicolas Schier
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
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
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(-)
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index e797ad360f7a..c1757db6aa8a 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -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
diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index eb67787f8673..cc87a473c01f 100755
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -11,7 +11,7 @@
# Wichert Akkerman <wichert@wiggy.net>.
#
-set -e
+set -eu
#
# Some variables and settings used throughout the script
diff --git a/scripts/package/gen-diff-patch b/scripts/package/gen-diff-patch
index 8a98b7bb78a0..f272f7770ea3 100755
--- a/scripts/package/gen-diff-patch
+++ b/scripts/package/gen-diff-patch
@@ -1,6 +1,8 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
+set -eu
+
diff_patch=$1
mkdir -p "$(dirname "${diff_patch}")"
diff --git a/scripts/package/install-extmod-build b/scripts/package/install-extmod-build
index 76e0765dfcd6..8cc9e13403ae 100755
--- a/scripts/package/install-extmod-build
+++ b/scripts/package/install-extmod-build
@@ -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
}
diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
index 070149c985fe..ecfeb34b99aa 100755
--- a/scripts/package/mkdebian
+++ b/scripts/package/mkdebian
@@ -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
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index ce201bfa8377..cc046ac74bf9 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -9,6 +9,8 @@
# Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net>
#
+set -eu
+
output=$1
mkdir -p "$(dirname "${output}")"
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] kconfig: add -e and -u options to *conf-cfg.sh scripts
2024-06-11 16:08 [PATCH 1/2] kconfig: add -e and -u options to *conf-cfg.sh scripts Masahiro Yamada
2024-06-11 16:08 ` [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts Masahiro Yamada
@ 2024-06-12 19:28 ` Nicolas Schier
1 sibling, 0 replies; 8+ messages in thread
From: Nicolas Schier @ 2024-06-12 19:28 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel
On Wed, Jun 12, 2024 at 01:08:05AM +0900, Masahiro Yamada wrote:
> 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 <masahiroy@kernel.org>
> ---
Thanks, I think 'set -eu' is really a good thing. Would like to see it
in even more scripts below scripts/.
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
Kind regards,
Nicolas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
2024-06-11 16:08 ` [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts Masahiro Yamada
@ 2024-06-12 19:33 ` Nicolas Schier
2024-06-16 15:21 ` Masahiro Yamada
1 sibling, 0 replies; 8+ messages in thread
From: Nicolas Schier @ 2024-06-12 19:33 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel, Nathan Chancellor
On Wed, Jun 12, 2024 at 01:08:06AM +0900, Masahiro Yamada wrote:
> 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
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
2024-06-11 16:08 ` [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts Masahiro Yamada
2024-06-12 19:33 ` Nicolas Schier
@ 2024-06-16 15:21 ` Masahiro Yamada
2024-06-16 15:55 ` Nicolas Schier
1 sibling, 1 reply; 8+ messages in thread
From: Masahiro Yamada @ 2024-06-16 15:21 UTC (permalink / raw)
To: linux-kbuild; +Cc: linux-kernel, Nathan Chancellor, Nicolas Schier
On Wed, Jun 12, 2024 at 1:09 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> 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
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
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.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
2024-06-16 15:21 ` Masahiro Yamada
@ 2024-06-16 15:55 ` Nicolas Schier
2024-06-16 16:52 ` Masahiro Yamada
0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Schier @ 2024-06-16 15:55 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel, Nathan Chancellor
[-- Attachment #1: Type: text/plain, Size: 1758 bytes --]
On Mon, Jun 17, 2024 at 12:21:15AM +0900, Masahiro Yamada wrote:
> On Wed, Jun 12, 2024 at 1:09 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > 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
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
>
>
>
> 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.
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?
diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
index ecfeb34b99aa..7e3878197041 100755
--- a/scripts/package/mkdebian
+++ b/scripts/package/mkdebian
@@ -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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
2024-06-16 15:55 ` Nicolas Schier
@ 2024-06-16 16:52 ` Masahiro Yamada
2024-06-16 18:40 ` Nicolas Schier
0 siblings, 1 reply; 8+ messages in thread
From: Masahiro Yamada @ 2024-06-16 16:52 UTC (permalink / raw)
To: Nicolas Schier; +Cc: linux-kbuild, linux-kernel, Nathan Chancellor
On Mon, Jun 17, 2024 at 12:56 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Mon, Jun 17, 2024 at 12:21:15AM +0900, Masahiro Yamada wrote:
> > On Wed, Jun 12, 2024 at 1:09 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > >
> > > 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
> > >
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > ---
> >
> >
> >
> > 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.
>
> 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?
>
> diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
> index ecfeb34b99aa..7e3878197041 100755
> --- a/scripts/package/mkdebian
> +++ b/scripts/package/mkdebian
> @@ -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
> }
>
It depends on the code.
I would fix
if [ -n "$KDEB_PKGVERSION" ]; then
to
if [ "${KDEB_PKGVERSION:+set}" = set ]; then
or
if [ "${KDEB_PKGVERSION:+set}" ]; then
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
2024-06-16 16:52 ` Masahiro Yamada
@ 2024-06-16 18:40 ` Nicolas Schier
0 siblings, 0 replies; 8+ messages in thread
From: Nicolas Schier @ 2024-06-16 18:40 UTC (permalink / raw)
To: Masahiro Yamada; +Cc: linux-kbuild, linux-kernel, Nathan Chancellor
On Mon, Jun 17, 2024 at 01:52:23AM +0900 Masahiro Yamada wrote:
> On Mon, Jun 17, 2024 at 12:56 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
> >
> > On Mon, Jun 17, 2024 at 12:21:15AM +0900, Masahiro Yamada wrote:
> > > On Wed, Jun 12, 2024 at 1:09 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > >
> > > > 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
> > > >
> > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > > ---
> > >
> > >
> > >
> > > 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.
> >
> > 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?
> >
> > diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
> > index ecfeb34b99aa..7e3878197041 100755
> > --- a/scripts/package/mkdebian
> > +++ b/scripts/package/mkdebian
> > @@ -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
> > }
> >
>
>
>
>
> It depends on the code.
>
>
>
>
> I would fix
>
>
> if [ -n "$KDEB_PKGVERSION" ]; then
>
>
> to
>
> if [ "${KDEB_PKGVERSION:+set}" = set ]; then
>
> or
> if [ "${KDEB_PKGVERSION:+set}" ]; then
ah, yes that's probaly better than the default value assigments, Please ignore
my patch.
Kind regards,
Nicolas
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-06-16 18:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-11 16:08 [PATCH 1/2] kconfig: add -e and -u options to *conf-cfg.sh scripts Masahiro Yamada
2024-06-11 16:08 ` [PATCH 2/2] kbuild: package: add -e and -u options to shell scripts Masahiro Yamada
2024-06-12 19:33 ` Nicolas Schier
2024-06-16 15:21 ` Masahiro Yamada
2024-06-16 15:55 ` Nicolas Schier
2024-06-16 16:52 ` Masahiro Yamada
2024-06-16 18:40 ` Nicolas Schier
2024-06-12 19:28 ` [PATCH 1/2] kconfig: add -e and -u options to *conf-cfg.sh scripts Nicolas Schier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox