Skip to content

Commit 858805b

Browse files
committed
kbuild: add $(BASH) to run scripts with bash-extension
CONFIG_SHELL falls back to sh when bash is not installed on the system, but nobody is testing such a case since bash is usually installed. So, shell scripts invoked by CONFIG_SHELL are only tested with bash. It makes it difficult to test whether the hashbang #!/bin/sh is real. For example, #!/bin/sh in arch/powerpc/kernel/prom_init_check.sh is false. (I fixed it up) Besides, some shell scripts invoked by CONFIG_SHELL use bash-extension and #!/bin/bash is specified as the hashbang, while CONFIG_SHELL may not always be set to bash. Probably, the right thing to do is to introduce BASH, which is bash by default, and always set CONFIG_SHELL to sh. Replace $(CONFIG_SHELL) with $(BASH) for bash scripts. If somebody tries to add bash-extension to a #!/bin/sh script, it will be caught in testing because /bin/sh is a symlink to dash on some major distributions. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 8cc7af7 commit 858805b

File tree

6 files changed

+10
-11
lines changed

6 files changed

+10
-11
lines changed

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,7 @@ KCONFIG_CONFIG ?= .config
404404
export KCONFIG_CONFIG
405405

406406
# SHELL used by kbuild
407-
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
408-
else if [ -x /bin/bash ]; then echo /bin/bash; \
409-
else echo sh; fi ; fi)
407+
CONFIG_SHELL := sh
410408

411409
HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
412410
HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
@@ -443,6 +441,7 @@ PYTHON = python
443441
PYTHON2 = python2
444442
PYTHON3 = python3
445443
CHECK = sparse
444+
BASH = bash
446445

447446
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
448447
-Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
@@ -488,7 +487,7 @@ KBUILD_LDFLAGS :=
488487
GCC_PLUGINS_CFLAGS :=
489488
CLANG_FLAGS :=
490489

491-
export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
490+
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
492491
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK INSTALLKERNEL
493492
export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
494493
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
@@ -1687,7 +1686,7 @@ clean: $(clean-dirs)
16871686
# Generate tags for editors
16881687
# ---------------------------------------------------------------------------
16891688
quiet_cmd_tags = GEN $@
1690-
cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@
1689+
cmd_tags = $(BASH) $(srctree)/scripts/tags.sh $@
16911690

16921691
tags TAGS cscope gtags: FORCE
16931692
$(call cmd,tags)
@@ -1708,7 +1707,7 @@ versioncheck:
17081707
| xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
17091708

17101709
coccicheck:
1711-
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@
1710+
$(Q)$(BASH) $(srctree)/scripts/$@
17121711

17131712
namespacecheck:
17141713
$(PERL) $(srctree)/scripts/namespace.pl

arch/mips/boot/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ targets += vmlinux.lzo.itb
160160
quiet_cmd_itb-image = ITB $@
161161
cmd_itb-image = \
162162
env PATH="$(objtree)/scripts/dtc:$(PATH)" \
163-
$(CONFIG_SHELL) $(MKIMAGE) \
163+
$(BASH) $(MKIMAGE) \
164164
-D "-I dts -O dtb -p 500 \
165165
--include $(objtree)/arch/mips \
166166
--warning no-unit_address_vs_reg" \

arch/powerpc/Makefile.postlink

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ quiet_cmd_relocs_check = CHKREL $@
1818
ifdef CONFIG_PPC_BOOK3S_64
1919
cmd_relocs_check = \
2020
$(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$@" ; \
21-
$(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/unrel_branch_check.sh "$(OBJDUMP)" "$@"
21+
$(BASH) $(srctree)/arch/powerpc/tools/unrel_branch_check.sh "$(OBJDUMP)" "$@"
2222
else
2323
cmd_relocs_check = \
2424
$(CONFIG_SHELL) $(srctree)/arch/powerpc/tools/relocs_check.sh "$(OBJDUMP)" "$@"

arch/powerpc/kernel/prom_init_check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ OBJ="$2"
3333

3434
ERROR=0
3535

36-
function check_section()
36+
check_section()
3737
{
3838
file=$1
3939
section=$2

kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ $(obj)/config_data.gz: $(KCONFIG_CONFIG) FORCE
126126
$(obj)/kheaders.o: $(obj)/kheaders_data.tar.xz
127127

128128
quiet_cmd_genikh = CHK $(obj)/kheaders_data.tar.xz
129-
cmd_genikh = $(CONFIG_SHELL) $(srctree)/kernel/gen_kheaders.sh $@
129+
cmd_genikh = $(BASH) $(srctree)/kernel/gen_kheaders.sh $@
130130
$(obj)/kheaders_data.tar.xz: FORCE
131131
$(call cmd,genikh)
132132

scripts/Makefile.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR)
364364
UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)'
365365

366366
quiet_cmd_uimage = UIMAGE $@
367-
cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
367+
cmd_uimage = $(BASH) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \
368368
-C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \
369369
-T $(UIMAGE_TYPE) \
370370
-a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \

0 commit comments

Comments
 (0)