kbuild: Fix install errors when INSTALL_PATH does not exist
Subsystems (10)
cover kbuild: Fix install errors when INSTALL_PATH does not exist
From: Zhang Bingwu <[email protected]>
When running 'make zinstall INSTALL_PATH=somepath'
where 'somepath' does not exist, the install scripts (install.sh) print error messages
but also return a success status code.
This will make 'make' regard 'install' (and 'zinstall', etc)
succeeded.
When there are also other targets at the same time,
for example, 'make zinstall dtbs_install modules_install', make will keep going on and other outputs will fill stdout, and make the error message hard to find.
dtbs_install and modules_install creates the target directory
if it does not exist. install, zinstall and others should have the same behaviour.
If INSTALL_PATH is not a valid directory, we should create it. If the installation process still fails with errors, for example,
insufficient space on disk or permission denied, make should regard the install target failed, stop as soon as possible,
and exit with error.
Zhang Bingwu (2):
kbuild: Abort make on install failures
kbuild: Create INSTALL_PATH directory if it does not exist
arch/arm/boot/install.sh | 2 ++ arch/arm64/boot/install.sh | 2 ++ arch/m68k/install.sh | 2 ++ arch/nios2/boot/install.sh | 2 ++ arch/parisc/install.sh | 2 ++ arch/riscv/boot/install.sh | 2 ++ arch/s390/boot/install.sh | 2 ++ arch/sparc/boot/install.sh | 2 ++ arch/x86/boot/install.sh | 2 ++ scripts/install.sh | 4 ++++ 10 files changed, 22 insertions(+)
base-commit: d0f86d080e3d7d5e1e75a56d88daf8e5f56a4146
Signature · 1 line
2.43.0
PATCH 1/2 kbuild: Abort make on install failures
From: Zhang Bingwu <[email protected]>
Setting '-e' flag tells shells to exit with error exit code immediately after any of commands fails, and causes make(1) to regard recipes as failed.
Before this, make will still continue to succeed even after the installation failed, for example, for insufficient permission or directory does not exist.
--- arch/arm/boot/install.sh | 2 ++ arch/arm64/boot/install.sh | 2 ++ arch/m68k/install.sh | 2 ++ arch/nios2/boot/install.sh | 2 ++ arch/parisc/install.sh | 2 ++ arch/riscv/boot/install.sh | 2 ++ arch/s390/boot/install.sh | 2 ++ arch/sparc/boot/install.sh | 2 ++ arch/x86/boot/install.sh | 2 ++ 9 files changed, 18 insertions(+)
arch/arm/boot/install.sh +2 -0
@@ -17,6 +17,8 @@ # $3 - kernel map file # $4 - default install path (blank if root directory) +set -e + if [ "$(basename $2)" = "zImage" ]; then # Compressed install echo "Installing compressed kernel"
arch/arm64/boot/install.sh +2 -0
@@ -17,6 +17,8 @@ # $3 - kernel map file # $4 - default install path (blank if root directory) +set -e + if [ "$(basename $2)" = "Image.gz" ] || [ "$(basename $2)" = "vmlinuz.efi" ] then # Compressed install
arch/m68k/install.sh +2 -0
@@ -16,6 +16,8 @@ # $3 - kernel map file # $4 - default install path (blank if root directory) +set -e + if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.old fi
arch/nios2/boot/install.sh +2 -0
@@ -16,6 +16,8 @@ # $3 - kernel map file # $4 - default install path (blank if root directory) +set -e + if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.old fi
arch/parisc/install.sh +2 -0
@@ -16,6 +16,8 @@ # $3 - kernel map file # $4 - default install path (blank if root directory) +set -e + if [ "$(basename $2)" = "vmlinuz" ]; then # Compressed install echo "Installing compressed kernel"
arch/riscv/boot/install.sh +2 -0
@@ -17,6 +17,8 @@ # $3 - kernel map file # $4 - default install path (blank if root directory) +set -e + if [ "$(basename $2)" = "Image.gz" ]; then # Compressed install echo "Installing compressed kernel"
arch/s390/boot/install.sh +2 -0
@@ -15,6 +15,8 @@ # $3 - kernel map file # $4 - default install path (blank if root directory) +set -e + echo "Warning: '${INSTALLKERNEL}' command not available - additional " \ "bootloader config required" >&2 if [ -f "$4/vmlinuz-$1" ]; then mv -- "$4/vmlinuz-$1" "$4/vmlinuz-$1.old"; fi
arch/sparc/boot/install.sh +2 -0
@@ -16,6 +16,8 @@ # $3 - kernel map file # $4 - default install path (blank if root directory) +set -e + if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.old fi
arch/x86/boot/install.sh +2 -0
@@ -16,6 +16,8 @@ # $3 - kernel map file # $4 - default install path (blank if root directory) +set -e + if [ -f $4/vmlinuz ]; then mv $4/vmlinuz $4/vmlinuz.old fi
Signature · 1 line
2.43.0
Re: [PATCH 1/2] kbuild: Abort make on install failures
Quoted 7 lines · Zhang Bingwu
From: Zhang Bingwu <[email protected]>
Setting '-e' flag tells shells to exit with error exit code immediately after any of commands fails, and causes make(1) to regard recipes as failed.
Quoted 5 lines
Before this, make will still continue to succeed even after the installation failed, for example, for insufficient permission or directory does not exist.
Signed-off-by Zhang Bingwu <[email protected]>
Applied to linux-kbuild. Thanks!
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH 2/2 kbuild: Create INSTALL_PATH directory if it does not exist
In reply to Zhang BingwuFrom: Zhang Bingwu <[email protected]>
If INSTALL_PATH is not a valid directory, create it, like what modules_install and dtbs_install will do in the same situation.
--- scripts/install.sh | 4 ++++ 1 file changed, 4 insertions(+)
scripts/install.sh +4 -0
@@ -20,6 +20,10 @@ do fi done +if [ "${INSTALL_PATH}" != "" ] && ! [ -e "${INSTALL_PATH}" ]; then + mkdir -p "${INSTALL_PATH}" +fi + # User/arch may have a custom install script for file in "${HOME}/bin/${INSTALLKERNEL}" \ "/sbin/${INSTALLKERNEL}" \
Signature · 1 line
2.43.0
Re: [PATCH 2/2] kbuild: Create INSTALL_PATH directory if it does not exist
Re: [PATCH 2/2] kbuild: Create INSTALL_PATH directory if it does not exist
In reply to Zhang BingwuQuoted 16 lines · Zhang Bingwu
From: Zhang Bingwu <[email protected]>
If
INSTALL_PATHis not a valid directory, create it, like whatmodules_installanddtbs_installwill do in the same situation.Signed-off-by Zhang Bingwu <[email protected]>--- scripts/install.sh | 4 ++++ 1 file changed, 4 insertions(+)scripts/install.sh +0
-0
scripts/install.sh do · line 23
Quoted 4 lines
scripts/install.sh +1
-0@@ -20,6 +20,10 @@ do fi done +if [ "${INSTALL_PATH}" != "" ] && ! [ -e "${INSTALL_PATH}" ]; then
I changed the first check to [ -n "${INSTALL_PATH}" ] Applied to linux-kbuild. Thanks!
Quoted 9 lines
scripts/install.sh +3
-1+ mkdir -p "${INSTALL_PATH}" +fi + # User/arch may have a custom install script for file in "${HOME}/bin/${INSTALLKERNEL}" \ "/sbin/${INSTALLKERNEL}" \ --2.43.0
Signature · 2 lines
Best Regards Masahiro Yamada