Re: [PATCH] kbuild: deb-dpkg: Check optional env variables before use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 25, 2024 at 9:46 PM Nicolas Schier <n.schier@xxxxxx> wrote:
>
> 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.


This patch is not enough for enabling -u.



email=${DEBEMAIL-$EMAIL}

causes an error.


$ unset DEBEMAIL; unset EMAIL; make deb-pkg
  GEN     debian
./scripts/package/mkdebian: 128: EMAIL: parameter not set




I can do this work myself.









>
> Suggested-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
> Signed-off-by: Nicolas Schier <n.schier@xxxxxx>
> ---
> 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@xxxxxxxxxx/
> ---
>  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
>


--
Best Regards
Masahiro Yamada





[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux