mbox series

[00/20] kbuild: unify the install.sh script usage

Message ID 20210407053419.449796-1-gregkh@linuxfoundation.org (mailing list archive)
Headers show
Series kbuild: unify the install.sh script usage | expand

Message

Greg KH April 7, 2021, 5:33 a.m. UTC
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

Comments

Geert Uytterhoeven April 7, 2021, 7:18 a.m. UTC | #1
Hi Greg,

Thanks for your series!

On Wed, Apr 7, 2021 at 7:34 AM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> 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 -- geert@linux-m68k.org

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
Greg KH April 7, 2021, 7:46 a.m. UTC | #2
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
> <gregkh@linuxfoundation.org> 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
Russell King (Oracle) April 7, 2021, 8:02 a.m. UTC | #3
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
> > <gregkh@linuxfoundation.org> 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.
Greg KH April 7, 2021, 8:07 a.m. UTC | #4
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
> > > <gregkh@linuxfoundation.org> 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
Russell King (Oracle) April 7, 2021, 8:14 a.m. UTC | #5
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
> > > > <gregkh@linuxfoundation.org> 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.
Greg KH April 7, 2021, 8:37 a.m. UTC | #6
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
> > > > > <gregkh@linuxfoundation.org> 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
Masahiro Yamada April 7, 2021, 10:53 a.m. UTC | #7
On Wed, Apr 7, 2021 at 5:37 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> 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
> > > > > > <gregkh@linuxfoundation.org> 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.
Kees Cook April 9, 2021, 3:12 a.m. UTC | #8
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