All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Increase flexibility of kernel naming, allow non-versioned kernels.
@ 2012-04-29  4:46 Mike Gilbert
  2012-04-29 16:28 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Gilbert @ 2012-04-29  4:46 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Robin Johnson


[-- Attachment #1.1: Type: text/plain, Size: 1105 bytes --]

I am relaying a patch by Robin Johnson, one of the core infrastructure
staff at Gentoo Linux. In the process of building some Gentoo servers
utilizing GRUB 2, he has made some changes to 10_linux that should make
grub-mkconfig "out of the box" for additional users.

I did a little work to clean up the indentation and wrote a proper
changelog. Credit should go to him.

Here is his description:

Increase flexibility of kernel naming, allow non-versioned kernels.

The block that tried to find the kernels was getting unweidly long, as
was not
easily customizable by users or distributors. Refactor to introduce a new
variable, GRUB_KERNEL_GLOB, that allows complete control over the naming
used
to search for kernel binaries.

Add 'bzImage' to the list of default names to support more distribution
naming
variants.

Adjust the default set of globs to look for unversioned kernels before
versioned kernels, to find symlinked kernel names.

Also apply similar logic to to initramfs.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>

--
Take 2: Added initramfs logic.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: grub-2.00-kernel-naming-flexibility.patch --]
[-- Type: text/x-patch; name="grub-2.00-kernel-naming-flexibility.patch", Size: 6015 bytes --]

Increase flexibility of kernel naming, allow non-versioned kernels.

The block that tried to find the kernels was getting unweidly long, as was not
easily customizable by users or distributors. Refactor to introduce a new
variable, GRUB_KERNEL_GLOB, that allows complete control over the naming used
to search for kernel binaries.

Add 'bzImage' to the list of default names to support more distribution naming
variants.

Adjust the default set of globs to look for unversioned kernels before
versioned kernels, to find symlinked kernel names.

Also apply similar logic to to initramfs.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>

--
Take 2: Added initramfs logic.

=== modified file 'ChangeLog'
--- ChangeLog	2012-04-26 18:51:06 +0000
+++ ChangeLog	2012-04-29 04:29:01 +0000
@@ -1,3 +1,19 @@
+2102-04-29  Robin H. Johnson  <robbat2@gentoo.org>
+
+	Increase flexibility of kernel naming, allow non-versioned kernels.
+
+	Introduce GRUB_KERNEL_GLOB variable to allow customization by
+	distrubutions or users.
+
+	* docs/grub.texi: Document GRUB_KERNEL_GLOB variable.
+	* util/grub-mkconfig.in: Export GRUB_KERNEL_GLOB variable.
+	* util/grub.d/10_linux.in: Refactor kernel detection to utilize
+	GRUB_KERNEL_GLOB variable. Add bzImage to the list of default names to
+	support more distribution naming variants. Adjust the default set of
+	globs to look for unversioned kernels before versioned kernels, to
+	find symlinked kernel names. Apply similar logic to initramfs and
+	config file detection.
+
 2012-04-26  Vladimir Serbinenko  <phcoder@gmail.com>
 
 	* grub-core/term/ieee1275/console.c (grub_console_dimensions): Use 80x24

=== modified file 'docs/grub.texi'
--- docs/grub.texi	2012-03-27 23:37:00 +0000
+++ docs/grub.texi	2012-04-29 03:25:10 +0000
@@ -1288,6 +1288,10 @@
 Each module will be loaded as early as possible, at the start of
 @file{grub.cfg}.
 
+@item GRUB_KERNEL_GLOB
+This is a space-seperated list of globs to evaluate while looking for the names
+of your kernel binaries. Default is platform-specific.
+
 @end table
 
 For more detailed customisation of @command{grub-mkconfig}'s output, you may

=== modified file 'util/grub-mkconfig.in'
--- util/grub-mkconfig.in	2012-04-07 17:49:25 +0000
+++ util/grub-mkconfig.in	2012-04-29 03:25:10 +0000
@@ -216,7 +216,8 @@
   GRUB_INIT_TUNE \
   GRUB_SAVEDEFAULT \
   GRUB_ENABLE_CRYPTODISK \
-  GRUB_BADRAM
+  GRUB_BADRAM \
+  GRUB_KERNEL_GLOB
 
 if test "x${grub_cfg}" != "x"; then
   rm -f "${grub_cfg}.new"

=== modified file 'util/grub.d/10_linux.in'
--- util/grub.d/10_linux.in	2012-04-18 21:25:21 +0000
+++ util/grub.d/10_linux.in	2012-04-29 04:16:51 +0000
@@ -151,16 +151,17 @@
 }
 
 machine=`uname -m`
-case "x$machine" in
-    xi?86 | xx86_64)
-	list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do
-                  if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
-              done` ;;
-    *) 
-	list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do
-                  if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi
-	     done` ;;
-esac
+if [ "x$GRUB_KERNEL_GLOB" = "x" ]; then
+    case "x$machine" in
+        xi?86 | xx86_64) GRUB_KERNEL_GLOB="/boot/vmlinuz /vmlinuz /boot/kernel /boot/bzImage" ;;
+        *) GRUB_KERNEL_GLOB="/boot/vmlinuz /boot/vmlinux /boot/kernel /boot/bzImage /vmlinuz /vmlinux" ;;
+    esac
+    list="$GRUB_KERNEL_GLOB"
+    for l in $list ; do list="${list} ${l}-*" ; done
+else
+    list="$GRUB_KERNEL_GLOB"
+fi
+list=$(eval "for i in ${list} ; do if grub_file_is_not_garbage \"\$i\" ; then echo -n \"\$i \" ; fi ; done")
 
 case "$machine" in
     i?86) GENKERNEL_ARCH="x86" ;;
@@ -187,18 +188,27 @@
   dirname=`dirname $linux`
   rel_dirname=`make_system_path_relative_to_its_root $dirname`
   version=`echo $basename | sed -e "s,^[^0-9]*-,,g"`
+  [ "x$version" == "x$basename" ] && version=
   alt_version=`echo $version | sed -e "s,\.old$,,g"`
   linux_root_device_thisversion="${LINUX_ROOT_DEVICE}"
 
   initrd=
-  for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
-	   "initrd-${version}" "initramfs-${version}.img" \
-	   "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
-	   "initrd-${alt_version}" "initramfs-${alt_version}.img" \
-	   "initramfs-genkernel-${version}" \
-	   "initramfs-genkernel-${alt_version}" \
-	   "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
-	   "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do
+  set --
+  if [ "x$version" = "x" ]; then
+      set -- "initrd.img" "initrd.gz" "initrd" "initramfs.img" "initramfs" \
+	     "initramfs-genkernel" "initramfs-genkernel-${GENKERNEL_ARCH}"
+  fi
+  set -- "$@" \
+    "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \
+    "initrd-${version}" "initramfs-${version}.img" \
+    "initrd.img-${alt_version}" "initrd-${alt_version}.img" \
+    "initrd-${alt_version}" "initramfs-${alt_version}.img" \
+    "initramfs-${version}" "initramfs-${alt_version}" \
+    "initramfs-genkernel-${version}" \
+    "initramfs-genkernel-${alt_version}" \
+    "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \
+    "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"
+  for i in "$@" ; do
     if test -e "${dirname}/${i}" ; then
       initrd="$i"
       break
@@ -206,12 +216,20 @@
   done
 
   config=
-  for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
+  set --
+  if [ "x$version" = "x" ]; then
+	  set -- "${dirname}/config"
+  fi
+  set -- "$@" "${dirname}/config-${version}" \
+	      "${dirname}/config-${alt_version}" \
+	      "/etc/kernels/kernel-config-${version}"
+  for i in "$@"; do
     if test -e "${i}" ; then
       config="${i}"
       break
     fi
   done
+  set --
 
   initramfs=
   if test -n "${config}" ; then


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

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

* Re: [PATCH] Increase flexibility of kernel naming, allow non-versioned kernels.
  2012-04-29  4:46 [PATCH] Increase flexibility of kernel naming, allow non-versioned kernels Mike Gilbert
@ 2012-04-29 16:28 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2012-04-29 20:07   ` Mike Gilbert
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-04-29 16:28 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1748 bytes --]

On 29.04.2012 06:46, Mike Gilbert wrote:
> I am relaying a patch by Robin Johnson, one of the core infrastructure
> staff at Gentoo Linux. In the process of building some Gentoo servers
> utilizing GRUB 2, he has made some changes to 10_linux that should make
> grub-mkconfig "out of the box" for additional users.
>
> I did a little work to clean up the indentation and wrote a proper
> changelog. Credit should go to him.
>
> Here is his description:
>
> Increase flexibility of kernel naming, allow non-versioned kernels.
> The block that tried to find the kernels was getting unweidly long, as
> was not
> easily customizable by users or distributors. Refactor to introduce a new
> variable, GRUB_KERNEL_GLOB, that allows complete control over the naming
> used
> to search for kernel binaries.
It was well structured and its length is solely due to distros using
multiple names. We can't make it shorter and this patch surely didn't.
Also it looks like it actually degraded compatibility on POSIX systems.
I don't consider that being able to customise the kernel naming is of
any advantage. Saying otherwise is like saying "let's make location of
/etc/passwd customizable". Some objects just have to be named as given.
I don't see any advantage to renaming kernels, especially given that you
can change versionstring as you see fit.
> Add 'bzImage' to the list of default names to support more distribution
> naming
> variants.
>
> Adjust the default set of globs to look for unversioned kernels before
> versioned kernels, to find symlinked kernel names.
Additionally empty version would probably result in some quirks not
addressed in this patch.

-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

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

* Re: [PATCH] Increase flexibility of kernel naming, allow non-versioned kernels.
  2012-04-29 16:28 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2012-04-29 20:07   ` Mike Gilbert
  2012-05-01 23:17     ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Gilbert @ 2012-04-29 20:07 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 3045 bytes --]

On 04/29/2012 12:28 PM, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> On 29.04.2012 06:46, Mike Gilbert wrote:
>> I am relaying a patch by Robin Johnson, one of the core infrastructure
>> staff at Gentoo Linux. In the process of building some Gentoo servers
>> utilizing GRUB 2, he has made some changes to 10_linux that should make
>> grub-mkconfig "out of the box" for additional users.
>>
>> I did a little work to clean up the indentation and wrote a proper
>> changelog. Credit should go to him.
>>
>> Here is his description:
>>
>> Increase flexibility of kernel naming, allow non-versioned kernels.
>> The block that tried to find the kernels was getting unweidly long, as
>> was not
>> easily customizable by users or distributors. Refactor to introduce a new
>> variable, GRUB_KERNEL_GLOB, that allows complete control over the naming
>> used
>> to search for kernel binaries.
> It was well structured and its length is solely due to distros using
> multiple names. We can't make it shorter and this patch surely didn't.

Right. I think the intent is not to make it "shorter", just slightly
easier to manage.

> Also it looks like it actually degraded compatibility on POSIX systems.

Can you be more specific? I did not spot anything obviously incompatible
with POSIX, but I'm certainly not an expert on the subject.

> I don't consider that being able to customise the kernel naming is of
> any advantage. Saying otherwise is like saying "let's make location of
> /etc/passwd customizable". Some objects just have to be named as given.

I do not follow that analogy. In contrast to /etc/passwd, the only
program on the system that actually needs to know the path to the kernel
is the boot loader. So long as the boot loader can find it, you can put
the kernel anywhere, and name it anything.

> I don't see any advantage to renaming kernels, especially given that you
> can change versionstring as you see fit.

I agree that there is no "advantage" to these various naming schemes; it
is just something that people have done over the years due to the lack
of a standard back in the day.

We have many users on Gentoo who compile their kernel and then manually
copy the resulting bzImage to /boot with whatever name they please. This
patch is an attempt GRUB compatible with that reality.

I am respectfully asking you to merge it to save myself some work in
re-basing a disto-specific patch, or my users from having to change
their behavior due to a somewhat rigid boot loader configuration file
generator.

>> Add 'bzImage' to the list of default names to support more distribution
>> naming
>> variants.
>>
>> Adjust the default set of globs to look for unversioned kernels before
>> versioned kernels, to find symlinked kernel names.
> Additionally empty version would probably result in some quirks not
> addressed in this patch.

Could you expand on this? I do not have the knowledge you do in this
area, so I cannot predict all possible problems.

Thanks.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

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

* Re: [PATCH] Increase flexibility of kernel naming, allow non-versioned kernels.
  2012-04-29 20:07   ` Mike Gilbert
@ 2012-05-01 23:17     ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; 4+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-05-01 23:17 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 4168 bytes --]

On 29.04.2012 22:07, Mike Gilbert wrote:
> On 04/29/2012 12:28 PM, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
>> On 29.04.2012 06:46, Mike Gilbert wrote:
>>> I am relaying a patch by Robin Johnson, one of the core infrastructure
>>> staff at Gentoo Linux. In the process of building some Gentoo servers
>>> utilizing GRUB 2, he has made some changes to 10_linux that should make
>>> grub-mkconfig "out of the box" for additional users.
>>>
>>> I did a little work to clean up the indentation and wrote a proper
>>> changelog. Credit should go to him.
>>>
>>> Here is his description:
>>>
>>> Increase flexibility of kernel naming, allow non-versioned kernels.
>>> The block that tried to find the kernels was getting unweidly long, as
>>> was not
>>> easily customizable by users or distributors. Refactor to introduce a new
>>> variable, GRUB_KERNEL_GLOB, that allows complete control over the naming
>>> used
>>> to search for kernel binaries.
>> It was well structured and its length is solely due to distros using
>> multiple names. We can't make it shorter and this patch surely didn't.
> Right. I think the intent is not to make it "shorter", just slightly
> easier to manage.
Well it didn't. So I'll prefer these tossing around to be kept out and
I'll skip discussing them in the rest of this mail.
As for the goal of moving this part out of the script altogether and
making it distro-specific config it's an impossible goal since upstream
version has to be functional on common distros unless distros go out of
their way to make it difficult.
>> I don't consider that being able to customise the kernel naming is of
>> any advantage. Saying otherwise is like saying "let's make location of
>> /etc/passwd customizable". Some objects just have to be named as given.
> I do not follow that analogy. In contrast to /etc/passwd, the only
> program on the system that actually needs to know the path to the kernel
> is the boot loader. So long as the boot loader can find it, you can put
> the kernel anywhere, and name it anything.
Even if it was though, it still creates problem for no benefit.
Also Super GRUB Disk and bootinfoscript both need to find the kernels
and initrds.
>> I don't see any advantage to renaming kernels, especially given that you
>> can change versionstring as you see fit.
> I agree that there is no "advantage" to these various naming schemes; it
> is just something that people have done over the years due to the lack
> of a standard back in the day.
>
> We have many users on Gentoo who compile their kernel and then manually
> copy the resulting bzImage to /boot with whatever name they please. This
> patch is an attempt GRUB compatible with that reality.
>
> I am respectfully asking you to merge it to save myself some work in
> re-basing a disto-specific patch, or my users from having to change
> their behavior due to a somewhat rigid boot loader configuration file
> generator.
I fail to see how "configure your uncommon naming scheme into a config
file" is less annoying than "stick to a common naming scheme". Both
require informing users and both require user action. Sticking to
standard naming scheme has obvious benefits of standardising the
filenames which is especially interesting for tools like os-prober,
bootinfoscript, Super GRUB Disk.
>>> Add 'bzImage' to the list of default names to support more distribution
>>> naming
>>> variants.
>>>
>>> Adjust the default set of globs to look for unversioned kernels before
>>> versioned kernels, to find symlinked kernel names.
>> Additionally empty version would probably result in some quirks not
>> addressed in this patch.
> Could you expand on this? I do not have the knowledge you do in this
> area, so I cannot predict all possible problems.
Off the top of my head: it's used for title, id, initrd name and
sorting. All those would have to be adjusted.
> Thanks.
>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

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

end of thread, other threads:[~2012-05-01 23:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-29  4:46 [PATCH] Increase flexibility of kernel naming, allow non-versioned kernels Mike Gilbert
2012-04-29 16:28 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-29 20:07   ` Mike Gilbert
2012-05-01 23:17     ` Vladimir 'φ-coder/phcoder' Serbinenko

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.