All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts: add generic install.sh
@ 2021-08-24 16:50 Masahiro Yamada
  2021-08-25 20:20 ` Nicolas Schier
  0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2021-08-24 16:50 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel

Many architectures has a similar install.sh script.

The first half is really generic; ensures the kernel image and the map
file exist, then invokes ~/bin/${INSTALLKERNEL} or /sbin/${INSTALLKERNEL}
if available.

The second half is kind of arch-specific. It just copies the kernel image
and map file to the destination, but the code is slightly different.
(Maybe, this part can be consolidated as well if we want).

This patch factors out the generic part into scripts/install.sh, which
will architectures to drop the duplicated code.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 Makefile           |  8 ++++++++
 scripts/install.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)
 create mode 100755 scripts/install.sh

diff --git a/Makefile b/Makefile
index 185ce47d6734..725eadc4fcb8 100644
--- a/Makefile
+++ b/Makefile
@@ -1325,6 +1325,14 @@ scripts_unifdef: scripts_basic
 
 install: sub_make_done :=
 
+# Install $(KBUILD_IMAGE) by default.
+# If necessary, override install-image per target.
+install-image = $(KBUILD_IMAGE)
+
+quiet_cmd_install = INSTALL $(INSTALL_PATH)
+      cmd_install = scripts/install.sh $(KERNELRELEASE) $(install-image) \
+			System.map "$(INSTALL_PATH)"
+
 # ---------------------------------------------------------------------------
 # Tools
 
diff --git a/scripts/install.sh b/scripts/install.sh
new file mode 100755
index 000000000000..6ac0e0c0f078
--- /dev/null
+++ b/scripts/install.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# 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
+#
+# 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 >&2
+		echo >&2 " *** Missing file: $1"
+		echo >&2 ' *** You need to run "make" before "make install".'
+		echo >&2
+		exit 1
+	fi
+}
+
+# Make sure the files actually exist
+verify "$2"
+verify "$3"
+
+# User/arch may have a custom install script
+
+for script in "~/bin/${INSTALLKERNEL}" "/sbin/${INSTALLKERNEL}" \
+		"arch/${SRCARCH}/install.sh" "arch/${SRCARCH}/boot/install.sh"
+do
+	if [ -x "${script}" ]; then
+		exec "${script}" "$@"
+	fi
+done
+
+echo "No install script found" >&2
+exit 1
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scripts: add generic install.sh
  2021-08-24 16:50 [PATCH] scripts: add generic install.sh Masahiro Yamada
@ 2021-08-25 20:20 ` Nicolas Schier
  2021-08-27 15:14   ` Masahiro Yamada
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Schier @ 2021-08-25 20:20 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: linux-kbuild, Michal Marek, linux-kernel

On Wed, 25 Aug 2021 01:50:24 +0900 Masahiro Yamada wrote:
> Many architectures has a similar install.sh script.
> 
> The first half is really generic; ensures the kernel image and the map
> file exist, then invokes ~/bin/${INSTALLKERNEL} or /sbin/${INSTALLKERNEL}
> if available.
> 
> The second half is kind of arch-specific. It just copies the kernel image
> and map file to the destination, but the code is slightly different.
> (Maybe, this part can be consolidated as well if we want).
> 
> This patch factors out the generic part into scripts/install.sh, which
> will architectures to drop the duplicated code.
      ^
I am afraid, a word is missing here, e.g.:
... which will allow architectures to drop ...?

> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  Makefile           |  8 ++++++++
>  scripts/install.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 51 insertions(+)
>  create mode 100755 scripts/install.sh
> 
> diff --git a/Makefile b/Makefile
> index 185ce47d6734..725eadc4fcb8 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1325,6 +1325,14 @@ scripts_unifdef: scripts_basic
>  
>  install: sub_make_done :=
>  
> +# Install $(KBUILD_IMAGE) by default.
> +# If necessary, override install-image per target.
> +install-image = $(KBUILD_IMAGE)
> +
> +quiet_cmd_install = INSTALL $(INSTALL_PATH)
> +      cmd_install = scripts/install.sh $(KERNELRELEASE) $(install-image) \
> +			System.map "$(INSTALL_PATH)"
> +
>  # ---------------------------------------------------------------------------
>  # Tools
>  
> diff --git a/scripts/install.sh b/scripts/install.sh
> new file mode 100755
> index 000000000000..6ac0e0c0f078
> --- /dev/null
> +++ b/scripts/install.sh
> @@ -0,0 +1,43 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# 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
> +#
> +# 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 >&2
> +		echo >&2 " *** Missing file: $1"
> +		echo >&2 ' *** You need to run "make" before "make install".'
> +		echo >&2
> +		exit 1
> +	fi
> +}
> +
> +# Make sure the files actually exist
> +verify "$2"
> +verify "$3"
> +
> +# User/arch may have a custom install script
> +
> +for script in "~/bin/${INSTALLKERNEL}" "/sbin/${INSTALLKERNEL}" \

Quoted ~ will not be expanded.  Either you need to put the leading ~/ 
before the quotes, or replace it by ${HOME}.

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

> +		"arch/${SRCARCH}/install.sh" "arch/${SRCARCH}/boot/install.sh"
> +do
> +	if [ -x "${script}" ]; then
> +		exec "${script}" "$@"
> +	fi
> +done
> +
> +echo "No install script found" >&2
> +exit 1
> -- 
> 2.30.2
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scripts: add generic install.sh
  2021-08-25 20:20 ` Nicolas Schier
@ 2021-08-27 15:14   ` Masahiro Yamada
  0 siblings, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2021-08-27 15:14 UTC (permalink / raw)
  To: nicolas
  Cc: Linux Kbuild mailing list, Michal Marek, Linux Kernel Mailing List

On Thu, Aug 26, 2021 at 5:25 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> On Wed, 25 Aug 2021 01:50:24 +0900 Masahiro Yamada wrote:
> > Many architectures has a similar install.sh script.
> >
> > The first half is really generic; ensures the kernel image and the map
> > file exist, then invokes ~/bin/${INSTALLKERNEL} or /sbin/${INSTALLKERNEL}
> > if available.
> >
> > The second half is kind of arch-specific. It just copies the kernel image
> > and map file to the destination, but the code is slightly different.
> > (Maybe, this part can be consolidated as well if we want).
> >
> > This patch factors out the generic part into scripts/install.sh, which
> > will architectures to drop the duplicated code.
>       ^
> I am afraid, a word is missing here, e.g.:
> ... which will allow architectures to drop ...?

Yes, I meant "will allow architectures to ..."
I just noticed after the submission.



> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  Makefile           |  8 ++++++++
> >  scripts/install.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 51 insertions(+)
> >  create mode 100755 scripts/install.sh
> >
> > diff --git a/Makefile b/Makefile
> > index 185ce47d6734..725eadc4fcb8 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1325,6 +1325,14 @@ scripts_unifdef: scripts_basic
> >
> >  install: sub_make_done :=
> >
> > +# Install $(KBUILD_IMAGE) by default.
> > +# If necessary, override install-image per target.
> > +install-image = $(KBUILD_IMAGE)
> > +
> > +quiet_cmd_install = INSTALL $(INSTALL_PATH)
> > +      cmd_install = scripts/install.sh $(KERNELRELEASE) $(install-image) \
> > +                     System.map "$(INSTALL_PATH)"
> > +
> >  # ---------------------------------------------------------------------------
> >  # Tools
> >
> > diff --git a/scripts/install.sh b/scripts/install.sh
> > new file mode 100755
> > index 000000000000..6ac0e0c0f078
> > --- /dev/null
> > +++ b/scripts/install.sh
> > @@ -0,0 +1,43 @@
> > +#!/bin/sh
> > +# SPDX-License-Identifier: GPL-2.0-only
> > +#
> > +# 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
> > +#
> > +# 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 >&2
> > +             echo >&2 " *** Missing file: $1"
> > +             echo >&2 ' *** You need to run "make" before "make install".'
> > +             echo >&2
> > +             exit 1
> > +     fi
> > +}
> > +
> > +# Make sure the files actually exist
> > +verify "$2"
> > +verify "$3"
> > +
> > +# User/arch may have a custom install script
> > +
> > +for script in "~/bin/${INSTALLKERNEL}" "/sbin/${INSTALLKERNEL}" \
>
> Quoted ~ will not be expanded.  Either you need to put the leading ~/
> before the quotes, or replace it by ${HOME}.

A good catch, thank you.




>
> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
>
> > +             "arch/${SRCARCH}/install.sh" "arch/${SRCARCH}/boot/install.sh"
> > +do
> > +     if [ -x "${script}" ]; then
> > +             exec "${script}" "$@"
> > +     fi
> > +done
> > +
> > +echo "No install script found" >&2
> > +exit 1
> > --
> > 2.30.2
> >



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-27 15:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 16:50 [PATCH] scripts: add generic install.sh Masahiro Yamada
2021-08-25 20:20 ` Nicolas Schier
2021-08-27 15:14   ` Masahiro Yamada

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.