2021-04-07 18:29:10

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 00/20] kbuild: unify the install.sh script usage

Almost every architecture has copied the "install.sh" script that
originally came with i386, and modified it in very tiny ways. This
patch series unifies all of these scripts into one single script to
allow people to understand how to correctly install a kernel, and fixes
up some issues regarding trying to install a kernel to a path with
spaces in it.

Note that not all architectures actually seem to have any type of way to
install a kernel, they must rely on external scripts or tools which
feels odd as everything should be included here in the main repository.
I'll work on trying to figure out the missing architecture issues
afterward.

Note the cc: list here is crazy, due to touching arch-specific code in a
number of different arches in the same patch series. I've cc:ed
individual arch maintainers on this 00/20 patch, and on their individual
arch-specific patch as well, but not the whole thing.

thanks,

greg k-h

Greg Kroah-Hartman (20):
kbuild: move x86 install script to scripts/install.sh
kbuild: scripts/install.sh: properly quote all variables
kbuild: scripts/install.sh: provide a "install" function
kbuild: scripts/install.sh: call sync before calling the bootloader
installer
kbuild: scripts/install.sh: prepare for arch-specific bootloaders
kbuild: scripts/install.sh: handle compressed/uncompressed kernel
images
kbuild: scripts/install.sh: allow for the version number
kbuild: riscv: use common install script
kbuild: arm64: use common install script
kbuild: arm: use common install script
kbuild: ia64: use common install script
kbuild: m68k: use common install script
kbuild: nds32: convert to use the common install scripts
kbuild: nios2: use common install script
kbuild: parisc: use common install script
kbuild: powerpc: use common install script
kbuild: s390: use common install script
kbuild: sh: remove unused install script
kbuild: sparc: use common install script
kbuild: scripts/install.sh: update documentation

arch/arm/boot/Makefile | 6 +-
arch/arm/boot/install.sh | 66 --------------
arch/arm64/boot/Makefile | 4 +-
arch/arm64/boot/install.sh | 60 -------------
arch/ia64/Makefile | 2 +-
arch/ia64/install.sh | 40 ---------
arch/m68k/Makefile | 2 +-
arch/m68k/install.sh | 52 -----------
arch/nds32/boot/Makefile | 4 +-
arch/nios2/boot/Makefile | 2 +-
arch/nios2/boot/install.sh | 52 -----------
arch/parisc/Makefile | 4 +-
arch/parisc/boot/Makefile | 2 +-
arch/parisc/boot/install.sh | 65 --------------
arch/parisc/install.sh | 66 --------------
arch/powerpc/boot/Makefile | 4 +-
arch/powerpc/boot/install.sh | 55 ------------
arch/riscv/boot/Makefile | 4 +-
arch/riscv/boot/install.sh | 60 -------------
arch/s390/boot/Makefile | 2 +-
arch/s390/boot/install.sh | 30 -------
arch/sh/boot/compressed/install.sh | 56 ------------
arch/sparc/boot/Makefile | 2 +-
arch/sparc/boot/install.sh | 50 -----------
arch/x86/boot/Makefile | 2 +-
arch/x86/boot/install.sh | 59 -------------
scripts/install.sh | 136 +++++++++++++++++++++++++++++
27 files changed, 156 insertions(+), 731 deletions(-)
delete mode 100644 arch/arm/boot/install.sh
delete mode 100644 arch/arm64/boot/install.sh
delete mode 100644 arch/ia64/install.sh
delete mode 100644 arch/m68k/install.sh
delete mode 100644 arch/nios2/boot/install.sh
delete mode 100644 arch/parisc/boot/install.sh
delete mode 100644 arch/parisc/install.sh
delete mode 100644 arch/powerpc/boot/install.sh
delete mode 100644 arch/riscv/boot/install.sh
delete mode 100644 arch/s390/boot/install.sh
delete mode 100644 arch/sh/boot/compressed/install.sh
delete mode 100644 arch/sparc/boot/install.sh
delete mode 100644 arch/x86/boot/install.sh
create mode 100644 scripts/install.sh


base-commit: e49d033bddf5b565044e2abe4241353959bc9120
--
2.31.1


2021-04-07 18:29:25

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 15/20] kbuild: parisc: use common install script

The common scripts/install.sh script will now work for parisc, all that
is needed is to add the compressed image type to it. So add that file
type check, and then we can remove the two different copies of the
parisc install.sh script that were only different by one line and have
the arch call the common install script.

Cc: "James E.J. Bottomley" <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
arch/parisc/Makefile | 4 +--
arch/parisc/boot/Makefile | 2 +-
arch/parisc/boot/install.sh | 65 ------------------------------------
arch/parisc/install.sh | 66 -------------------------------------
scripts/install.sh | 1 +
5 files changed, 4 insertions(+), 134 deletions(-)
delete mode 100644 arch/parisc/boot/install.sh
delete mode 100644 arch/parisc/install.sh

diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 7d9f71aa829a..296d8ab8e2aa 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -164,10 +164,10 @@ vmlinuz: vmlinux
endif

install:
- $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \
+ $(CONFIG_SHELL) $(srctree)/scripts/install.sh \
$(KERNELRELEASE) vmlinux System.map "$(INSTALL_PATH)"
zinstall:
- $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \
+ $(CONFIG_SHELL) $(srctree)/scripts/install.sh \
$(KERNELRELEASE) vmlinuz System.map "$(INSTALL_PATH)"

CLEAN_FILES += lifimage
diff --git a/arch/parisc/boot/Makefile b/arch/parisc/boot/Makefile
index 61f44142cfe1..ad2611929aee 100644
--- a/arch/parisc/boot/Makefile
+++ b/arch/parisc/boot/Makefile
@@ -17,5 +17,5 @@ $(obj)/compressed/vmlinux: FORCE
$(Q)$(MAKE) $(build)=$(obj)/compressed $@

install: $(CONFIGURE) $(obj)/bzImage
- sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
+ sh -x $(srctree)/scripts/install.sh $(KERNELRELEASE) $(obj)/bzImage \
System.map "$(INSTALL_PATH)"
diff --git a/arch/parisc/boot/install.sh b/arch/parisc/boot/install.sh
deleted file mode 100644
index 8f7c365fad83..000000000000
--- a/arch/parisc/boot/install.sh
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/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.
-#
-# Copyright (C) 1995 by Linus Torvalds
-#
-# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
-#
-# "make install" script for i386 architecture
-#
-# Arguments:
-# $1 - kernel version
-# $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
-fi
-
-# Default install
-
-if [ "$(basename $2)" = "zImage" ]; then
-# Compressed install
- echo "Installing compressed kernel"
- base=vmlinuz
-else
-# Normal install
- echo "Installing normal kernel"
- base=vmlinux
-fi
-
-if [ -f $4/$base-$1 ]; then
- mv $4/$base-$1 $4/$base-$1.old
-fi
-cat $2 > $4/$base-$1
-
-# Install system map file
-if [ -f $4/System.map-$1 ]; then
- mv $4/System.map-$1 $4/System.map-$1.old
-fi
-cp $3 $4/System.map-$1
diff --git a/arch/parisc/install.sh b/arch/parisc/install.sh
deleted file mode 100644
index 056d588befdd..000000000000
--- a/arch/parisc/install.sh
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/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.
-#
-# Copyright (C) 1995 by Linus Torvalds
-#
-# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
-#
-# "make install" script for i386 architecture
-#
-# Arguments:
-# $1 - kernel version
-# $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
-fi
-
-# Default install
-
-if [ "$(basename $2)" = "vmlinuz" ]; then
-# Compressed install
- echo "Installing compressed kernel"
- base=vmlinuz
-else
-# Normal install
- echo "Installing normal kernel"
- base=vmlinux
-fi
-
-if [ -f $4/$base-$1 ]; then
- mv $4/$base-$1 $4/$base-$1.old
-fi
-cat $2 > $4/$base-$1
-
-# Install system map file
-if [ -f $4/System.map-$1 ]; then
- mv $4/System.map-$1 $4/System.map-$1.old
-fi
-cp $3 $4/System.map-$1
-
diff --git a/scripts/install.sh b/scripts/install.sh
index 407ffa65062c..e0ffb95737d4 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -53,6 +53,7 @@ base=$(basename "$2")
if [ "$base" = "bzImage" ] ||
[ "$base" = "Image.gz" ] ||
[ "$base" = "vmlinux.gz" ] ||
+ [ "$base" = "vmlinuz" ] ||
[ "$base" = "zImage" ] ; then
# Compressed install
echo "Installing compressed kernel"
--
2.31.1

2021-04-07 18:29:26

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 04/20] kbuild: scripts/install.sh: call sync before calling the bootloader installer

It's good to ensure that the files are written out before calling the
bootloader installer, as other architectures do, so call sync after
doing the copying of the kernel and system map files.

Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
scripts/install.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/install.sh b/scripts/install.sh
index af36c0a82f01..92d0d2ade414 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -52,12 +52,12 @@ if [ -x /sbin/"${INSTALLKERNEL}" ]; then exec /sbin/"${INSTALLKERNEL}" "$@"; fi
# Default install - same as make zlilo
install "$2" "$4"/vmlinuz
install "$3" "$4"/System.map
+sync

if [ -x /sbin/lilo ]; then
/sbin/lilo
elif [ -x /etc/lilo/install ]; then
/etc/lilo/install
else
- sync
echo "Cannot find LILO."
fi
--
2.31.1

2021-04-07 18:30:07

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 10/20] kbuild: arm: use common install script

The common scripts/install.sh script will now work for arm, all that
is needed is to add the compressed image type to it. So add that file
type check and the ability to call /sbin/loadmap after copying the
kernel. With that we can remove the arm-only version of the file.

Cc: Russell King <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
arch/arm/boot/Makefile | 6 ++--
arch/arm/boot/install.sh | 66 ----------------------------------------
scripts/install.sh | 10 +++++-
3 files changed, 12 insertions(+), 70 deletions(-)
delete mode 100644 arch/arm/boot/install.sh

diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index 0b3cd7a33a26..053187f0b714 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -104,15 +104,15 @@ initrd:
(echo You must specify INITRD; exit -1)

install:
- $(CONFIG_SHELL) $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" \
+ $(CONFIG_SHELL) $(srctree)/scripts/install.sh "$(KERNELRELEASE)" \
$(obj)/Image System.map "$(INSTALL_PATH)"

zinstall:
- $(CONFIG_SHELL) $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" \
+ $(CONFIG_SHELL) $(srctree)/scripts/install.sh "$(KERNELRELEASE)" \
$(obj)/zImage System.map "$(INSTALL_PATH)"

uinstall:
- $(CONFIG_SHELL) $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" \
+ $(CONFIG_SHELL) $(srctree)/scripts/install.sh "$(KERNELRELEASE)" \
$(obj)/uImage System.map "$(INSTALL_PATH)"

subdir- := bootp compressed dts
diff --git a/arch/arm/boot/install.sh b/arch/arm/boot/install.sh
deleted file mode 100644
index 2a45092a40e3..000000000000
--- a/arch/arm/boot/install.sh
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/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.
-#
-# Copyright (C) 1995 by Linus Torvalds
-#
-# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
-# Adapted from code in arch/i386/boot/install.sh by Russell King
-#
-# "make install" script for arm architecture
-#
-# Arguments:
-# $1 - kernel version
-# $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
- echo "Installing compressed kernel"
- base=vmlinuz
-else
-# Normal install
- echo "Installing normal kernel"
- base=vmlinux
-fi
-
-if [ -f $4/$base-$1 ]; then
- mv $4/$base-$1 $4/$base-$1.old
-fi
-cat $2 > $4/$base-$1
-
-# Install system map file
-if [ -f $4/System.map-$1 ]; then
- mv $4/System.map-$1 $4/System.map-$1.old
-fi
-cp $3 $4/System.map-$1
-
-if [ -x /sbin/loadmap ]; then
- /sbin/loadmap
-else
- echo "You have to install it yourself"
-fi
diff --git a/scripts/install.sh b/scripts/install.sh
index 9c8a22d96255..73067b535ea0 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -51,7 +51,8 @@ if [ -x /sbin/"${INSTALLKERNEL}" ]; then exec /sbin/"${INSTALLKERNEL}" "$@"; fi

base=$(basename "$2")
if [ "$base" = "bzImage" ] ||
- [ "$base" = "Image.gz" ] ; then
+ [ "$base" = "Image.gz" ] ||
+ [ "$base" = "zImage" ] ; then
# Compressed install
echo "Installing compressed kernel"
base=vmlinuz
@@ -78,6 +79,13 @@ sync

# Some architectures like to call specific bootloader "helper" programs:
case "${ARCH}" in
+ arm)
+ if [ -x /sbin/loadmap ]; then
+ /sbin/loadmap
+ else
+ echo "You have to install it yourself"
+ fi
+ ;;
x86)
if [ -x /sbin/lilo ]; then
/sbin/lilo
--
2.31.1

2021-04-07 18:30:14

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 12/20] kbuild: m68k: use common install script

The common scripts/install.sh script will now work for m68k, all that
is needed is to add it to the list of arches that do not put the version
number in the installed file name.

With that we can remove the m68k-only version of the install script.

Cc: Geert Uytterhoeven <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
arch/m68k/Makefile | 2 +-
arch/m68k/install.sh | 52 --------------------------------------------
scripts/install.sh | 2 +-
3 files changed, 2 insertions(+), 54 deletions(-)
delete mode 100644 arch/m68k/install.sh

diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index ea14f2046fb4..e56abf79c313 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -143,4 +143,4 @@ archheaders:
$(Q)$(MAKE) $(build)=arch/m68k/kernel/syscalls all

install:
- sh $(srctree)/arch/m68k/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)"
+ sh $(srctree)/scripts/install.sh $(KERNELRELEASE) vmlinux.gz System.map "$(INSTALL_PATH)"
diff --git a/arch/m68k/install.sh b/arch/m68k/install.sh
deleted file mode 100644
index 57d640d4382c..000000000000
--- a/arch/m68k/install.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/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.
-#
-# Copyright (C) 1995 by Linus Torvalds
-#
-# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
-#
-# "make install" script for m68k architecture
-#
-# Arguments:
-# $1 - kernel version
-# $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
-fi
-
-if [ -f $4/System.map ]; then
- mv $4/System.map $4/System.old
-fi
-
-cat $2 > $4/vmlinuz
-cp $3 $4/System.map
-
-sync
diff --git a/scripts/install.sh b/scripts/install.sh
index b6ca2a0f0983..a61a5ce28cad 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -66,7 +66,7 @@ fi
# Some architectures name their files based on version number, and
# others do not. Call out the ones that do not to make it obvious.
case "${ARCH}" in
- ia64 | x86)
+ ia64 | m68k | x86)
version=""
;;
*)
--
2.31.1

2021-04-07 18:30:56

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 02/20] kbuild: scripts/install.sh: properly quote all variables

A few variables are quoted to handle spaces in directory names, but not
all of them. Properly quote everything so that the kernel build can
handle working correctly with directory names with spaces.

This change makes the script "shellcheck" clean now.

Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
scripts/install.sh | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/scripts/install.sh b/scripts/install.sh
index d13ec1c38640..c183d6ddd00c 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -33,21 +33,21 @@ 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 [ -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
+if [ -f "$4"/vmlinuz ]; then
+ mv "$4"/vmlinuz "$4"/vmlinuz.old
fi

-if [ -f $4/System.map ]; then
- mv $4/System.map $4/System.old
+if [ -f "$4"/System.map ]; then
+ mv "$4"/System.map "$4"/System.old
fi

-cat $2 > $4/vmlinuz
-cp $3 $4/System.map
+cat "$2" > "$4"/vmlinuz
+cp "$3" "$4"/System.map

if [ -x /sbin/lilo ]; then
/sbin/lilo
--
2.31.1

2021-04-07 18:57:04

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 01/20] kbuild: move x86 install script to scripts/install.sh

To unify the different architecture kernel installation scripts, start
out with the one they all were based on, the x86 script. Move it from
arch/x86/boot/ into scripts/ so that all architectures can call it in
the future.

Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
arch/x86/boot/Makefile | 2 +-
{arch/x86/boot => scripts}/install.sh | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename {arch/x86/boot => scripts}/install.sh (100%)

diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index fe605205b4ce..17c7718c1a4a 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -157,5 +157,5 @@ bzlilo:
if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi

install:
- sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
+ sh $(srctree)/scripts/install.sh $(KERNELRELEASE) $(obj)/bzImage \
System.map "$(INSTALL_PATH)"
diff --git a/arch/x86/boot/install.sh b/scripts/install.sh
similarity index 100%
rename from arch/x86/boot/install.sh
rename to scripts/install.sh
--
2.31.1

2021-04-07 18:57:05

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 09/20] kbuild: arm64: use common install script

The common scripts/install.sh script will now work for arm65, no changes
needed so convert the arm64 boot Makefile to call it instead of the
arm64-only version of the file and remove the now unused file.

Cc: Catalin Marinas <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
arch/arm64/boot/Makefile | 4 +--
arch/arm64/boot/install.sh | 60 --------------------------------------
2 files changed, 2 insertions(+), 62 deletions(-)
delete mode 100644 arch/arm64/boot/install.sh

diff --git a/arch/arm64/boot/Makefile b/arch/arm64/boot/Makefile
index cd3414898d10..08c56332dde2 100644
--- a/arch/arm64/boot/Makefile
+++ b/arch/arm64/boot/Makefile
@@ -37,9 +37,9 @@ $(obj)/Image.lzo: $(obj)/Image FORCE
$(call if_changed,lzo)

install:
- $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
+ $(CONFIG_SHELL) $(srctree)/scripts/install.sh $(KERNELRELEASE) \
$(obj)/Image System.map "$(INSTALL_PATH)"

zinstall:
- $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
+ $(CONFIG_SHELL) $(srctree)/scripts/install.sh $(KERNELRELEASE) \
$(obj)/Image.gz System.map "$(INSTALL_PATH)"
diff --git a/arch/arm64/boot/install.sh b/arch/arm64/boot/install.sh
deleted file mode 100644
index d91e1f022573..000000000000
--- a/arch/arm64/boot/install.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/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.
-#
-# Copyright (C) 1995 by Linus Torvalds
-#
-# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
-# Adapted from code in arch/i386/boot/install.sh by Russell King
-#
-# "make install" script for the AArch64 Linux port
-#
-# Arguments:
-# $1 - kernel version
-# $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
- echo "Installing compressed kernel"
- base=vmlinuz
-else
-# Normal install
- echo "Installing normal kernel"
- base=vmlinux
-fi
-
-if [ -f $4/$base-$1 ]; then
- mv $4/$base-$1 $4/$base-$1.old
-fi
-cat $2 > $4/$base-$1
-
-# Install system map file
-if [ -f $4/System.map-$1 ]; then
- mv $4/System.map-$1 $4/System.map-$1.old
-fi
-cp $3 $4/System.map-$1
--
2.31.1

2021-04-07 18:57:08

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 07/20] kbuild: scripts/install.sh: allow for the version number

Some architectures put the version number by default at the end of the
files that are copied, so add support for this to be set by arch type.

Odds are one day we should change this for x86, but let's not break
anyone's systems just yet.

Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
scripts/install.sh | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/scripts/install.sh b/scripts/install.sh
index 72dc4c81013e..934619f81119 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -60,8 +60,19 @@ else
base=vmlinux
fi

-install "$2" "$4"/"$base"
-install "$3" "$4"/System.map
+# Some architectures name their files based on version number, and
+# others do not. Call out the ones that do not to make it obvious.
+case "${ARCH}" in
+ x86)
+ version=""
+ ;;
+ *)
+ version="-${1}"
+ ;;
+esac
+
+install "$2" "$4"/"$base""$version"
+install "$3" "$4"/System.map"$version"
sync

# Some architectures like to call specific bootloader "helper" programs:
--
2.31.1

2021-04-07 18:57:18

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 05/20] kbuild: scripts/install.sh: prepare for arch-specific bootloaders

Despite the last release of LILO being in 2015, it seems that it is
still the default x86 bootloader and wants to be called to "install" the
new kernel image when it has been replaced on the disk. To allow
arch-specific programs like this to be called in future changes, move
the logic to an arch-specific test now.

Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
scripts/install.sh | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/scripts/install.sh b/scripts/install.sh
index 92d0d2ade414..2adcb993efa2 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -54,10 +54,15 @@ install "$2" "$4"/vmlinuz
install "$3" "$4"/System.map
sync

-if [ -x /sbin/lilo ]; then
- /sbin/lilo
-elif [ -x /etc/lilo/install ]; then
- /etc/lilo/install
-else
- echo "Cannot find LILO."
-fi
+# Some architectures like to call specific bootloader "helper" programs:
+case "${ARCH}" in
+ x86)
+ if [ -x /sbin/lilo ]; then
+ /sbin/lilo
+ elif [ -x /etc/lilo/install ]; then
+ /etc/lilo/install
+ else
+ echo "Cannot find LILO."
+ fi
+ ;;
+esac
--
2.31.1

2021-04-07 18:57:24

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 03/20] kbuild: scripts/install.sh: provide a "install" function

Instead of open-coding the "test for file, if present make a backup,
then copy the file to the new location" in multiple places, make a
single function, install(), to do all of this in one place.

Note, this does change the default x86 kernel map file saved name from
"System.old" to "System.map.old". This brings it into unification with
the other architectures as to what they call their backup file for the
kernel map file. As this is a text file, and nothing parses this from a
backup file, there should not be any operational differences.

Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
scripts/install.sh | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/scripts/install.sh b/scripts/install.sh
index c183d6ddd00c..af36c0a82f01 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -27,6 +27,19 @@ verify () {
fi
}

+install () {
+ install_source=${1}
+ install_target=${2}
+
+ echo "installing '${install_source}' to '${install_target}'"
+
+ # if the target is already present, move it to a .old filename
+ if [ -f "${install_target}" ]; then
+ mv "${install_target}" "${install_target}".old
+ fi
+ cat "${install_source}" > "${install_target}"
+}
+
# Make sure the files actually exist
verify "$2"
verify "$3"
@@ -37,17 +50,8 @@ 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
-fi
-
-if [ -f "$4"/System.map ]; then
- mv "$4"/System.map "$4"/System.old
-fi
-
-cat "$2" > "$4"/vmlinuz
-cp "$3" "$4"/System.map
+install "$2" "$4"/vmlinuz
+install "$3" "$4"/System.map

if [ -x /sbin/lilo ]; then
/sbin/lilo
--
2.31.1

2021-04-07 18:57:24

by Greg Kroah-Hartman

[permalink] [raw]
Subject: [PATCH 16/20] kbuild: powerpc: use common install script

The common scripts/install.sh script will now work for powerpc, all that
is needed is to add it to the list of arches that do not put the version
number in the installed file name.

After the kernel is installed, powerpc also likes to install a few
random files, so provide the ability to do that as well.

With that we can remove the powerpc-only version of the install script.

Cc: Michael Ellerman <[email protected]>
Cc: [email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
arch/powerpc/boot/Makefile | 4 +--
arch/powerpc/boot/install.sh | 55 ------------------------------------
scripts/install.sh | 14 ++++++++-
3 files changed, 15 insertions(+), 58 deletions(-)
delete mode 100644 arch/powerpc/boot/install.sh

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 2b8da923ceca..bbfcbd33e0b7 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -442,11 +442,11 @@ $(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y))

# Only install the vmlinux
install: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
- sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)"
+ sh -x $(srctree)/scripts/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)"

# Install the vmlinux and other built boot targets.
zInstall: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
- sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $^
+ sh -x $(srctree)/scripts/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $^

PHONY += install zInstall

diff --git a/arch/powerpc/boot/install.sh b/arch/powerpc/boot/install.sh
deleted file mode 100644
index b6a256bc96ee..000000000000
--- a/arch/powerpc/boot/install.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/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.
-#
-# Copyright (C) 1995 by Linus Torvalds
-#
-# Blatantly stolen from in arch/i386/boot/install.sh by Dave Hansen
-#
-# "make install" script for ppc64 architecture
-#
-# Arguments:
-# $1 - kernel version
-# $2 - kernel image file
-# $3 - kernel map file
-# $4 - default install path (blank if root directory)
-# $5 and more - kernel boot files; zImage*, uImage, cuImage.*, etc.
-#
-
-# Bail with error code if anything goes wrong
-set -e
-
-# 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`
-
-if [ -f $4/$image_name ]; then
- mv $4/$image_name $4/$image_name.old
-fi
-
-if [ -f $4/System.map ]; then
- mv $4/System.map $4/System.old
-fi
-
-cat $2 > $4/$image_name
-cp $3 $4/System.map
-
-# Copy all the bootable image files
-path=$4
-shift 4
-while [ $# -ne 0 ]; do
- image_name=`basename $1`
- if [ -f $path/$image_name ]; then
- mv $path/$image_name $path/$image_name.old
- fi
- cat $1 > $path/$image_name
- shift
-done;
diff --git a/scripts/install.sh b/scripts/install.sh
index e0ffb95737d4..67c0a5f74af2 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -67,7 +67,7 @@ fi
# Some architectures name their files based on version number, and
# others do not. Call out the ones that do not to make it obvious.
case "${ARCH}" in
- ia64 | m68k | nios2 | x86)
+ ia64 | m68k | nios2 | powerpc | x86)
version=""
;;
*)
@@ -93,6 +93,18 @@ case "${ARCH}" in
/usr/sbin/elilo
fi
;;
+ powerpc)
+ # powerpc installation can list other boot targets after the
+ # install path that should be copied to the correct location
+ path=$4
+ shift 4
+ while [ $# -ne 0 ]; do
+ image_name=$(basename "$1")
+ install "$1" "$path"/"$image_name"
+ shift
+ done;
+ sync
+ ;;
x86)
if [ -x /sbin/lilo ]; then
/sbin/lilo
--
2.31.1

2021-04-07 20:25:31

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 12/20] kbuild: m68k: use common install script

Hi Greg,

On Wed, Apr 7, 2021 at 7:35 AM Greg Kroah-Hartman
<[email protected]> wrote:
> The common scripts/install.sh script will now work for m68k, all that
> is needed is to add it to the list of arches that do not put the version
> number in the installed file name.
>
> With that we can remove the m68k-only version of the install script.
>
> Cc: Geert Uytterhoeven <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>

Thanks for your patch!

Acked-by: Geert Uytterhoeven <[email protected]>

I guess it would "work" with the version number, too.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2021-04-07 20:31:24

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH 00/20] kbuild: unify the install.sh script usage

On Wed, Apr 07, 2021 at 10:07:29AM +0200, Greg Kroah-Hartman wrote:
> On Wed, Apr 07, 2021 at 09:02:29AM +0100, Russell King - ARM Linux admin wrote:
> > On Wed, Apr 07, 2021 at 09:46:18AM +0200, Greg Kroah-Hartman wrote:
> > > On Wed, Apr 07, 2021 at 09:18:11AM +0200, Geert Uytterhoeven wrote:
> > > > Hi Greg,
> > > >
> > > > Thanks for your series!
> > > >
> > > > On Wed, Apr 7, 2021 at 7:34 AM Greg Kroah-Hartman
> > > > <[email protected]> wrote:
> > > > > Almost every architecture has copied the "install.sh" script that
> > > > > originally came with i386, and modified it in very tiny ways. This
> > > > > patch series unifies all of these scripts into one single script to
> > > > > allow people to understand how to correctly install a kernel, and fixes
> > > > > up some issues regarding trying to install a kernel to a path with
> > > > > spaces in it.
> > > > >
> > > > > Note that not all architectures actually seem to have any type of way to
> > > > > install a kernel, they must rely on external scripts or tools which
> > > > > feels odd as everything should be included here in the main repository.
> > > > > I'll work on trying to figure out the missing architecture issues
> > > > > afterward.
> > > >
> > > > I'll bite ;-)
> > > >
> > > > Does anyone actually use these scripts (outside of x86)?
> >
> > Yes, every time I build a kernel. My kernel build system involves
> > typing "kbuild <flags> <dirname> <machines...>" and the kernel gets
> > built in ../build/<dirname>. When the build completes, it gets
> > installed into ~/systems/<dirname>, tar'd up, and copied to the
> > destination machines, unpacked, installed as appropriate, and
> > the machine rebooted if requested.
> >
> > The installation step is done via the ~/bin/installkernel script.
>
> So you don't use install.sh at all except to invoke your local script.

It depends where the kernel is being built; it has been used in the
past (one will notice that the arm32 version is not a direct copy of
the x86 version, and never was - it was modified from day 1.) It's
placement and naming of the files in /boot is still used today, which
is slightly different from the x86 version.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

2021-04-07 20:32:16

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH 00/20] kbuild: unify the install.sh script usage

On Wed, Apr 07, 2021 at 09:46:18AM +0200, Greg Kroah-Hartman wrote:
> On Wed, Apr 07, 2021 at 09:18:11AM +0200, Geert Uytterhoeven wrote:
> > Hi Greg,
> >
> > Thanks for your series!
> >
> > On Wed, Apr 7, 2021 at 7:34 AM Greg Kroah-Hartman
> > <[email protected]> wrote:
> > > Almost every architecture has copied the "install.sh" script that
> > > originally came with i386, and modified it in very tiny ways. This
> > > patch series unifies all of these scripts into one single script to
> > > allow people to understand how to correctly install a kernel, and fixes
> > > up some issues regarding trying to install a kernel to a path with
> > > spaces in it.
> > >
> > > Note that not all architectures actually seem to have any type of way to
> > > install a kernel, they must rely on external scripts or tools which
> > > feels odd as everything should be included here in the main repository.
> > > I'll work on trying to figure out the missing architecture issues
> > > afterward.
> >
> > I'll bite ;-)
> >
> > Does anyone actually use these scripts (outside of x86)?

Yes, every time I build a kernel. My kernel build system involves
typing "kbuild <flags> <dirname> <machines...>" and the kernel gets
built in ../build/<dirname>. When the build completes, it gets
installed into ~/systems/<dirname>, tar'd up, and copied to the
destination machines, unpacked, installed as appropriate, and
the machine rebooted if requested.

The installation step is done via the ~/bin/installkernel script.

> > I assume the architectures that have them, only have them because they
> > were copied from x86 while doing the initial ports ("oh, a file I don't
> > have to modify at all.").
> > But installing the kernel can be very platform-specific.
> > Do you need the vmlinux, vmlinux.gz, Image, zImage, uImage, ...?
> > With separate or appended DTB?

My scripts deal with all that.

However, I haven't been able to review the changes that are being
made because I have no visibility of the common "scripts" version.
Provided it offers exactly the same functionality as the arm32
version, I'm happy. If it doesn't, it may cause a regression, and
I will be reporting that.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

2021-04-07 20:32:41

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 00/20] kbuild: unify the install.sh script usage

On Wed, Apr 07, 2021 at 09:02:29AM +0100, Russell King - ARM Linux admin wrote:
> On Wed, Apr 07, 2021 at 09:46:18AM +0200, Greg Kroah-Hartman wrote:
> > On Wed, Apr 07, 2021 at 09:18:11AM +0200, Geert Uytterhoeven wrote:
> > > Hi Greg,
> > >
> > > Thanks for your series!
> > >
> > > On Wed, Apr 7, 2021 at 7:34 AM Greg Kroah-Hartman
> > > <[email protected]> wrote:
> > > > Almost every architecture has copied the "install.sh" script that
> > > > originally came with i386, and modified it in very tiny ways. This
> > > > patch series unifies all of these scripts into one single script to
> > > > allow people to understand how to correctly install a kernel, and fixes
> > > > up some issues regarding trying to install a kernel to a path with
> > > > spaces in it.
> > > >
> > > > Note that not all architectures actually seem to have any type of way to
> > > > install a kernel, they must rely on external scripts or tools which
> > > > feels odd as everything should be included here in the main repository.
> > > > I'll work on trying to figure out the missing architecture issues
> > > > afterward.
> > >
> > > I'll bite ;-)
> > >
> > > Does anyone actually use these scripts (outside of x86)?
>
> Yes, every time I build a kernel. My kernel build system involves
> typing "kbuild <flags> <dirname> <machines...>" and the kernel gets
> built in ../build/<dirname>. When the build completes, it gets
> installed into ~/systems/<dirname>, tar'd up, and copied to the
> destination machines, unpacked, installed as appropriate, and
> the machine rebooted if requested.
>
> The installation step is done via the ~/bin/installkernel script.

So you don't use install.sh at all except to invoke your local script.

> > > I assume the architectures that have them, only have them because they
> > > were copied from x86 while doing the initial ports ("oh, a file I don't
> > > have to modify at all.").
> > > But installing the kernel can be very platform-specific.
> > > Do you need the vmlinux, vmlinux.gz, Image, zImage, uImage, ...?
> > > With separate or appended DTB?
>
> My scripts deal with all that.
>
> However, I haven't been able to review the changes that are being
> made because I have no visibility of the common "scripts" version.
> Provided it offers exactly the same functionality as the arm32
> version, I'm happy. If it doesn't, it may cause a regression, and
> I will be reporting that.

It should be identical, if I got something wrong please let me know.

thanks,

greg k-h

2021-04-07 20:37:03

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 00/20] kbuild: unify the install.sh script usage

On Wed, Apr 07, 2021 at 09:14:36AM +0100, Russell King - ARM Linux admin wrote:
> On Wed, Apr 07, 2021 at 10:07:29AM +0200, Greg Kroah-Hartman wrote:
> > On Wed, Apr 07, 2021 at 09:02:29AM +0100, Russell King - ARM Linux admin wrote:
> > > On Wed, Apr 07, 2021 at 09:46:18AM +0200, Greg Kroah-Hartman wrote:
> > > > On Wed, Apr 07, 2021 at 09:18:11AM +0200, Geert Uytterhoeven wrote:
> > > > > Hi Greg,
> > > > >
> > > > > Thanks for your series!
> > > > >
> > > > > On Wed, Apr 7, 2021 at 7:34 AM Greg Kroah-Hartman
> > > > > <[email protected]> wrote:
> > > > > > Almost every architecture has copied the "install.sh" script that
> > > > > > originally came with i386, and modified it in very tiny ways. This
> > > > > > patch series unifies all of these scripts into one single script to
> > > > > > allow people to understand how to correctly install a kernel, and fixes
> > > > > > up some issues regarding trying to install a kernel to a path with
> > > > > > spaces in it.
> > > > > >
> > > > > > Note that not all architectures actually seem to have any type of way to
> > > > > > install a kernel, they must rely on external scripts or tools which
> > > > > > feels odd as everything should be included here in the main repository.
> > > > > > I'll work on trying to figure out the missing architecture issues
> > > > > > afterward.
> > > > >
> > > > > I'll bite ;-)
> > > > >
> > > > > Does anyone actually use these scripts (outside of x86)?
> > >
> > > Yes, every time I build a kernel. My kernel build system involves
> > > typing "kbuild <flags> <dirname> <machines...>" and the kernel gets
> > > built in ../build/<dirname>. When the build completes, it gets
> > > installed into ~/systems/<dirname>, tar'd up, and copied to the
> > > destination machines, unpacked, installed as appropriate, and
> > > the machine rebooted if requested.
> > >
> > > The installation step is done via the ~/bin/installkernel script.
> >
> > So you don't use install.sh at all except to invoke your local script.
>
> It depends where the kernel is being built; it has been used in the
> past (one will notice that the arm32 version is not a direct copy of
> the x86 version, and never was - it was modified from day 1.) It's
> placement and naming of the files in /boot is still used today, which
> is slightly different from the x86 version.

The placement depends on the caller to the script, so that's not an
issue here. The name for the output does differ from x86, but the
"common" script handles all of that (or it should, if not I messed up.)

Attached below is the common scripts/install.sh that this patch series
produces at the end of it, if you want to check to see if I missed
anything for your arch.

thanks,

greg k-h


Attachments:
(No filename) (2.74 kB)
install.sh (3.75 kB)
Download all attachments

2021-04-07 20:53:39

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 00/20] kbuild: unify the install.sh script usage

On Wed, Apr 7, 2021 at 5:37 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> On Wed, Apr 07, 2021 at 09:14:36AM +0100, Russell King - ARM Linux admin wrote:
> > On Wed, Apr 07, 2021 at 10:07:29AM +0200, Greg Kroah-Hartman wrote:
> > > On Wed, Apr 07, 2021 at 09:02:29AM +0100, Russell King - ARM Linux admin wrote:
> > > > On Wed, Apr 07, 2021 at 09:46:18AM +0200, Greg Kroah-Hartman wrote:
> > > > > On Wed, Apr 07, 2021 at 09:18:11AM +0200, Geert Uytterhoeven wrote:
> > > > > > Hi Greg,
> > > > > >
> > > > > > Thanks for your series!
> > > > > >
> > > > > > On Wed, Apr 7, 2021 at 7:34 AM Greg Kroah-Hartman
> > > > > > <[email protected]> wrote:
> > > > > > > Almost every architecture has copied the "install.sh" script that
> > > > > > > originally came with i386, and modified it in very tiny ways. This
> > > > > > > patch series unifies all of these scripts into one single script to
> > > > > > > allow people to understand how to correctly install a kernel, and fixes
> > > > > > > up some issues regarding trying to install a kernel to a path with
> > > > > > > spaces in it.
> > > > > > >
> > > > > > > Note that not all architectures actually seem to have any type of way to
> > > > > > > install a kernel, they must rely on external scripts or tools which
> > > > > > > feels odd as everything should be included here in the main repository.
> > > > > > > I'll work on trying to figure out the missing architecture issues
> > > > > > > afterward.
> > > > > >
> > > > > > I'll bite ;-)
> > > > > >
> > > > > > Does anyone actually use these scripts (outside of x86)?
> > > >
> > > > Yes, every time I build a kernel. My kernel build system involves
> > > > typing "kbuild <flags> <dirname> <machines...>" and the kernel gets
> > > > built in ../build/<dirname>. When the build completes, it gets
> > > > installed into ~/systems/<dirname>, tar'd up, and copied to the
> > > > destination machines, unpacked, installed as appropriate, and
> > > > the machine rebooted if requested.
> > > >
> > > > The installation step is done via the ~/bin/installkernel script.
> > >
> > > So you don't use install.sh at all except to invoke your local script.
> >
> > It depends where the kernel is being built; it has been used in the
> > past (one will notice that the arm32 version is not a direct copy of
> > the x86 version, and never was - it was modified from day 1.) It's
> > placement and naming of the files in /boot is still used today, which
> > is slightly different from the x86 version.
>
> The placement depends on the caller to the script, so that's not an
> issue here. The name for the output does differ from x86, but the
> "common" script handles all of that (or it should, if not I messed up.)
>
> Attached below is the common scripts/install.sh that this patch series
> produces at the end of it, if you want to check to see if I missed
> anything for your arch.
>
> thanks,
>
> greg k-h



Thanks for nice cleanups!

I will give some nit-picking comments to individual patches.
Overall, this series looks nice.


--
Best Regards
Masahiro Yamada

2021-04-07 20:54:07

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 02/20] kbuild: scripts/install.sh: properly quote all variables

On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> A few variables are quoted to handle spaces in directory names, but not
> all of them. Properly quote everything so that the kernel build can
> handle working correctly with directory names with spaces.
>
> This change makes the script "shellcheck" clean now.
>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> scripts/install.sh | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/scripts/install.sh b/scripts/install.sh
> index d13ec1c38640..c183d6ddd00c 100644
> --- a/scripts/install.sh
> +++ b/scripts/install.sh
> @@ -33,21 +33,21 @@ 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 [ -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
> +if [ -f "$4"/vmlinuz ]; then
> + mv "$4"/vmlinuz "$4"/vmlinuz.old
> fi


Another way of quoting is doing like this:

if [ -f "$4/vmlinuz" ]; then
mv "$4/vmlinuz" "$4/vmlinuz.old"
fi


shellcheck is still satisfied.





Because you will add more quotes,
quoting the whole of each parameter might be cleaner.

See my comment in 07/20.








> -if [ -f $4/System.map ]; then
> - mv $4/System.map $4/System.old
> +if [ -f "$4"/System.map ]; then
> + mv "$4"/System.map "$4"/System.old
> fi
>
> -cat $2 > $4/vmlinuz
> -cp $3 $4/System.map
> +cat "$2" > "$4"/vmlinuz
> +cp "$3" "$4"/System.map
>
> if [ -x /sbin/lilo ]; then
> /sbin/lilo
> --
> 2.31.1
>


--
Best Regards
Masahiro Yamada

2021-04-07 20:54:11

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 03/20] kbuild: scripts/install.sh: provide a "install" function

On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> Instead of open-coding the "test for file, if present make a backup,
> then copy the file to the new location" in multiple places, make a
> single function, install(), to do all of this in one place.
>
> Note, this does change the default x86 kernel map file saved name from
> "System.old" to "System.map.old". This brings it into unification with
> the other architectures as to what they call their backup file for the
> kernel map file. As this is a text file, and nothing parses this from a
> backup file, there should not be any operational differences.
>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> scripts/install.sh | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/scripts/install.sh b/scripts/install.sh
> index c183d6ddd00c..af36c0a82f01 100644
> --- a/scripts/install.sh
> +++ b/scripts/install.sh
> @@ -27,6 +27,19 @@ verify () {
> fi
> }
>
> +install () {
> + install_source=${1}
> + install_target=${2}



You double-quoted all variables in 02/20.

For consistency and safety here,

install_source="${1}"

or

install_source="$1"


so that it will work even if $1 contains spaces.





> +
> + echo "installing '${install_source}' to '${install_target}'"
> +
> + # if the target is already present, move it to a .old filename
> + if [ -f "${install_target}" ]; then
> + mv "${install_target}" "${install_target}".old
> + fi
> + cat "${install_source}" > "${install_target}"
> +}
> +
> # Make sure the files actually exist
> verify "$2"
> verify "$3"
> @@ -37,17 +50,8 @@ 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
> -fi
> -
> -if [ -f "$4"/System.map ]; then
> - mv "$4"/System.map "$4"/System.old
> -fi
> -
> -cat "$2" > "$4"/vmlinuz
> -cp "$3" "$4"/System.map
> +install "$2" "$4"/vmlinuz
> +install "$3" "$4"/System.map
>
> if [ -x /sbin/lilo ]; then
> /sbin/lilo
> --
> 2.31.1
>


--
Best Regards

Masahiro Yamada

2021-04-07 20:54:55

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 04/20] kbuild: scripts/install.sh: call sync before calling the bootloader installer

On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> It's good to ensure that the files are written out before calling the
> bootloader installer, as other architectures do, so call sync after
> doing the copying of the kernel and system map files.


I see 3 architectures that call 'sync' from install.sh

masahiro@grover:~/ref/linux$ find . -name install.sh | xargs grep sync
./arch/nios2/boot/install.sh:sync
./arch/x86/boot/install.sh: sync
./arch/m68k/install.sh:sync


As for nios2 and m68k, they do not call
any bootloader-specific setups.



> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> scripts/install.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/install.sh b/scripts/install.sh
> index af36c0a82f01..92d0d2ade414 100644
> --- a/scripts/install.sh
> +++ b/scripts/install.sh
> @@ -52,12 +52,12 @@ if [ -x /sbin/"${INSTALLKERNEL}" ]; then exec /sbin/"${INSTALLKERNEL}" "$@"; fi
> # Default install - same as make zlilo
> install "$2" "$4"/vmlinuz
> install "$3" "$4"/System.map
> +sync
>
> if [ -x /sbin/lilo ]; then
> /sbin/lilo
> elif [ -x /etc/lilo/install ]; then
> /etc/lilo/install
> else
> - sync
> echo "Cannot find LILO."
> fi
> --
> 2.31.1
>

Why do we need 'sync' before lilo invocation?



If you want to ensure everything is flushed
to a disk before this scripts exits,
adding 'sync' at the end of the script
makes more sense, in my opinion.



if [ -x /sbin/lilo ]; then
/sbin/lilo
elif [ -x /etc/lilo/install ]; then
/etc/lilo/install
else
echo "Cannot find LILO."
fi

sync




This goes aligned with nios2 and m68k.



--
Best Regards

Masahiro Yamada

2021-04-07 20:55:34

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 16/20] kbuild: powerpc: use common install script

On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> The common scripts/install.sh script will now work for powerpc, all that
> is needed is to add it to the list of arches that do not put the version
> number in the installed file name.
>
> After the kernel is installed, powerpc also likes to install a few
> random files, so provide the ability to do that as well.
>
> With that we can remove the powerpc-only version of the install script.
>
> Cc: Michael Ellerman <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> arch/powerpc/boot/Makefile | 4 +--
> arch/powerpc/boot/install.sh | 55 ------------------------------------
> scripts/install.sh | 14 ++++++++-
> 3 files changed, 15 insertions(+), 58 deletions(-)
> delete mode 100644 arch/powerpc/boot/install.sh
>
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index 2b8da923ceca..bbfcbd33e0b7 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -442,11 +442,11 @@ $(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y))
>
> # Only install the vmlinux
> install: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
> - sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)"
> + sh -x $(srctree)/scripts/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)"
>
> # Install the vmlinux and other built boot targets.
> zInstall: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
> - sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $^
> + sh -x $(srctree)/scripts/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $^


I want comments from the ppc maintainers
because this code is already broken.


This 'zInstall' target is unreachable.

See commit c913e5f95e546d8d3a9f99ba9908f7e095cbc1fb

It added the new target 'zInstall', but it is not hooked anywhere.
It is completely useless for 6 years, and nobody has pointed it out.
So, I think nobody is caring about this broken code.

One more thing, Kbuild does not recognize it as an installation target
because the 'I' in 'zInstall' is a capital letter.

The name of the installation target must be '*install',
all letters in lower cases.






> PHONY += install zInstall
>
> diff --git a/arch/powerpc/boot/install.sh b/arch/powerpc/boot/install.sh
> deleted file mode 100644
> index b6a256bc96ee..000000000000
> --- a/arch/powerpc/boot/install.sh
> +++ /dev/null
> @@ -1,55 +0,0 @@
> -#!/bin/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.
> -#
> -# Copyright (C) 1995 by Linus Torvalds
> -#
> -# Blatantly stolen from in arch/i386/boot/install.sh by Dave Hansen
> -#
> -# "make install" script for ppc64 architecture
> -#
> -# Arguments:
> -# $1 - kernel version
> -# $2 - kernel image file
> -# $3 - kernel map file
> -# $4 - default install path (blank if root directory)
> -# $5 and more - kernel boot files; zImage*, uImage, cuImage.*, etc.
> -#
> -
> -# Bail with error code if anything goes wrong
> -set -e
> -
> -# 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`
> -
> -if [ -f $4/$image_name ]; then
> - mv $4/$image_name $4/$image_name.old
> -fi
> -
> -if [ -f $4/System.map ]; then
> - mv $4/System.map $4/System.old
> -fi
> -
> -cat $2 > $4/$image_name
> -cp $3 $4/System.map
> -
> -# Copy all the bootable image files
> -path=$4
> -shift 4
> -while [ $# -ne 0 ]; do
> - image_name=`basename $1`
> - if [ -f $path/$image_name ]; then
> - mv $path/$image_name $path/$image_name.old
> - fi
> - cat $1 > $path/$image_name
> - shift
> -done;
> diff --git a/scripts/install.sh b/scripts/install.sh
> index e0ffb95737d4..67c0a5f74af2 100644
> --- a/scripts/install.sh
> +++ b/scripts/install.sh
> @@ -67,7 +67,7 @@ fi
> # Some architectures name their files based on version number, and
> # others do not. Call out the ones that do not to make it obvious.
> case "${ARCH}" in
> - ia64 | m68k | nios2 | x86)
> + ia64 | m68k | nios2 | powerpc | x86)
> version=""
> ;;
> *)
> @@ -93,6 +93,18 @@ case "${ARCH}" in
> /usr/sbin/elilo
> fi
> ;;
> + powerpc)
> + # powerpc installation can list other boot targets after the
> + # install path that should be copied to the correct location


Perhaps, we can remove this if the ppc maintainers approve it ?




> + path=$4
> + shift 4
> + while [ $# -ne 0 ]; do
> + image_name=$(basename "$1")
> + install "$1" "$path"/"$image_name"
> + shift
> + done;
> + sync
> + ;;
> x86)
> if [ -x /sbin/lilo ]; then
> /sbin/lilo
> --
> 2.31.1
>


--
Best Regards
Masahiro Yamada

2021-04-07 20:55:37

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 15/20] kbuild: parisc: use common install script

On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> The common scripts/install.sh script will now work for parisc, all that
> is needed is to add the compressed image type to it. So add that file
> type check, and then we can remove the two different copies of the
> parisc install.sh script that were only different by one line and have
> the arch call the common install script.
>
> Cc: "James E.J. Bottomley" <[email protected]>
> Cc: Helge Deller <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> arch/parisc/Makefile | 4 +--
> arch/parisc/boot/Makefile | 2 +-
> arch/parisc/boot/install.sh | 65 ------------------------------------
> arch/parisc/install.sh | 66 -------------------------------------
> scripts/install.sh | 1 +
> 5 files changed, 4 insertions(+), 134 deletions(-)
> delete mode 100644 arch/parisc/boot/install.sh
> delete mode 100644 arch/parisc/install.sh
>
> diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
> index 7d9f71aa829a..296d8ab8e2aa 100644
> --- a/arch/parisc/Makefile
> +++ b/arch/parisc/Makefile
> @@ -164,10 +164,10 @@ vmlinuz: vmlinux
> endif
>
> install:
> - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \
> + $(CONFIG_SHELL) $(srctree)/scripts/install.sh \
> $(KERNELRELEASE) vmlinux System.map "$(INSTALL_PATH)"
> zinstall:
> - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \
> + $(CONFIG_SHELL) $(srctree)/scripts/install.sh \
> $(KERNELRELEASE) vmlinuz System.map "$(INSTALL_PATH)"
>
> CLEAN_FILES += lifimage
> diff --git a/arch/parisc/boot/Makefile b/arch/parisc/boot/Makefile
> index 61f44142cfe1..ad2611929aee 100644
> --- a/arch/parisc/boot/Makefile
> +++ b/arch/parisc/boot/Makefile
> @@ -17,5 +17,5 @@ $(obj)/compressed/vmlinux: FORCE
> $(Q)$(MAKE) $(build)=$(obj)/compressed $@
>
> install: $(CONFIGURE) $(obj)/bzImage
> - sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
> + sh -x $(srctree)/scripts/install.sh $(KERNELRELEASE) $(obj)/bzImage \
> System.map "$(INSTALL_PATH)"



As far as I understood, there is no way to invoke this 'install' target
in arch/parisc/boot/Makefile since everything is done
by arch/parisc/Makefile.



Can we remove this 'install' rule entirely?










> diff --git a/arch/parisc/boot/install.sh b/arch/parisc/boot/install.sh
> deleted file mode 100644
> index 8f7c365fad83..000000000000
> --- a/arch/parisc/boot/install.sh
> +++ /dev/null
> @@ -1,65 +0,0 @@
> -#!/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.
> -#
> -# Copyright (C) 1995 by Linus Torvalds
> -#
> -# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
> -#
> -# "make install" script for i386 architecture
> -#
> -# Arguments:
> -# $1 - kernel version
> -# $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
> -fi
> -
> -# Default install
> -
> -if [ "$(basename $2)" = "zImage" ]; then
> -# Compressed install
> - echo "Installing compressed kernel"
> - base=vmlinuz
> -else
> -# Normal install
> - echo "Installing normal kernel"
> - base=vmlinux
> -fi
> -
> -if [ -f $4/$base-$1 ]; then
> - mv $4/$base-$1 $4/$base-$1.old
> -fi
> -cat $2 > $4/$base-$1
> -
> -# Install system map file
> -if [ -f $4/System.map-$1 ]; then
> - mv $4/System.map-$1 $4/System.map-$1.old
> -fi
> -cp $3 $4/System.map-$1
> diff --git a/arch/parisc/install.sh b/arch/parisc/install.sh
> deleted file mode 100644
> index 056d588befdd..000000000000
> --- a/arch/parisc/install.sh
> +++ /dev/null
> @@ -1,66 +0,0 @@
> -#!/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.
> -#
> -# Copyright (C) 1995 by Linus Torvalds
> -#
> -# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
> -#
> -# "make install" script for i386 architecture
> -#
> -# Arguments:
> -# $1 - kernel version
> -# $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
> -fi
> -
> -# Default install
> -
> -if [ "$(basename $2)" = "vmlinuz" ]; then
> -# Compressed install
> - echo "Installing compressed kernel"
> - base=vmlinuz
> -else
> -# Normal install
> - echo "Installing normal kernel"
> - base=vmlinux
> -fi
> -
> -if [ -f $4/$base-$1 ]; then
> - mv $4/$base-$1 $4/$base-$1.old
> -fi
> -cat $2 > $4/$base-$1
> -
> -# Install system map file
> -if [ -f $4/System.map-$1 ]; then
> - mv $4/System.map-$1 $4/System.map-$1.old
> -fi
> -cp $3 $4/System.map-$1
> -
> diff --git a/scripts/install.sh b/scripts/install.sh
> index 407ffa65062c..e0ffb95737d4 100644
> --- a/scripts/install.sh
> +++ b/scripts/install.sh
> @@ -53,6 +53,7 @@ base=$(basename "$2")
> if [ "$base" = "bzImage" ] ||
> [ "$base" = "Image.gz" ] ||
> [ "$base" = "vmlinux.gz" ] ||
> + [ "$base" = "vmlinuz" ] ||
> [ "$base" = "zImage" ] ; then
> # Compressed install
> echo "Installing compressed kernel"
> --
> 2.31.1
>


--
Best Regards
Masahiro Yamada

2021-04-07 20:59:40

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 07/20] kbuild: scripts/install.sh: allow for the version number

On Wed, Apr 07, 2021 at 08:05:23PM +0900, Masahiro Yamada wrote:
> On Wed, Apr 7, 2021 at 2:35 PM Greg Kroah-Hartman
> <[email protected]> wrote:
> >
> > Some architectures put the version number by default at the end of the
> > files that are copied, so add support for this to be set by arch type.
> >
> > Odds are one day we should change this for x86, but let's not break
> > anyone's systems just yet.
> >
> > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > ---
> > scripts/install.sh | 15 +++++++++++++--
> > 1 file changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/scripts/install.sh b/scripts/install.sh
> > index 72dc4c81013e..934619f81119 100644
> > --- a/scripts/install.sh
> > +++ b/scripts/install.sh
> > @@ -60,8 +60,19 @@ else
> > base=vmlinux
> > fi
> >
> > -install "$2" "$4"/"$base"
> > -install "$3" "$4"/System.map
> > +# Some architectures name their files based on version number, and
> > +# others do not. Call out the ones that do not to make it obvious.
> > +case "${ARCH}" in
> > + x86)
> > + version=""
> > + ;;
> > + *)
> > + version="-${1}"
> > + ;;
> > +esac
> > +
> > +install "$2" "$4"/"$base""$version"
>
>
> Too many quotes are eye sore.
>
>
> install "$2" "$4/$base$version"
>
> looks cleaner in my opinion.
>
> Shell correctly understands the end of each
> variable because a slash or a dollar
> cannot be a part of a variable name.

Good idea, I usually just default to "quote everything!" when dealing
with bash variables. I'll fix this up.

Oh, any preference for "$2" vs. "${2}"? I don't care either way but I
couldn't tell what is the normal kernel style these days.

thanks for all of the review, much appreciated!

greg k-h

2021-04-07 21:07:31

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH 09/20] kbuild: arm64: use common install script

On Wed, Apr 07, 2021 at 07:34:08AM +0200, Greg Kroah-Hartman wrote:
> The common scripts/install.sh script will now work for arm65, no changes
> needed so convert the arm64 boot Makefile to call it instead of the
> arm64-only version of the file and remove the now unused file.
>
> Cc: Catalin Marinas <[email protected]>
> Cc: Will Deacon <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>

Assuming that it does the same thing (it seems to from a quick look):

Acked-by: Catalin Marinas <[email protected]>

2021-04-07 22:31:53

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 00/20] kbuild: unify the install.sh script usage

Hi Greg,

Thanks for your series!

On Wed, Apr 7, 2021 at 7:34 AM Greg Kroah-Hartman
<[email protected]> wrote:
> Almost every architecture has copied the "install.sh" script that
> originally came with i386, and modified it in very tiny ways. This
> patch series unifies all of these scripts into one single script to
> allow people to understand how to correctly install a kernel, and fixes
> up some issues regarding trying to install a kernel to a path with
> spaces in it.
>
> Note that not all architectures actually seem to have any type of way to
> install a kernel, they must rely on external scripts or tools which
> feels odd as everything should be included here in the main repository.
> I'll work on trying to figure out the missing architecture issues
> afterward.

I'll bite ;-)

Does anyone actually use these scripts (outside of x86)?
I assume the architectures that have them, only have them because they
were copied from x86 while doing the initial ports ("oh, a file I don't
have to modify at all.").
But installing the kernel can be very platform-specific.
Do you need the vmlinux, vmlinux.gz, Image, zImage, uImage, ...?
With separate or appended DTB?

Even on x86, the script will bail out with "Cannot find LILO." if you're
using Grub.

Anyway, having less of them is good.

Gr{oetje,eeting}s,

Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2021-04-07 22:32:19

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 00/20] kbuild: unify the install.sh script usage

On Wed, Apr 07, 2021 at 09:18:11AM +0200, Geert Uytterhoeven wrote:
> Hi Greg,
>
> Thanks for your series!
>
> On Wed, Apr 7, 2021 at 7:34 AM Greg Kroah-Hartman
> <[email protected]> wrote:
> > Almost every architecture has copied the "install.sh" script that
> > originally came with i386, and modified it in very tiny ways. This
> > patch series unifies all of these scripts into one single script to
> > allow people to understand how to correctly install a kernel, and fixes
> > up some issues regarding trying to install a kernel to a path with
> > spaces in it.
> >
> > Note that not all architectures actually seem to have any type of way to
> > install a kernel, they must rely on external scripts or tools which
> > feels odd as everything should be included here in the main repository.
> > I'll work on trying to figure out the missing architecture issues
> > afterward.
>
> I'll bite ;-)
>
> Does anyone actually use these scripts (outside of x86)?

I think so, if not then what do they use?

Ok, I'll answer that, Before this week, I used my own script, a horrible
hack I've drug along for years:
https://github.com/gregkh/gregkh-linux/blob/master/scripts/install

but for almost everyone else, they just use /sbin/installkernel that is
provided by their distro. But this feels really odd given that we
should include the logic to install the kernel in the kernel source
itself, otherwise everyone has to rely on an external package that no
one knows where it is.

> I assume the architectures that have them, only have them because they
> were copied from x86 while doing the initial ports ("oh, a file I don't
> have to modify at all.").
> But installing the kernel can be very platform-specific.
> Do you need the vmlinux, vmlinux.gz, Image, zImage, uImage, ...?
> With separate or appended DTB?

That seems handled already by the arch/ARCH/boot/Makefile logic today,
so I do not think we need to change that.

> Even on x86, the script will bail out with "Cannot find LILO." if you're
> using Grub.

The last change in this series tries to "soften" that language so that
isn't really an issue anymore.

I want to turn this into something that everyone can use, so we do not
have to rely on distro-specific or other external programs, as trying to
explain how to install a kernel to someone new to kernel development is
a real pain.

> Anyway, having less of them is good.

Agreed, thanks for the review :)

greg k-h

2021-04-07 22:35:03

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 07/20] kbuild: scripts/install.sh: allow for the version number

On Wed, Apr 7, 2021 at 2:35 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> Some architectures put the version number by default at the end of the
> files that are copied, so add support for this to be set by arch type.
>
> Odds are one day we should change this for x86, but let's not break
> anyone's systems just yet.
>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
> scripts/install.sh | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/install.sh b/scripts/install.sh
> index 72dc4c81013e..934619f81119 100644
> --- a/scripts/install.sh
> +++ b/scripts/install.sh
> @@ -60,8 +60,19 @@ else
> base=vmlinux
> fi
>
> -install "$2" "$4"/"$base"
> -install "$3" "$4"/System.map
> +# Some architectures name their files based on version number, and
> +# others do not. Call out the ones that do not to make it obvious.
> +case "${ARCH}" in
> + x86)
> + version=""
> + ;;
> + *)
> + version="-${1}"
> + ;;
> +esac
> +
> +install "$2" "$4"/"$base""$version"


Too many quotes are eye sore.


install "$2" "$4/$base$version"

looks cleaner in my opinion.

Shell correctly understands the end of each
variable because a slash or a dollar
cannot be a part of a variable name.







> +install "$3" "$4"/System.map"$version"
> sync
>
> # Some architectures like to call specific bootloader "helper" programs:
> --
> 2.31.1
>


--
Best Regards

Masahiro Yamada

2021-04-07 22:35:30

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH 07/20] kbuild: scripts/install.sh: allow for the version number

On Wed, Apr 7, 2021 at 10:04 PM Greg Kroah-Hartman
<[email protected]> wrote:
>
> On Wed, Apr 07, 2021 at 08:05:23PM +0900, Masahiro Yamada wrote:
> > On Wed, Apr 7, 2021 at 2:35 PM Greg Kroah-Hartman
> > <[email protected]> wrote:
> > >
> > > Some architectures put the version number by default at the end of the
> > > files that are copied, so add support for this to be set by arch type.
> > >
> > > Odds are one day we should change this for x86, but let's not break
> > > anyone's systems just yet.
> > >
> > > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > > ---
> > > scripts/install.sh | 15 +++++++++++++--
> > > 1 file changed, 13 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/scripts/install.sh b/scripts/install.sh
> > > index 72dc4c81013e..934619f81119 100644
> > > --- a/scripts/install.sh
> > > +++ b/scripts/install.sh
> > > @@ -60,8 +60,19 @@ else
> > > base=vmlinux
> > > fi
> > >
> > > -install "$2" "$4"/"$base"
> > > -install "$3" "$4"/System.map
> > > +# Some architectures name their files based on version number, and
> > > +# others do not. Call out the ones that do not to make it obvious.
> > > +case "${ARCH}" in
> > > + x86)
> > > + version=""
> > > + ;;
> > > + *)
> > > + version="-${1}"
> > > + ;;
> > > +esac
> > > +
> > > +install "$2" "$4"/"$base""$version"
> >
> >
> > Too many quotes are eye sore.
> >
> >
> > install "$2" "$4/$base$version"
> >
> > looks cleaner in my opinion.
> >
> > Shell correctly understands the end of each
> > variable because a slash or a dollar
> > cannot be a part of a variable name.
>
> Good idea, I usually just default to "quote everything!" when dealing
> with bash variables. I'll fix this up.
>
> Oh, any preference for "$2" vs. "${2}"? I don't care either way but I
> couldn't tell what is the normal kernel style these days.


I do not see a well-defined coding style guideline
for shell scripts.

If you want to know my personal preference,
I use "$2" without braces.


Thanks.


>
> thanks for all of the review, much appreciated!

My pleasure.

>
> greg k-h



--
Best Regards
Masahiro Yamada

2021-04-09 03:09:39

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 09/20] kbuild: arm64: use common install script

On Wed, Apr 07, 2021 at 07:34:08AM +0200, Greg Kroah-Hartman wrote:
> The common scripts/install.sh script will now work for arm65, no changes

nit: arm64

> needed so convert the arm64 boot Makefile to call it instead of the
> arm64-only version of the file and remove the now unused file.
>
> Cc: Catalin Marinas <[email protected]>
> Cc: Will Deacon <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>

With that fixed:

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2021-04-09 03:09:48

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 05/20] kbuild: scripts/install.sh: prepare for arch-specific bootloaders

On Wed, Apr 07, 2021 at 07:34:04AM +0200, Greg Kroah-Hartman wrote:
> Despite the last release of LILO being in 2015, it seems that it is
> still the default x86 bootloader and wants to be called to "install" the
> new kernel image when it has been replaced on the disk. To allow
> arch-specific programs like this to be called in future changes, move
> the logic to an arch-specific test now.
>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2021-04-09 03:11:53

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 01/20] kbuild: move x86 install script to scripts/install.sh

On Wed, Apr 07, 2021 at 07:34:00AM +0200, Greg Kroah-Hartman wrote:
> To unify the different architecture kernel installation scripts, start
> out with the one they all were based on, the x86 script. Move it from
> arch/x86/boot/ into scripts/ so that all architectures can call it in
> the future.
>
> Cc: Thomas Gleixner <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2021-04-09 03:12:23

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 12/20] kbuild: m68k: use common install script

On Wed, Apr 07, 2021 at 07:34:11AM +0200, Greg Kroah-Hartman wrote:
> The common scripts/install.sh script will now work for m68k, all that
> is needed is to add it to the list of arches that do not put the version
> number in the installed file name.
>
> With that we can remove the m68k-only version of the install script.
>
> Cc: Geert Uytterhoeven <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2021-04-09 03:12:28

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 10/20] kbuild: arm: use common install script

On Wed, Apr 07, 2021 at 07:34:09AM +0200, Greg Kroah-Hartman wrote:
> The common scripts/install.sh script will now work for arm, all that
> is needed is to add the compressed image type to it. So add that file
> type check and the ability to call /sbin/loadmap after copying the
> kernel. With that we can remove the arm-only version of the file.
>
> Cc: Russell King <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> Cc: [email protected]
> Signed-off-by: Greg Kroah-Hartman <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2021-04-09 03:14:47

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 00/20] kbuild: unify the install.sh script usage

On Wed, Apr 07, 2021 at 07:33:59AM +0200, Greg Kroah-Hartman wrote:
> Almost every architecture has copied the "install.sh" script that
> originally came with i386, and modified it in very tiny ways. This
> patch series unifies all of these scripts into one single script to
> allow people to understand how to correctly install a kernel, and fixes
> up some issues regarding trying to install a kernel to a path with
> spaces in it.

Yay consolidation! Thanks for digging into this.

I sent Reviewed-by:s for a bunch of these, and agree with the things
Masahiro has suggested with regard to quoting, etc. I look forward to
v2.

-Kees

--
Kees Cook

2021-04-09 06:38:54

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 09/20] kbuild: arm64: use common install script

On Thu, Apr 08, 2021 at 08:08:18PM -0700, Kees Cook wrote:
> On Wed, Apr 07, 2021 at 07:34:08AM +0200, Greg Kroah-Hartman wrote:
> > The common scripts/install.sh script will now work for arm65, no changes
>
> nit: arm64

Hah!

Thanks for the reviews, I'll be doing a new series soon based on
Masahiro's reviews.

thanks,

greg k-h

2021-04-14 18:07:24

by Helge Deller

[permalink] [raw]
Subject: Re: [PATCH 15/20] kbuild: parisc: use common install script

On 4/7/21 1:23 PM, Masahiro Yamada wrote:
> On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman
> <[email protected]> wrote:
>>
>> The common scripts/install.sh script will now work for parisc, all that
>> is needed is to add the compressed image type to it. So add that file
>> type check, and then we can remove the two different copies of the
>> parisc install.sh script that were only different by one line and have
>> the arch call the common install script.
>>
>> Cc: "James E.J. Bottomley" <[email protected]>
>> Cc: Helge Deller <[email protected]>
>> Cc: [email protected]
>> Signed-off-by: Greg Kroah-Hartman <[email protected]>
>> ---
>> arch/parisc/Makefile | 4 +--
>> arch/parisc/boot/Makefile | 2 +-
>> arch/parisc/boot/install.sh | 65 ------------------------------------
>> arch/parisc/install.sh | 66 -------------------------------------
>> scripts/install.sh | 1 +
>> 5 files changed, 4 insertions(+), 134 deletions(-)
>> delete mode 100644 arch/parisc/boot/install.sh
>> delete mode 100644 arch/parisc/install.sh
>>
>> diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
>> index 7d9f71aa829a..296d8ab8e2aa 100644
>> --- a/arch/parisc/Makefile
>> +++ b/arch/parisc/Makefile
>> @@ -164,10 +164,10 @@ vmlinuz: vmlinux
>> endif
>>
>> install:
>> - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \
>> + $(CONFIG_SHELL) $(srctree)/scripts/install.sh \
>> $(KERNELRELEASE) vmlinux System.map "$(INSTALL_PATH)"
>> zinstall:
>> - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \
>> + $(CONFIG_SHELL) $(srctree)/scripts/install.sh \
>> $(KERNELRELEASE) vmlinuz System.map "$(INSTALL_PATH)"
>>
>> CLEAN_FILES += lifimage
>> diff --git a/arch/parisc/boot/Makefile b/arch/parisc/boot/Makefile
>> index 61f44142cfe1..ad2611929aee 100644
>> --- a/arch/parisc/boot/Makefile
>> +++ b/arch/parisc/boot/Makefile
>> @@ -17,5 +17,5 @@ $(obj)/compressed/vmlinux: FORCE
>> $(Q)$(MAKE) $(build)=$(obj)/compressed $@
>>
>> install: $(CONFIGURE) $(obj)/bzImage
>> - sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
>> + sh -x $(srctree)/scripts/install.sh $(KERNELRELEASE) $(obj)/bzImage \
>> System.map "$(INSTALL_PATH)"
>
>
>
> As far as I understood, there is no way to invoke this 'install' target
> in arch/parisc/boot/Makefile since everything is done
> by arch/parisc/Makefile.
>
> Can we remove this 'install' rule entirely?

Yes, I think it can go in arch/parisc/boot/Makefile.

Helge

2021-04-15 00:38:27

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 15/20] kbuild: parisc: use common install script

On Wed, Apr 14, 2021 at 06:30:59PM +0200, Helge Deller wrote:
> On 4/7/21 1:23 PM, Masahiro Yamada wrote:
> > On Wed, Apr 7, 2021 at 2:34 PM Greg Kroah-Hartman
> > <[email protected]> wrote:
> > >
> > > The common scripts/install.sh script will now work for parisc, all that
> > > is needed is to add the compressed image type to it. So add that file
> > > type check, and then we can remove the two different copies of the
> > > parisc install.sh script that were only different by one line and have
> > > the arch call the common install script.
> > >
> > > Cc: "James E.J. Bottomley" <[email protected]>
> > > Cc: Helge Deller <[email protected]>
> > > Cc: [email protected]
> > > Signed-off-by: Greg Kroah-Hartman <[email protected]>
> > > ---
> > > arch/parisc/Makefile | 4 +--
> > > arch/parisc/boot/Makefile | 2 +-
> > > arch/parisc/boot/install.sh | 65 ------------------------------------
> > > arch/parisc/install.sh | 66 -------------------------------------
> > > scripts/install.sh | 1 +
> > > 5 files changed, 4 insertions(+), 134 deletions(-)
> > > delete mode 100644 arch/parisc/boot/install.sh
> > > delete mode 100644 arch/parisc/install.sh
> > >
> > > diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
> > > index 7d9f71aa829a..296d8ab8e2aa 100644
> > > --- a/arch/parisc/Makefile
> > > +++ b/arch/parisc/Makefile
> > > @@ -164,10 +164,10 @@ vmlinuz: vmlinux
> > > endif
> > >
> > > install:
> > > - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \
> > > + $(CONFIG_SHELL) $(srctree)/scripts/install.sh \
> > > $(KERNELRELEASE) vmlinux System.map "$(INSTALL_PATH)"
> > > zinstall:
> > > - $(CONFIG_SHELL) $(srctree)/arch/parisc/install.sh \
> > > + $(CONFIG_SHELL) $(srctree)/scripts/install.sh \
> > > $(KERNELRELEASE) vmlinuz System.map "$(INSTALL_PATH)"
> > >
> > > CLEAN_FILES += lifimage
> > > diff --git a/arch/parisc/boot/Makefile b/arch/parisc/boot/Makefile
> > > index 61f44142cfe1..ad2611929aee 100644
> > > --- a/arch/parisc/boot/Makefile
> > > +++ b/arch/parisc/boot/Makefile
> > > @@ -17,5 +17,5 @@ $(obj)/compressed/vmlinux: FORCE
> > > $(Q)$(MAKE) $(build)=$(obj)/compressed $@
> > >
> > > install: $(CONFIGURE) $(obj)/bzImage
> > > - sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
> > > + sh -x $(srctree)/scripts/install.sh $(KERNELRELEASE) $(obj)/bzImage \
> > > System.map "$(INSTALL_PATH)"
> >
> >
> >
> > As far as I understood, there is no way to invoke this 'install' target
> > in arch/parisc/boot/Makefile since everything is done
> > by arch/parisc/Makefile.
> >
> > Can we remove this 'install' rule entirely?
>
> Yes, I think it can go in arch/parisc/boot/Makefile.

It's already there today, so I'll delete the rule from
arch/parisc/Makefile in my next round.

thanks,

greg k-h