Skip to content

Commit f774f5b

Browse files
committed
kbuild: factor out the common installation code into scripts/install.sh
Many architectures have similar install.sh scripts. The first half is really generic; it verifies that the kernel image and System.map exist, then executes ~/bin/${INSTALLKERNEL} or /sbin/${INSTALLKERNEL} if available. The second half is kind of arch-specific; it copies the kernel image and System.map to the destination, but the code is slightly different. Factor out the generic part into scripts/install.sh. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <n.schier@avm.de>
1 parent f18379a commit f774f5b

24 files changed

Lines changed: 63 additions & 247 deletions

File tree

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,8 @@ scripts_unifdef: scripts_basic
12981298
# to this Makefile to build and install external modules.
12991299
# Cancel sub_make_done so that options such as M=, V=, etc. are parsed.
13001300

1301-
install: sub_make_done :=
1301+
quiet_cmd_install = INSTALL $(INSTALL_PATH)
1302+
cmd_install = unset sub_make_done; $(srctree)/scripts/install.sh
13021303

13031304
# ---------------------------------------------------------------------------
13041305
# Tools

arch/arm/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ $(BOOT_TARGETS): vmlinux
318318
$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@
319319
@$(kecho) ' Kernel: $(boot)/$@ is ready'
320320

321+
$(INSTALL_TARGETS): KBUILD_IMAGE = $(boot)/$(patsubst %install,%Image,$@)
321322
$(INSTALL_TARGETS):
322-
$(CONFIG_SHELL) $(srctree)/$(boot)/install.sh "$(KERNELRELEASE)" \
323-
$(boot)/$(patsubst %install,%Image,$@) System.map "$(INSTALL_PATH)"
323+
$(call cmd,install)
324324

325325
PHONY += vdso_install
326326
vdso_install:

arch/arm/boot/install.sh

100644100755
Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/sh
22
#
3-
# arch/arm/boot/install.sh
4-
#
53
# This file is subject to the terms and conditions of the GNU General Public
64
# License. See the file "COPYING" in the main directory of this archive
75
# for more details.
@@ -18,25 +16,6 @@
1816
# $2 - kernel image file
1917
# $3 - kernel map file
2018
# $4 - default install path (blank if root directory)
21-
#
22-
23-
verify () {
24-
if [ ! -f "$1" ]; then
25-
echo "" 1>&2
26-
echo " *** Missing file: $1" 1>&2
27-
echo ' *** You need to run "make" before "make install".' 1>&2
28-
echo "" 1>&2
29-
exit 1
30-
fi
31-
}
32-
33-
# Make sure the files actually exist
34-
verify "$2"
35-
verify "$3"
36-
37-
# User may have a custom install script
38-
if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
39-
if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
4019

4120
if [ "$(basename $2)" = "zImage" ]; then
4221
# Compressed install

arch/arm64/Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,9 @@ Image: vmlinux
162162
Image.%: Image
163163
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
164164

165-
install: install-image := Image
166-
zinstall: install-image := Image.gz
165+
install: KBUILD_IMAGE := $(boot)/Image
167166
install zinstall:
168-
$(CONFIG_SHELL) $(srctree)/$(boot)/install.sh $(KERNELRELEASE) \
169-
$(boot)/$(install-image) System.map "$(INSTALL_PATH)"
167+
$(call cmd,install)
170168

171169
PHONY += vdso_install
172170
vdso_install:

arch/arm64/boot/install.sh

100644100755
Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/sh
22
#
3-
# arch/arm64/boot/install.sh
4-
#
53
# This file is subject to the terms and conditions of the GNU General Public
64
# License. See the file "COPYING" in the main directory of this archive
75
# for more details.
@@ -18,25 +16,6 @@
1816
# $2 - kernel image file
1917
# $3 - kernel map file
2018
# $4 - default install path (blank if root directory)
21-
#
22-
23-
verify () {
24-
if [ ! -f "$1" ]; then
25-
echo "" 1>&2
26-
echo " *** Missing file: $1" 1>&2
27-
echo ' *** You need to run "make" before "make install".' 1>&2
28-
echo "" 1>&2
29-
exit 1
30-
fi
31-
}
32-
33-
# Make sure the files actually exist
34-
verify "$2"
35-
verify "$3"
36-
37-
# User may have a custom install script
38-
if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
39-
if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
4019

4120
if [ "$(basename $2)" = "Image.gz" ]; then
4221
# Compressed install

arch/ia64/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ archheaders:
7272

7373
CLEAN_FILES += vmlinux.gz
7474

75+
install: KBUILD_IMAGE := vmlinux.gz
7576
install:
76-
sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)"
77+
$(call cmd,install)
7778

7879
define archhelp
7980
echo '* compressed - Build compressed kernel image'

arch/ia64/install.sh

100644100755
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/sh
22
#
3-
# arch/ia64/install.sh
4-
#
53
# This file is subject to the terms and conditions of the GNU General Public
64
# License. See the file "COPYING" in the main directory of this archive
75
# for more details.
@@ -17,14 +15,6 @@
1715
# $2 - kernel image file
1816
# $3 - kernel map file
1917
# $4 - default install path (blank if root directory)
20-
#
21-
22-
# User may have a custom install script
23-
24-
if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
25-
if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
26-
27-
# Default install - same as make zlilo
2818

2919
if [ -f $4/vmlinuz ]; then
3020
mv $4/vmlinuz $4/vmlinuz.old

arch/m68k/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,6 @@ CLEAN_FILES += vmlinux.gz vmlinux.bz2
138138
archheaders:
139139
$(Q)$(MAKE) $(build)=arch/m68k/kernel/syscalls all
140140

141+
install: KBUILD_IMAGE := vmlinux.gz
141142
install:
142-
sh $(srctree)/arch/m68k/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)"
143+
$(call cmd,install)

arch/m68k/install.sh

100644100755
Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,6 @@
1515
# $2 - kernel image file
1616
# $3 - kernel map file
1717
# $4 - default install path (blank if root directory)
18-
#
19-
20-
verify () {
21-
if [ ! -f "$1" ]; then
22-
echo "" 1>&2
23-
echo " *** Missing file: $1" 1>&2
24-
echo ' *** You need to run "make" before "make install".' 1>&2
25-
echo "" 1>&2
26-
exit 1
27-
fi
28-
}
29-
30-
# Make sure the files actually exist
31-
verify "$2"
32-
verify "$3"
33-
34-
# User may have a custom install script
35-
36-
if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
37-
if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
38-
39-
# Default install - same as make zlilo
4018

4119
if [ -f $4/vmlinuz ]; then
4220
mv $4/vmlinuz $4/vmlinuz.old

arch/nios2/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ $(BOOT_TARGETS): vmlinux
5656
$(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@
5757

5858
install:
59-
sh $(srctree)/$(nios2-boot)/install.sh $(KERNELRELEASE) \
60-
$(KBUILD_IMAGE) System.map "$(INSTALL_PATH)"
59+
$(call cmd,install)
6160

6261
define archhelp
6362
echo '* vmImage - Kernel-only image for U-Boot ($(KBUILD_IMAGE))'

0 commit comments

Comments
 (0)