Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: package: add -e and -u options to some 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.

I tweaked mkdebian to cope with optional environment variables.

Remove the explicit "test -n ..." from 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>

+22 -13
+1 -1
scripts/package/builddeb
··· 10 10 # specified in KDEB_HOOKDIR) that will be called on package install and 11 11 # removal. 12 12 13 - set -e 13 + set -eu 14 14 15 15 is_enabled() { 16 16 grep -q "^$1=y" include/config/auto.conf
+1 -1
scripts/package/buildtar
··· 11 11 # Wichert Akkerman <wichert@wiggy.net>. 12 12 # 13 13 14 - set -e 14 + set -eu 15 15 16 16 # 17 17 # Some variables and settings used throughout the script
+2
scripts/package/gen-diff-patch
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0-only 3 3 4 + set -eu 5 + 4 6 diff_patch=$1 5 7 6 8 mkdir -p "$(dirname "${diff_patch}")"
+1 -4
scripts/package/install-extmod-build
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0-only 3 3 4 - set -e 4 + set -eu 5 5 6 6 destdir=${1} 7 - 8 - test -n "${srctree}" 9 - test -n "${SRCARCH}" 10 7 11 8 is_enabled() { 12 9 grep -q "^$1=y" include/config/auto.conf
+15 -7
scripts/package/mkdebian
··· 4 4 # 5 5 # Simple script to generate a debian/ directory for a Linux kernel. 6 6 7 - set -e 7 + set -eu 8 8 9 9 is_enabled() { 10 10 grep -q "^$1=y" include/config/auto.conf ··· 19 19 } 20 20 21 21 set_debarch() { 22 - if [ -n "$KBUILD_DEBARCH" ] ; then 22 + if [ "${KBUILD_DEBARCH:+set}" ]; then 23 23 debarch="$KBUILD_DEBARCH" 24 24 return 25 25 fi ··· 135 135 fi 136 136 maintainer="${name} <${email}>" 137 137 138 - if [ "$1" = --need-source ]; then 139 - gen_source 140 - fi 138 + while [ $# -gt 0 ]; do 139 + case "$1" in 140 + --need-source) 141 + gen_source 142 + shift 143 + ;; 144 + *) 145 + break 146 + ;; 147 + esac 148 + done 141 149 142 150 # Some variables and settings used throughout the script 143 151 version=$KERNELRELEASE 144 - if [ -n "$KDEB_PKGVERSION" ]; then 152 + if [ "${KDEB_PKGVERSION:+set}" ]; then 145 153 packageversion=$KDEB_PKGVERSION 146 154 else 147 155 packageversion=$(${srctree}/scripts/setlocalversion --no-local ${srctree})-$($srctree/scripts/build-version) ··· 166 158 set_debarch 167 159 168 160 # Try to determine distribution 169 - if [ -n "$KDEB_CHANGELOG_DIST" ]; then 161 + if [ "${KDEB_CHANGELOG_DIST:+set}" ]; then 170 162 distribution=$KDEB_CHANGELOG_DIST 171 163 # In some cases lsb_release returns the codename as n/a, which breaks dpkg-parsechangelog 172 164 elif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ] && [ "$distribution" != "n/a" ]; then
+2
scripts/package/mkspec
··· 9 9 # Patched for non-x86 by Opencon (L) 2002 <opencon@rio.skydome.net> 10 10 # 11 11 12 + set -eu 13 + 12 14 output=$1 13 15 14 16 mkdir -p "$(dirname "${output}")"