Skip to contentSkip to conversation

LoongArch/build: Using a generic scripts/install.sh in `make install`

PATCH In review Youling Tang 4 participants 9 messages Apr 21, 2025 LoongArch

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 LoongArch/build: Using a generic scripts/install.sh in `make install`

From: Youling Tang <[email protected]>

Use the generic script/install.sh to perform the make install operation. This will automatically generate the initrd file and modify grub.cfg without manual intervention (The previous image and System.map will also be generated), similar to other architectures.

---
 arch/loongarch/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/loongarch/Makefile +1 -3
index 0304eabbe606..64bdb52ddf7c 100644
@@ -181,9 +181,7 @@ vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux
 	$(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@
 
 install:
-	$(Q)install -D -m 755 $(KBUILD_IMAGE) $(INSTALL_PATH)/$(image-name-y)-$(KERNELRELEASE)
-	$(Q)install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE)
-	$(Q)install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE)
+	$(call cmd,install)
 
 define archhelp
 	echo '  install              - install kernel into $(INSTALL_PATH)'
Signature · 1 line
2.38.1
#1 lore raw

PATCH 2/3 LoongArch/build: Add fallback install.sh

From: Youling Tang <[email protected]>

As specified in scripts/install.sh, the priority order is as follows (from highest to lowest):
~/bin/installkernel
/sbin/installkernel arch/loongarch/boot/install.sh

Fallback to default install.sh if installkernel not found.

---
 arch/loongarch/boot/install.sh | 44 ++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100755 arch/loongarch/boot/install.sh
arch/loongarch/boot/install.sh new file +44 -0
new file mode 100755
index 000000000000..c97f611ca913
@@ -0,0 +1,44 @@
+#!/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
+# Adapted from code in arch/i386/boot/install.sh by Russell King
+#
+# "make install" script for the RISC-V Linux port
+#
+# Arguments:
+#   $1 - kernel version
+#   $2 - kernel image file
+#   $3 - kernel map file
+#   $4 - default install path (blank if root directory)
+
+set -e
+
+case "${2##*/}" in
+# Compressed install
+vmlinuz.efi)
+  echo "Installing compressed kernel"
+  base=vmlinuz
+  ;;
+# Normal install
+*)
+  echo "Installing normal kernel"
+  base=vmlinux
+  ;;
+esac
+
+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
Signature · 1 line
2.38.1
#5 lore raw

PATCH 3/3 LoongArch: Add some annotations in archhelp

In reply to Youling Tang

From: Youling Tang <[email protected]>

- Add annotations to the kernel image.
- Modify the annotations of insatll.

---
 arch/loongarch/Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/loongarch/Makefile +6 -1
index 64bdb52ddf7c..5711fe0efa76 100644
@@ -184,6 +184,11 @@ install:
 	$(call cmd,install)
 
 define archhelp
-	echo '  install              - install kernel into $(INSTALL_PATH)'
+	echo '  vmlinux.elf          - Uncompressed ELF kernel image (arch/loongarch/boot/vmlinux.elf)'
+	echo '  vmlinux.efi          - Uncompressed EFI kernel image (arch/loongarch/boot/vmlinux.efi)'
+	echo '  vmlinuz.efi          - Compressed EFI kernel image (arch/loongarch/boot/vmlinuz.efi)'
+	echo '                         Default when CONFIG_EFI_ZBOOT=y'
+	echo '  install              - Install kernel using (your) ~/bin/$(INSTALLKERNEL) or (distribution)'
+	echo '                         /sbin/$(INSTALLKERNEL) or install.sh to $$(INSTALL_PATH)'
 	echo
 endef
Signature · 1 line
2.38.1
#2 lore raw

Re: [PATCH 2/3] LoongArch/build: Add fallback install.sh

In reply to Youling Tang
Quoted 30 lines · Youling Tang

From: Youling Tang <[email protected]>

As specified in scripts/install.sh, the priority order is as follows (from highest to lowest):
  ~/bin/installkernel
  /sbin/installkernel arch/loongarch/boot/install.sh

Fallback to default install.sh if installkernel not found.

---
 arch/loongarch/boot/install.sh | 44
++++++++++++++++++++++++++++++++++

 1 file changed, 44 insertions(+)

 create mode 100755 arch/loongarch/boot/install.sh

arch/loongarch/boot/install.sh new file +3 -0
new file mode 100755
index 000000000000..c97f611ca913
@@ -0,0 +1,44 @@
+#!/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

arch/loongarch/boot/install.sh line 12

Quoted 8 lines
arch/loongarch/boot/install.sh new file +8 -0
+# 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 RISC-V Linux port
                                   ^^^^^^

Pasto here.

Quoted 32 lines
arch/loongarch/boot/install.sh new file +32 -0
+#
+# Arguments:
+#   $1 - kernel version
+#   $2 - kernel image file
+#   $3 - kernel map file
+#   $4 - default install path (blank if root directory)
+
+set -e
+
+case "${2##*/}" in
+# Compressed install
+vmlinuz.efi)
+  echo "Installing compressed kernel"
+  base=vmlinuz
+  ;;
+# Normal install
+*)
+  echo "Installing normal kernel"
+  base=vmlinux
+  ;;
+esac
+
+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
Signature · 2 lines
Xi Ruoyao <[email protected]>
School of Aerospace Science and Technology, Xidian University
#3 lore raw

Re: [PATCH 2/3] LoongArch/build: Add fallback install.sh

Hi, Ruoyao

Quoted 41 lines · Xi Ruoyao
Quoted 30 lines · Youling Tang

From: Youling Tang <[email protected]>

As specified in scripts/install.sh, the priority order is as follows (from highest to lowest):
  ~/bin/installkernel
  /sbin/installkernel arch/loongarch/boot/install.sh

Fallback to default install.sh if installkernel not found.

---
  arch/loongarch/boot/install.sh | 44
++++++++++++++++++++++++++++++++++
  1 file changed, 44 insertions(+)

 create mode 100755 arch/loongarch/boot/install.sh

arch/loongarch/boot/install.sh new file +3 -0
new file mode 100755
index 000000000000..c97f611ca913
@@ -0,0 +1,44 @@
+#!/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

arch/loongarch/boot/install.sh line 12

Quoted 8 lines
arch/loongarch/boot/install.sh new file +8 -0
+# 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 RISC-V Linux port
                                    ^^^^^^
Quoted 1 line

Pasto here.

My oversight, I'll revise it later.

Thanks,
Youling.

maintainer
#8 lore raw
In reply to Youling Tang

Hi, Youling,

I think the 2nd patch really should be the 1st one, in case there is no "installkernel" in the system.
And you can remove "build" in the title.

Huacai

Quoted 31 lines · Youling Tang

From: Youling Tang <[email protected]>

Use the generic script/install.sh to perform the make install operation. This will automatically generate the initrd file and modify grub.cfg without manual intervention (The previous image and System.map will also be generated), similar to other architectures.

---
 arch/loongarch/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/loongarch/Makefile +1 -4
index 0304eabbe606..64bdb52ddf7c 100644
@@ -181,9 +181,7 @@ vmlinux.elf vmlinux.efi vmlinuz.efi: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(bootvars-y) $(boot)/$@
 
 install:
-       $(Q)install -D -m 755 $(KBUILD_IMAGE) $(INSTALL_PATH)/$(image-name-y)-$(KERNELRELEASE)
-       $(Q)install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE)
-       $(Q)install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE)
+       $(call cmd,install)
 
 define archhelp
        echo '  install              - install kernel into $(INSTALL_PATH)'
--

2.38.1

maintainer
#4 lore raw

Re: [PATCH 2/3] LoongArch/build: Add fallback install.sh

In reply to Youling Tang

Hi, Youling,

Quoted 42 lines · Youling Tang

From: Youling Tang <[email protected]>

As specified in scripts/install.sh, the priority order is as follows (from highest to lowest):
~/bin/installkernel
/sbin/installkernel arch/loongarch/boot/install.sh

Fallback to default install.sh if installkernel not found.

---
 arch/loongarch/boot/install.sh | 44 ++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100755 arch/loongarch/boot/install.sh
arch/loongarch/boot/install.sh new file +19 -0
new file mode 100755
index 000000000000..c97f611ca913
@@ -0,0 +1,44 @@
+#!/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
+# Adapted from code in arch/i386/boot/install.sh by Russell King
+#
+# "make install" script for the RISC-V Linux port
+#
+# Arguments:
+#   $1 - kernel version
+#   $2 - kernel image file
+#   $3 - kernel map file
+#   $4 - default install path (blank if root directory)
+

arch/loongarch/boot/install.sh line 29

Quoted 10 lines
arch/loongarch/boot/install.sh new file +10 -0
+set -e
+
+case "${2##*/}" in
+# Compressed install
+vmlinuz.efi)
+  echo "Installing compressed kernel"
+  base=vmlinuz
+  ;;
+# Normal install
+*)

I suggest explicitly using vmlinux.elf and vmlinux.efi here, and print a warning message for *, because we may add more kernel image types in future.

Huacai

Quoted 19 lines
arch/loongarch/boot/install.sh new file +15 -1
+  echo "Installing normal kernel"
+  base=vmlinux
+  ;;
+esac
+
+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.38.1

maintainer
#6 lore raw

Re: [PATCH 3/3] LoongArch: Add some annotations in archhelp

In reply to Youling Tang

Hi, Youling,

Quoted 16 lines · Youling Tang

From: Youling Tang <[email protected]>

- Add annotations to the kernel image.
- Modify the annotations of insatll.

---
 arch/loongarch/Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
arch/loongarch/Makefile +0 -0
index 64bdb52ddf7c..5711fe0efa76 100644

arch/loongarch/Makefile install: · line 188

Quoted 6 lines
arch/loongarch/Makefile +2 -1
@@ -184,6 +184,11 @@ install:
        $(call cmd,install)
 
 define archhelp
-       echo '  install              - install kernel into $(INSTALL_PATH)'
+       echo '  vmlinux.elf          - Uncompressed ELF kernel image (arch/loongarch/boot/vmlinux.elf)'
+       echo '  vmlinux.efi          - Uncompressed EFI kernel image (arch/loongarch/boot/vmlinux.efi)'

Replace "Uncompressed" with "Normal"? Because you use "normal" in the 2nd patch.

Huacai

Quoted 10 lines
arch/loongarch/Makefile +4 -1
+       echo '  vmlinuz.efi          - Compressed EFI kernel image (arch/loongarch/boot/vmlinuz.efi)'
+       echo '                         Default when CONFIG_EFI_ZBOOT=y'
+       echo '  install              - Install kernel using (your) ~/bin/$(INSTALLKERNEL) or (distribution)'
+       echo '                         /sbin/$(INSTALLKERNEL) or install.sh to $$(INSTALL_PATH)'
        echo
 endef
--

2.38.1

#7 lore raw

Re: [PATCH 3/3] LoongArch: Add some annotations in archhelp

Hi Huacai and Youling,

Quoted 21 lines · Huacai Chen

Hi, Youling,

Quoted 18 lines · Youling Tang

From: Youling Tang <[email protected]>

- Add annotations to the kernel image.
- Modify the annotations of insatll.

---
  arch/loongarch/Makefile | 7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)
arch/loongarch/Makefile +0 -0
index 64bdb52ddf7c..5711fe0efa76 100644
@@ -184,6 +184,11 @@ install:
         $(call cmd,install)
 
Quoted 5 lines

arch/loongarch/Makefile install: · line 188

Quoted 4 lines
arch/loongarch/Makefile +2 -1
  define archhelp
-       echo '  install              - install kernel into $(INSTALL_PATH)'
+       echo '  vmlinux.elf          - Uncompressed ELF kernel image (arch/loongarch/boot/vmlinux.elf)'
+       echo '  vmlinux.efi          - Uncompressed EFI kernel image (arch/loongarch/boot/vmlinux.efi)'

Replace "Uncompressed" with "Normal"? Because you use "normal" in the 2nd patch.

My two cents would be to use "uncompressed."

"Normal" is purely subjective - unless we do expect all users to use vmlinux and not vmlinuz, in which case we would need to give extra explanation for how that is normal. AFAIK there is no such expectation for LoongArch.

Best Regards,
Mingcong Bai

Quoted 14 lines

Huacai

Quoted 10 lines
arch/loongarch/Makefile +4 -1
+       echo '  vmlinuz.efi          - Compressed EFI kernel image (arch/loongarch/boot/vmlinuz.efi)'
+       echo '                         Default when CONFIG_EFI_ZBOOT=y'
+       echo '  install              - Install kernel using (your) ~/bin/$(INSTALLKERNEL) or (distribution)'
+       echo '                         /sbin/$(INSTALLKERNEL) or install.sh to $$(INSTALL_PATH)'
         echo
  endef
--

2.38.1