grubby-bls: allow to add many BLS entries for the same kernel image
The BLS files name convention used is ${MACHINE_ID}-${KERNEL_VERSION}.conf but this means that there can only be a single entry for a given kernel. Allow the grubby wrapper to add many entries for the same kernel image, since the old grubby tool was able to do that. To differentiate from the original BLS entry and to specify that it's a customized entry, add a [[:digit:]]~custom suffix after the kernel version number. This will also sort the custom entries before the original entry, that's also what the old grubby tool did. Resolves: rhbz#1634752 Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
This commit is contained in:
parent
1c345197a4
commit
9a80bb6f8e
35
grubby-bls
35
grubby-bls
@ -260,6 +260,35 @@ remove_bls_fragment() {
|
|||||||
update_grubcfg
|
update_grubcfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_custom_bls_filename() {
|
||||||
|
local kernelver=$1
|
||||||
|
local bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
|
||||||
|
count=0
|
||||||
|
local -a files
|
||||||
|
local IFS=$'\n'
|
||||||
|
|
||||||
|
prefix="${bls_target%%.conf}"
|
||||||
|
prefix="${bls_target%%${arch}}"
|
||||||
|
prefix="${prefix%.*}"
|
||||||
|
|
||||||
|
last=($(for bls in ${prefix}.*~custom*.conf ; do
|
||||||
|
if ! [[ -e "${bls}" ]] ; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
bls="${bls##${prefix}.}"
|
||||||
|
bls="${bls%%~custom*}"
|
||||||
|
echo "${bls}"
|
||||||
|
done | tail -n1)) || :
|
||||||
|
|
||||||
|
if [[ -z $last ]]; then
|
||||||
|
last="0"
|
||||||
|
else
|
||||||
|
last=$((last+1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${bls_target}" | sed -e "s!${prefix}!${prefix}.${last}~custom!"
|
||||||
|
}
|
||||||
|
|
||||||
add_bls_fragment() {
|
add_bls_fragment() {
|
||||||
local kernel="$1" && shift
|
local kernel="$1" && shift
|
||||||
local title="$1" && shift
|
local title="$1" && shift
|
||||||
@ -288,6 +317,12 @@ add_bls_fragment() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
|
bls_target="${blsdir}/${MACHINE_ID}-${kernelver}.conf"
|
||||||
|
|
||||||
|
if [[ -e ${bls_target} ]]; then
|
||||||
|
bls_target="$(get_custom_bls_filename "${kernelver}")"
|
||||||
|
print_info "An entry for kernel ${kernelver} already exists, adding ${bls_target}"
|
||||||
|
fi
|
||||||
|
|
||||||
kernel_dir="/lib/modules/${kernelver}"
|
kernel_dir="/lib/modules/${kernelver}"
|
||||||
if [[ -f "${kernel_dir}/bls.conf" ]]; then
|
if [[ -f "${kernel_dir}/bls.conf" ]]; then
|
||||||
cp -aT "${kernel_dir}/bls.conf" "${bls_target}" || exit $?
|
cp -aT "${kernel_dir}/bls.conf" "${bls_target}" || exit $?
|
||||||
|
Loading…
Reference in New Issue
Block a user