kbuild: factor out the common installation code into scripts/install.sh
Subsystems (12)
PATCH v2 1/1 kbuild: factor out the common installation code into scripts/install.sh
Many architectures have similar install.sh scripts.
The first half is really generic; 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 just copies the kernel image and System.map to the destination, but the code is slightly different.
This patch factors out the generic part into scripts/install.sh.
---
Changes in v2:
- Move the installkernel parameters to scripts/install.sh
Makefile | 3 ++- arch/arm/Makefile | 4 ++-- arch/arm/boot/install.sh | 21 ------------------ arch/arm64/Makefile | 6 ++---- arch/arm64/boot/install.sh | 21 ------------------ arch/ia64/Makefile | 3 ++- arch/ia64/install.sh | 10 --------- arch/m68k/Makefile | 3 ++- arch/m68k/install.sh | 22 ------------------- arch/nios2/Makefile | 3 +-- arch/nios2/boot/install.sh | 22 ------------------- arch/parisc/Makefile | 11 +++++----- arch/parisc/install.sh | 28 ------------------------ arch/powerpc/Makefile | 3 +-- arch/powerpc/boot/install.sh | 23 -------------------- arch/riscv/Makefile | 7 +++--- arch/riscv/boot/install.sh | 21 ------------------ arch/s390/Makefile | 3 +-- arch/s390/boot/install.sh | 6 ------ arch/sparc/Makefile | 3 +-- arch/sparc/boot/install.sh | 22 ------------------- arch/x86/Makefile | 3 +-- arch/x86/boot/install.sh | 22 ------------------- scripts/install.sh | 41 ++++++++++++++++++++++++++++++++++++ 24 files changed, 64 insertions(+), 247 deletions(-) mode change 100644 => 100755 arch/arm/boot/install.sh mode change 100644 => 100755 arch/arm64/boot/install.sh mode change 100644 => 100755 arch/ia64/install.sh mode change 100644 => 100755 arch/m68k/install.sh mode change 100644 => 100755 arch/nios2/boot/install.sh mode change 100644 => 100755 arch/parisc/install.sh mode change 100644 => 100755 arch/powerpc/boot/install.sh mode change 100644 => 100755 arch/riscv/boot/install.sh mode change 100644 => 100755 arch/s390/boot/install.sh mode change 100644 => 100755 arch/sparc/boot/install.sh mode change 100644 => 100755 arch/x86/boot/install.sh create mode 100755 scripts/install.sh
Makefile +2 -1
@@ -1298,7 +1298,8 @@ scripts_unifdef: scripts_basic # to this Makefile to build and install external modules. # Cancel sub_make_done so that options such as M=, V=, etc. are parsed. -install: sub_make_done := +quiet_cmd_install = INSTALL $(INSTALL_PATH) + cmd_install = unset sub_make_done; $(srctree)/scripts/install.sh # --------------------------------------------------------------------------- # Tools
arch/arm/Makefile +2 -2
@@ -318,9 +318,9 @@ $(BOOT_TARGETS): vmlinux $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@ @$(kecho) ' Kernel: $(boot)/$@ is ready' +$(INSTALL_TARGETS): KBUILD_IMAGE = $(boot)/$(patsubst %install,%Image,$@) $(INSTALL_TARGETS): - $(CONFIG_SHELL) $(srctree)/$(boot)/install.sh "$(KERNELRELEASE)" \ - $(boot)/$(patsubst %install,%Image,$@) System.map "$(INSTALL_PATH)" + $(call cmd,install) PHONY += vdso_install vdso_install:
arch/arm/boot/install.sh +0 -21
@@ -1,7 +1,5 @@ #!/bin/sh # -# arch/arm/boot/install.sh -# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details.
@@ -18,25 +16,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi if [ "$(basename $2)" = "zImage" ]; then # Compressed install
arch/arm64/Makefile +2 -4
@@ -162,11 +162,9 @@ Image: vmlinux Image.%: Image $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ -install: install-image := Image -zinstall: install-image := Image.gz +install: KBUILD_IMAGE := $(boot)/Image install zinstall: - $(CONFIG_SHELL) $(srctree)/$(boot)/install.sh $(KERNELRELEASE) \ - $(boot)/$(install-image) System.map "$(INSTALL_PATH)" + $(call cmd,install) PHONY += vdso_install vdso_install:
arch/arm64/boot/install.sh +0 -21
@@ -1,7 +1,5 @@ #!/bin/sh # -# arch/arm64/boot/install.sh -# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details.
@@ -18,25 +16,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi if [ "$(basename $2)" = "Image.gz" ]; then # Compressed install
arch/ia64/Makefile +2 -1
@@ -72,8 +72,9 @@ archheaders: CLEAN_FILES += vmlinux.gz +install: KBUILD_IMAGE := vmlinux.gz install: - sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)" + $(call cmd,install) define archhelp echo '* compressed - Build compressed kernel image'
arch/ia64/install.sh +0 -10
@@ -1,7 +1,5 @@ #!/bin/sh # -# arch/ia64/install.sh -# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details.
@@ -17,14 +15,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -# User may have a custom install script - -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi - -# Default install - same as make zlilo if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.old
arch/m68k/Makefile +2 -1
@@ -138,5 +138,6 @@ CLEAN_FILES += vmlinux.gz vmlinux.bz2 archheaders: $(Q)$(MAKE) $(build)=arch/m68k/kernel/syscalls all +install: KBUILD_IMAGE := vmlinux.gz install: - sh $(srctree)/arch/m68k/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)" + $(call cmd,install)
arch/m68k/install.sh +0 -22
@@ -15,28 +15,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script - -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi - -# Default install - same as make zlilo if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.old
arch/nios2/Makefile +1 -2
@@ -56,8 +56,7 @@ $(BOOT_TARGETS): vmlinux $(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ install: - sh $(srctree)/$(nios2-boot)/install.sh $(KERNELRELEASE) \ - $(KBUILD_IMAGE) System.map "$(INSTALL_PATH)" + $(call cmd,install) define archhelp echo '* vmImage - Kernel-only image for U-Boot ($(KBUILD_IMAGE))'
arch/nios2/boot/install.sh +0 -22
@@ -15,28 +15,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script - -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi - -# Default install - same as make zlilo if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.old
arch/parisc/Makefile +5 -6
@@ -184,12 +184,11 @@ vdso_install: $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso $@ $(if $(CONFIG_COMPAT_VDSO), \ $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 $@) -install: - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \ - $(KERNELRELEASE) vmlinux System.map "$(INSTALL_PATH)" -zinstall: - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \ - $(KERNELRELEASE) vmlinuz System.map "$(INSTALL_PATH)" + +install: KBUILD_IMAGE := vmlinux +zinstall: KBUILD_IMAGE := vmlinuz +install zinstall: + $(call cmd,install) CLEAN_FILES += lifimage MRPROPER_FILES += palo.conf
arch/parisc/install.sh +0 -28
@@ -1,7 +1,5 @@ #!/bin/sh # -# arch/parisc/install.sh, derived from arch/i386/boot/install.sh -# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details.
@@ -17,32 +15,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist - -verify "$2" -verify "$3" - -# User may have a custom install script - -if [ -n "${INSTALLKERNEL}" ]; then - if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi - if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi - if [ -x /usr/sbin/${INSTALLKERNEL} ]; then exec /usr/sbin/${INSTALLKERNEL} "$@"; fi -fi - -# Default install if [ "$(basename $2)" = "vmlinuz" ]; then # Compressed install
arch/powerpc/Makefile +1 -2
@@ -408,8 +408,7 @@ endef PHONY += install install: - sh -x $(srctree)/$(boot)/install.sh "$(KERNELRELEASE)" vmlinux \ - System.map "$(INSTALL_PATH)" + $(call cmd,install) ifeq ($(KBUILD_EXTMOD),) # We need to generate vdso-offsets.h before compiling certain files in kernel/.
arch/powerpc/boot/install.sh +0 -23
@@ -15,32 +15,9 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# -# Bail with error code if anything goes wrong set -e -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script - -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi - -# Default install - # this should work for both the pSeries zImage and the iSeries vmlinux.sm image_name=`basename $2`
arch/riscv/Makefile +3 -4
@@ -139,11 +139,10 @@ $(BOOT_TARGETS): vmlinux Image.%: Image $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ -install: install-image = Image -zinstall: install-image = Image.gz +install: KBUILD_IMAGE := $(boot)/Image +zinstall: KBUILD_IMAGE := $(boot)/Image.gz install zinstall: - $(CONFIG_SHELL) $(srctree)/$(boot)/install.sh $(KERNELRELEASE) \ - $(boot)/$(install-image) System.map "$(INSTALL_PATH)" + $(call cmd,install) PHONY += rv32_randconfig rv32_randconfig:
arch/riscv/boot/install.sh +0 -21
@@ -1,7 +1,5 @@ #!/bin/sh # -# arch/riscv/boot/install.sh -# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details.
@@ -18,25 +16,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi if [ "$(basename $2)" = "Image.gz" ]; then # Compressed install
arch/s390/Makefile +1 -2
@@ -128,8 +128,7 @@ all: bzImage KBUILD_IMAGE := $(boot)/bzImage install: - sh -x $(srctree)/$(boot)/install.sh $(KERNELRELEASE) $(KBUILD_IMAGE) \ - System.map "$(INSTALL_PATH)" + $(call cmd,install) bzImage: vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
arch/s390/boot/install.sh +0 -6
@@ -14,12 +14,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -# User may have a custom install script - -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi echo "Warning: '${INSTALLKERNEL}' command not available - additional " \ "bootloader config required" >&2
arch/sparc/Makefile +1 -2
@@ -72,8 +72,7 @@ image zImage uImage tftpboot.img vmlinux.aout: vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ install: - sh $(srctree)/$(boot)/install.sh $(KERNELRELEASE) $(KBUILD_IMAGE) \ - System.map "$(INSTALL_PATH)" + $(call cmd,install) archheaders: $(Q)$(MAKE) $(build)=arch/sparc/kernel/syscalls all
arch/sparc/boot/install.sh +0 -22
@@ -15,28 +15,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script - -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi - -# Default install - same as make zlilo if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.old
arch/x86/Makefile +1 -2
@@ -271,8 +271,7 @@ $(BOOT_TARGETS): vmlinux PHONY += install install: - $(CONFIG_SHELL) $(srctree)/$(boot)/install.sh $(KERNELRELEASE) \ - $(KBUILD_IMAGE) System.map "$(INSTALL_PATH)" + $(call cmd,install) PHONY += vdso_install vdso_install:
arch/x86/boot/install.sh +0 -22
@@ -15,28 +15,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script - -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi - -# Default install - same as make zlilo if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.old
scripts/install.sh new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.32.0
Quoted 60 lines · On Tue, 3 May 2022 11:47 +0900 Masahiro Yamada wrote:
Many architectures have similar
install.shscripts.The first half is really generic; 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 just copies the kernel image and System.map to the destination, but the code is slightly different.
This patch factors out the generic part into
scripts/install.sh.Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v2:
- Move the installkernel parameters toscripts/install.shMakefile | 3 ++- arch/arm/Makefile | 4 ++-- arch/arm/boot/install.sh | 21 ------------------ arch/arm64/Makefile | 6 ++---- arch/arm64/boot/install.sh | 21 ------------------ arch/ia64/Makefile | 3 ++- arch/ia64/install.sh | 10 --------- arch/m68k/Makefile | 3 ++- arch/m68k/install.sh | 22 ------------------- arch/nios2/Makefile | 3 +-- arch/nios2/boot/install.sh | 22 ------------------- arch/parisc/Makefile | 11 +++++----- arch/parisc/install.sh | 28 ------------------------ arch/powerpc/Makefile | 3 +-- arch/powerpc/boot/install.sh | 23 -------------------- arch/riscv/Makefile | 7 +++--- arch/riscv/boot/install.sh | 21 ------------------ arch/s390/Makefile | 3 +-- arch/s390/boot/install.sh | 6 ------ arch/sparc/Makefile | 3 +-- arch/sparc/boot/install.sh | 22 ------------------- arch/x86/Makefile | 3 +-- arch/x86/boot/install.sh | 22 ------------------- scripts/install.sh | 41 ++++++++++++++++++++++++++++++++++++ 24 files changed, 64 insertions(+), 247 deletions(-) mode change 100644 => 100755 arch/arm/boot/install.sh mode change 100644 => 100755 arch/arm64/boot/install.sh mode change 100644 => 100755 arch/ia64/install.sh mode change 100644 => 100755 arch/m68k/install.sh mode change 100644 => 100755 arch/nios2/boot/install.sh mode change 100644 => 100755 arch/parisc/install.sh mode change 100644 => 100755 arch/powerpc/boot/install.sh mode change 100644 => 100755 arch/riscv/boot/install.sh mode change 100644 => 100755 arch/s390/boot/install.sh mode change 100644 => 100755 arch/sparc/boot/install.sh mode change 100644 => 100755 arch/x86/boot/install.sh create mode 100755 scripts/install.shMakefile +0
-0
Makefile scripts_unifdef: scripts_basic · line 1302
Quoted 6 lines
Makefile +2
-1@@ -1298,7 +1298,8 @@ scripts_unifdef: scripts_basic # to this Makefile to build and install external modules. # Cancel sub_make_done so that options such as M=, V=, etc. are parsed. -install: sub_make_done := +quiet_cmd_install = INSTALL $(INSTALL_PATH) + cmd_install = unset sub_make_done; $(srctree)/scripts/install.sh
This is the third 'cmd_install' in the tree; might it be better to take a more unique name (e.g. cmd_installkernel) to prevent confusion?
Quoted 64 lines
Makefile +0
-0# --------------------------------------------------------------------------- # Toolsarch/arm/Makefile +2
-2@@ -318,9 +318,9 @@ $(BOOT_TARGETS): vmlinux $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@ @$(kecho) ' Kernel: $(boot)/$@ is ready' +$(INSTALL_TARGETS): KBUILD_IMAGE = $(boot)/$(patsubst %install,%Image,$@) $(INSTALL_TARGETS): - $(CONFIG_SHELL) $(srctree)/$(boot)/install.sh "$(KERNELRELEASE)" \ - $(boot)/$(patsubst %install,%Image,$@) System.map "$(INSTALL_PATH)" + $(call cmd,install) PHONY += vdso_install vdso_install:arch/arm/boot/install.sh +0
-21@@ -1,7 +1,5 @@ #!/bin/sh # -# arch/arm/boot/install.sh -# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details.@@ -18,25 +16,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi if [ "$(basename $2)" = "zImage" ]; then # Compressed installarch/arm64/Makefile +0
-0
arch/arm64/Makefile Image: vmlinux · line 165
Quoted 6 lines
arch/arm64/Makefile +1
-2@@ -162,11 +162,9 @@ Image: vmlinux Image.%: Image $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ -install: install-image := Image -zinstall: install-image := Image.gz +install: KBUILD_IMAGE := $(boot)/Image
For me, it would have been more clear, if we'd also move the default KBUILD_IMAGE definition here (similar to the corresponding part in arch/parisc/Makefile):
zinstall: KBUILD_IMAGE := $(boot)/Image.gz
($(KBUILD_IMAGE) seems not to be used anywhere else in arch/arm64/ tree; but I haven't checked in depth.)
Quoted 194 lines
arch/arm64/Makefile +1
-2install zinstall: - $(CONFIG_SHELL) $(srctree)/$(boot)/install.sh $(KERNELRELEASE) \ - $(boot)/$(install-image) System.map "$(INSTALL_PATH)" + $(call cmd,install) PHONY += vdso_install vdso_install:arch/arm64/boot/install.sh +0
-21@@ -1,7 +1,5 @@ #!/bin/sh # -# arch/arm64/boot/install.sh -# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details.@@ -18,25 +16,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi if [ "$(basename $2)" = "Image.gz" ]; then # Compressed installarch/ia64/Makefile +2
-1@@ -72,8 +72,9 @@ archheaders: CLEAN_FILES += vmlinux.gz +install: KBUILD_IMAGE := vmlinux.gz install: - sh $(srctree)/arch/ia64/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)" + $(call cmd,install) define archhelp echo '* compressed - Build compressed kernel image'arch/ia64/install.sh +0
-10@@ -1,7 +1,5 @@ #!/bin/sh # -# arch/ia64/install.sh -# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details.@@ -17,14 +15,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -# User may have a custom install script - -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi - -# Default install - same as make zlilo if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.oldarch/m68k/Makefile +2
-1@@ -138,5 +138,6 @@ CLEAN_FILES += vmlinux.gz vmlinux.bz2 archheaders: $(Q)$(MAKE) $(build)=arch/m68k/kernel/syscalls all +install: KBUILD_IMAGE := vmlinux.gz install: - sh $(srctree)/arch/m68k/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)" + $(call cmd,install)arch/m68k/install.sh +0
-22@@ -15,28 +15,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script - -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi - -# Default install - same as make zlilo if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.oldarch/nios2/Makefile +1
-2@@ -56,8 +56,7 @@ $(BOOT_TARGETS): vmlinux $(Q)$(MAKE) $(build)=$(nios2-boot) $(nios2-boot)/$@ install: - sh $(srctree)/$(nios2-boot)/install.sh $(KERNELRELEASE) \ - $(KBUILD_IMAGE) System.map "$(INSTALL_PATH)" + $(call cmd,install) define archhelp echo '* vmImage - Kernel-only image for U-Boot ($(KBUILD_IMAGE))'arch/nios2/boot/install.sh +0
-22@@ -15,28 +15,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist -verify "$2" -verify "$3" - -# User may have a custom install script - -if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi -if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi - -# Default install - same as make zlilo if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.oldarch/parisc/Makefile +0
-0@@ -184,12 +184,11 @@ vdso_install: $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso $@ $(if $(CONFIG_COMPAT_VDSO), \
arch/parisc/Makefile vdso_install: · line 189
Quoted 10 lines
arch/parisc/Makefile +3
-6$(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 $@) -install: - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \ - $(KERNELRELEASE) vmlinux System.map "$(INSTALL_PATH)" -zinstall: - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \ - $(KERNELRELEASE) vmlinuz System.map "$(INSTALL_PATH)" + +install: KBUILD_IMAGE := vmlinux +zinstall: KBUILD_IMAGE := vmlinuz
Does this make the KBUILD_IMAGE definition in line 19 obsolete and unused?
Quoted 57 lines
arch/parisc/Makefile +2
-0+install zinstall: + $(call cmd,install) CLEAN_FILES += lifimage MRPROPER_FILES += palo.confarch/parisc/install.sh +0
-28@@ -1,7 +1,5 @@ #!/bin/sh # -# arch/parisc/install.sh, derived from arch/i386/boot/install.sh -# # This file is subject to the terms and conditions of the GNU General Public # License. See the file "COPYING" in the main directory of this archive # for more details.@@ -17,32 +15,6 @@ # $2 - kernel image file # $3 - kernel map file # $4 - default install path (blank if root directory) -# - -verify () { - if [ ! -f "$1" ]; then - echo "" 1>&2 - echo " *** Missing file: $1" 1>&2 - echo ' *** You need to run "make" before "make install".' 1>&2 - echo "" 1>&2 - exit 1 - fi -} - -# Make sure the files actually exist - -verify "$2" -verify "$3" - -# User may have a custom install script - -if [ -n "${INSTALLKERNEL}" ]; then - if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi - if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi - if [ -x /usr/sbin/${INSTALLKERNEL} ]; then exec /usr/sbin/${INSTALLKERNEL} "$@"; fi -fi - -# Default install if [ "$(basename $2)" = "vmlinuz" ]; then # Compressed installarch/powerpc/Makefile +0
-0
arch/powerpc/Makefile endef · line 410
Quoted 3 lines
arch/powerpc/Makefile +0
-0@@ -408,8 +408,7 @@ endef PHONY += install install:
I can't find a KBUILD_IMAGE definition in arch/powerpc/Makefile. Should it be set here as a target-specific varibable, too?
Kind regards,
Nicolas
Quoted 65 lines · Nicolas Schier
Quoted 63 lines · On Tue, 3 May 2022 11:47 +0900 Masahiro Yamada wrote:
Many architectures have similar
install.shscripts.The first half is really generic; 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 just copies the kernel image and System.map to the destination, but the code is slightly different.
This patch factors out the generic part into
scripts/install.sh.Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v2:
- Move the installkernel parameters toscripts/install.shMakefile | 3 ++- arch/arm/Makefile | 4 ++-- arch/arm/boot/install.sh | 21 ------------------ arch/arm64/Makefile | 6 ++---- arch/arm64/boot/install.sh | 21 ------------------ arch/ia64/Makefile | 3 ++- arch/ia64/install.sh | 10 --------- arch/m68k/Makefile | 3 ++- arch/m68k/install.sh | 22 ------------------- arch/nios2/Makefile | 3 +-- arch/nios2/boot/install.sh | 22 ------------------- arch/parisc/Makefile | 11 +++++----- arch/parisc/install.sh | 28 ------------------------ arch/powerpc/Makefile | 3 +-- arch/powerpc/boot/install.sh | 23 -------------------- arch/riscv/Makefile | 7 +++--- arch/riscv/boot/install.sh | 21 ------------------ arch/s390/Makefile | 3 +-- arch/s390/boot/install.sh | 6 ------ arch/sparc/Makefile | 3 +-- arch/sparc/boot/install.sh | 22 ------------------- arch/x86/Makefile | 3 +-- arch/x86/boot/install.sh | 22 ------------------- scripts/install.sh | 41 ++++++++++++++++++++++++++++++++++++ 24 files changed, 64 insertions(+), 247 deletions(-) mode change 100644 => 100755 arch/arm/boot/install.sh mode change 100644 => 100755 arch/arm64/boot/install.sh mode change 100644 => 100755 arch/ia64/install.sh mode change 100644 => 100755 arch/m68k/install.sh mode change 100644 => 100755 arch/nios2/boot/install.sh mode change 100644 => 100755 arch/parisc/install.sh mode change 100644 => 100755 arch/powerpc/boot/install.sh mode change 100644 => 100755 arch/riscv/boot/install.sh mode change 100644 => 100755 arch/s390/boot/install.sh mode change 100644 => 100755 arch/sparc/boot/install.sh mode change 100644 => 100755 arch/x86/boot/install.sh create mode 100755 scripts/install.shMakefile +0
-0@@ -1298,7 +1298,8 @@ scripts_unifdef: scripts_basic # to this Makefile to build and install external modules. # Cancel sub_make_done so that options such as M=, V=, etc. are parsed.
Quoted 6 lines
Makefile scripts_unifdef: scripts_basic · line 1302
Quoted 3 lines
Makefile +2
-1-install: sub_make_done := +quiet_cmd_install = INSTALL $(INSTALL_PATH) + cmd_install = unset sub_make_done; $(srctree)/scripts/install.shThis is the third '
cmd_install' in the tree; might it be better to take a more unique name (e.g.cmd_installkernel) to prevent confusion?
If this is confusing, we can rename the ones inscripts/Makefile.{modinst,headersinst}.
This command name matches the build target ("make install"), so I believe this name is good.
Quoted 9 lines
For me, it would have been more clear, if we'd also move the default
KBUILD_IMAGEdefinition here (similar to the corresponding part inarch/parisc/Makefile):zinstall:
KBUILD_IMAGE:= $(boot)/Image.gz($(KBUILD_IMAGE) seems not to be used anywhere else in
arch/arm64/tree; but I haven't checked in depth.)
KBUILD_IMAGE is _indirectly_ used to specify
the kernel image for package builds. [1]
This target returns the value IMAGE_BUILD. [2]
$(KBUILD_IMAGE) is definitely used for arm64.
[1]: https://github.com/torvalds/linux/blob/v5.17/scripts/package/builddeb#L150
[2]: https://github.com/torvalds/linux/blob/v5.17/Makefile#L1943
Quoted 12 lines
Quoted 12 lines
arch/parisc/Makefile +0
-4@@ -184,12 +184,11 @@ vdso_install: $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso $@ $(if $(CONFIG_COMPAT_VDSO), \ $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 $@) -install: - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \ - $(KERNELRELEASE) vmlinux System.map "$(INSTALL_PATH)" -zinstall:
Quoted 8 lines
arch/parisc/Makefile vdso_install: · line 189
Quoted 5 lines
arch/parisc/Makefile +3
-2- $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \ - $(KERNELRELEASE) vmlinuz System.map "$(INSTALL_PATH)" + +install: KBUILD_IMAGE := vmlinux +zinstall: KBUILD_IMAGE := vmlinuzDoes this make the
KBUILD_IMAGEdefinition in line 19 obsolete and unused?
As I said above for arm64, KBUILD_IMAGE is used for package builds.
If you delete line 19, it will change the behavior. (fall back to the global default [3])
[3]: https://github.com/torvalds/linux/blob/v5.17/Makefile#L1059
Quoted 11 lines
arch/powerpc/Makefile endef · line 410
Quoted 8 lines
arch/powerpc/Makefile +0
-0@@ -408,8 +408,7 @@ endef PHONY += install install:I can't find a
KBUILD_IMAGEdefinition inarch/powerpc/Makefile. Should it be set here as a target-specific varibable, too?
Right, powerpc does not define KBUILD_IMAGE explicitly. It falls back to [3].
Signature · 2 lines
Best Regards Masahiro Yamada
Nicolas Schier
Reviewed-byQuoted 156 lines · Masahiro Yamada
Quoted 65 lines · Nicolas Schier
Quoted 63 lines · On Tue, 3 May 2022 11:47 +0900 Masahiro Yamada wrote:
Many architectures have similar
install.shscripts.The first half is really generic; 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 just copies the kernel image and System.map to the destination, but the code is slightly different.
This patch factors out the generic part into
scripts/install.sh.Signed-off-by Masahiro Yamada <[email protected]>---
Changes in v2:
- Move the installkernel parameters toscripts/install.shMakefile | 3 ++- arch/arm/Makefile | 4 ++-- arch/arm/boot/install.sh | 21 ------------------ arch/arm64/Makefile | 6 ++---- arch/arm64/boot/install.sh | 21 ------------------ arch/ia64/Makefile | 3 ++- arch/ia64/install.sh | 10 --------- arch/m68k/Makefile | 3 ++- arch/m68k/install.sh | 22 ------------------- arch/nios2/Makefile | 3 +-- arch/nios2/boot/install.sh | 22 ------------------- arch/parisc/Makefile | 11 +++++----- arch/parisc/install.sh | 28 ------------------------ arch/powerpc/Makefile | 3 +-- arch/powerpc/boot/install.sh | 23 -------------------- arch/riscv/Makefile | 7 +++--- arch/riscv/boot/install.sh | 21 ------------------ arch/s390/Makefile | 3 +-- arch/s390/boot/install.sh | 6 ------ arch/sparc/Makefile | 3 +-- arch/sparc/boot/install.sh | 22 ------------------- arch/x86/Makefile | 3 +-- arch/x86/boot/install.sh | 22 ------------------- scripts/install.sh | 41 ++++++++++++++++++++++++++++++++++++ 24 files changed, 64 insertions(+), 247 deletions(-) mode change 100644 => 100755 arch/arm/boot/install.sh mode change 100644 => 100755 arch/arm64/boot/install.sh mode change 100644 => 100755 arch/ia64/install.sh mode change 100644 => 100755 arch/m68k/install.sh mode change 100644 => 100755 arch/nios2/boot/install.sh mode change 100644 => 100755 arch/parisc/install.sh mode change 100644 => 100755 arch/powerpc/boot/install.sh mode change 100644 => 100755 arch/riscv/boot/install.sh mode change 100644 => 100755 arch/s390/boot/install.sh mode change 100644 => 100755 arch/sparc/boot/install.sh mode change 100644 => 100755 arch/x86/boot/install.sh create mode 100755 scripts/install.shMakefile +0
-0@@ -1298,7 +1298,8 @@ scripts_unifdef: scripts_basic # to this Makefile to build and install external modules. # Cancel sub_make_done so that options such as M=, V=, etc. are parsed.Quoted 6 lines
Makefile scripts_unifdef: scripts_basic · line 1302
Quoted 3 lines
Makefile +2
-1-install: sub_make_done := +quiet_cmd_install = INSTALL $(INSTALL_PATH) + cmd_install = unset sub_make_done; $(srctree)/scripts/install.shThis is the third '
cmd_install' in the tree; might it be better to take a more unique name (e.g.cmd_installkernel) to prevent confusion?If this is confusing, we can rename the ones in
scripts/Makefile.{modinst,headersinst}.This command name matches the build target ("make install"), so I believe this name is good.
Quoted 9 lines
For me, it would have been more clear, if we'd also move the default
KBUILD_IMAGEdefinition here (similar to the corresponding part inarch/parisc/Makefile):zinstall:
KBUILD_IMAGE:= $(boot)/Image.gz($(KBUILD_IMAGE) seems not to be used anywhere else in
arch/arm64/tree; but I haven't checked in depth.)
KBUILD_IMAGEis _indirectly_ used to specify
the kernel image for package builds. [1]This target returns the value
IMAGE_BUILD. [2]$(KBUILD_IMAGE) is definitely used for arm64.
[1]: https://github.com/torvalds/linux/blob/v5.17/scripts/package/builddeb#L150
[2]: https://github.com/torvalds/linux/blob/v5.17/Makefile#L1943Quoted 12 lines
Quoted 12 lines
arch/parisc/Makefile +0
-4@@ -184,12 +184,11 @@ vdso_install: $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso $@ $(if $(CONFIG_COMPAT_VDSO), \ $(Q)$(MAKE) $(build)=arch/parisc/kernel/vdso32 $@) -install: - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \ - $(KERNELRELEASE) vmlinux System.map "$(INSTALL_PATH)" -zinstall:Quoted 8 lines
arch/parisc/Makefile vdso_install: · line 189
Quoted 5 lines
arch/parisc/Makefile +3
-2- $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \ - $(KERNELRELEASE) vmlinuz System.map "$(INSTALL_PATH)" + +install: KBUILD_IMAGE := vmlinux +zinstall: KBUILD_IMAGE := vmlinuzDoes this make the
KBUILD_IMAGEdefinition in line 19 obsolete and unused?As I said above for arm64,
KBUILD_IMAGEis used for package builds.If you delete line 19, it will change the behavior. (fall back to the global default [3])
[3]: https://github.com/torvalds/linux/blob/v5.17/Makefile#L1059
Quoted 11 lines
arch/powerpc/Makefile endef · line 410
Quoted 8 lines
arch/powerpc/Makefile +0
-0@@ -408,8 +408,7 @@ endef PHONY += install install:I can't find a
KBUILD_IMAGEdefinition inarch/powerpc/Makefile. Should it be set here as a target-specific varibable, too?
Quoted 3 lines
Right, powerpc does not define
KBUILD_IMAGEexplicitly. It falls back to [3].
Thanks for all those illuming clarifications, I have nothing more to ask.