Generate BootLoaderSpec config fragments

The BootLoaderSpec (BLS) defines a scheme where different bootloaders can
share a format for boot items and a configuration directory that accepts
these common configurations as drop-in files [0].

Generate BLS snippets at build time that can be copied on kernel install,
so bootloaders can parse to create menu entries using this information.

[0]: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/

Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
Peter Jones 2016-12-15 10:34:30 -05:00
parent 9ed1ca87cb
commit 08732ed826
2 changed files with 34 additions and 0 deletions

28
generate_bls_conf.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
set -e
. /etc/os-release
kernelver=$1 && shift
rootfs=$1 && shift
variant=$1 && shift
output="${rootfs}/lib/modules/${kernelver}/bls.conf"
date=$(date -u +%Y%m%d%H%M%S)
if [ "${variant:-5}" = "debug" ]; then
debugname=" with debugging"
else
debugname=""
fi
cat >${output} <<EOF
title ${NAME} (${kernelver}) ${VERSION}${debugname}
linux ${bootprefix}/vmlinuz-${kernelver}
initrd ${bootprefix}/initramfs-${kernelver}.img
options \$kernelopts
id ${ID}-${date}-${kernelver}
grub_users \$grub_users
grub_arg --unrestricted
grub_class kernel${variant}
EOF

View File

@ -464,6 +464,7 @@ Source40: generate_all_configs.sh
Source41: generate_debug_configs.sh Source41: generate_debug_configs.sh
Source42: process_configs.sh Source42: process_configs.sh
Source43: generate_bls_conf.sh
# This file is intentionally left empty in the stock kernel. Its a nicety # This file is intentionally left empty in the stock kernel. Its a nicety
# added for those wanting to do custom rebuilds with altered config opts. # added for those wanting to do custom rebuilds with altered config opts.
@ -1104,6 +1105,7 @@ cp %{SOURCE1000} .
cp %{SOURCE15} . cp %{SOURCE15} .
cp %{SOURCE40} . cp %{SOURCE40} .
cp %{SOURCE41} . cp %{SOURCE41} .
cp %{SOURCE43} .
%if !%{debugbuildsenabled} %if !%{debugbuildsenabled}
# The normal build is a really debug build and the user has explicitly requested # The normal build is a really debug build and the user has explicitly requested
@ -1518,6 +1520,9 @@ BuildKernel() {
# prune junk from kernel-devel # prune junk from kernel-devel
find $RPM_BUILD_ROOT/usr/src/kernels -name ".*.cmd" -exec rm -f {} \; find $RPM_BUILD_ROOT/usr/src/kernels -name ".*.cmd" -exec rm -f {} \;
# build a BLS config for this kernel
./generate_bls_conf.sh "$KernelVer" "$RPM_BUILD_ROOT" "%{?variant}"
} }
### ###
@ -1829,6 +1834,7 @@ fi
/lib/modules/%{KVERREL}%{?3:+%{3}}/build\ /lib/modules/%{KVERREL}%{?3:+%{3}}/build\
/lib/modules/%{KVERREL}%{?3:+%{3}}/source\ /lib/modules/%{KVERREL}%{?3:+%{3}}/source\
/lib/modules/%{KVERREL}%{?3:+%{3}}/updates\ /lib/modules/%{KVERREL}%{?3:+%{3}}/updates\
/lib/modules/%{KVERREL}%{?2:+%{2}}/bls.conf\
%if %{1}\ %if %{1}\
/lib/modules/%{KVERREL}%{?3:+%{3}}/vdso\ /lib/modules/%{KVERREL}%{?3:+%{3}}/vdso\
/etc/ld.so.conf.d/kernel-%{KVERREL}%{?3:+%{3}}.conf\ /etc/ld.so.conf.d/kernel-%{KVERREL}%{?3:+%{3}}.conf\