[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240625-mkdebian-check-if-optional-vars-are-defined-v1-1-53f196b9f83a@avm.de>
Date: Tue, 25 Jun 2024 14:45:56 +0200
From: Nicolas Schier <n.schier@....de>
To: Masahiro Yamada <masahiroy@...nel.org>,
Nathan Chancellor <nathan@...nel.org>, Nicolas Schier <nicolas@...sle.eu>
Cc: linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
Nicolas Schier <n.schier@....de>
Subject: [PATCH] kbuild: deb-dpkg: Check optional env variables before use
Add checks to mkdebian for undefined optional environment variables
before evaluating them.
Some variables used by scripts/package/mkdebian are fully optional and
not set by kbuild. In order to allow enabling 'set -u' (shell script
exits on dereference of undefined variables), introduce the explicit
checking.
Suggested-by: Masahiro Yamada <masahiroy@...nel.org>
Signed-off-by: Nicolas Schier <n.schier@....de>
---
This allows application of the original patch
[PATCH 1/2] kconfig: add -e and -u options to *conf-cfg.sh scripts
[PATCH 2/2] kbuild: package: add -e and -u options to shell scripts
as sent https://lore.kernel.org/linux-kbuild/20240611160938.3511096-1-masahiroy@kernel.org/
---
scripts/package/mkdebian | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
index b9a5b789c655..2a7bb05c7f60 100755
--- a/scripts/package/mkdebian
+++ b/scripts/package/mkdebian
@@ -19,7 +19,7 @@ if_enabled_echo() {
}
set_debarch() {
- if [ -n "$KBUILD_DEBARCH" ] ; then
+ if [ "${KBUILD_DEBARCH:+set}" ] ; then
debarch="$KBUILD_DEBARCH"
return
fi
@@ -147,7 +147,7 @@ fi
# Some variables and settings used throughout the script
version=$KERNELRELEASE
-if [ -n "$KDEB_PKGVERSION" ]; then
+if [ "${KDEB_PKGVERSION:+set}" ]; then
packageversion=$KDEB_PKGVERSION
else
packageversion=$(${srctree}/scripts/setlocalversion --no-local ${srctree})-$($srctree/scripts/build-version)
@@ -164,7 +164,7 @@ debarch=
set_debarch
# Try to determine distribution
-if [ -n "$KDEB_CHANGELOG_DIST" ]; then
+if [ "${KDEB_CHANGELOG_DIST:+set}" ]; then
distribution=$KDEB_CHANGELOG_DIST
# In some cases lsb_release returns the codename as n/a, which breaks dpkg-parsechangelog
elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ] && [ "$distribution" != "n/a" ]; then
---
base-commit: 3893a22a160edd1c15b483deb3dee36b36ee4226
change-id: 20240625-mkdebian-check-if-optional-vars-are-defined-a46cf0524e4e
Best regards,
--
Nicolas Schier
Powered by blists - more mailing lists