Merge branch 'c9s' into 'add_sig_check'

# Conflicts:
#   grub2.spec
This commit is contained in:
Marta Lewandowska 2026-07-30 08:23:16 +00:00
commit ffe9734138
2 changed files with 69 additions and 3 deletions

View File

@ -586,7 +586,6 @@ cp docs/grub-dev.info \\\
$RPM_BUILD_ROOT%{_infodir}/%{name}-dev.info \
install -d -m 0700 ${RPM_BUILD_ROOT}%{efi_esp_dir}/ \
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/%{name}/ \
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/loader/entries \
install -d -m 0700 ${RPM_BUILD_ROOT}/boot/%{name}/themes/system \
install -d -m 0700 ${RPM_BUILD_ROOT}%{_sysconfdir}/default \
install -d -m 0700 ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig \
@ -604,7 +603,6 @@ ln -s ../boot/%{name}/grub.cfg \\\
%defattr(-,root,root,-) \
%config(noreplace) %{_sysconfdir}/%{name}.cfg \
%ghost %config(noreplace) %attr(0600,root,root)/boot/%{name}/grub.cfg \
%dir %attr(0700,root,root)/boot/loader/entries \
%attr(0644,root,root) %config(noreplace) /etc/dnf/protected.d/%{name}-%{1}.conf \
%ifarch ppc64le \
%dir %{_libdir}/grub/%{2}/ \
@ -638,7 +636,6 @@ ln -s ../boot/%{name}/grub.cfg \\\
%endif \
%attr(0700,root,root)/boot/%{name}/fonts \
%attr(0700,root,root)/usr/bin/gen_grub_cfgstub \
%dir %attr(0700,root,root)/boot/loader/entries \
%ghost %config(noreplace) %attr(0600,root,root)/boot/%{name}/grub.cfg \
%ghost %config(noreplace) %verify(not mtime) %attr(0700,root,root)%{efi_esp_dir}/grub.cfg \
%config(noreplace) %verify(not size mode md5 mtime) /boot/%{name}/grubenv \

View File

@ -382,6 +382,75 @@ if test -f ${EFI_HOME}/grubenv; then
mv --force ${EFI_HOME}/grubenv ${GRUB_HOME}/grubenv
fi
%if "%{platform}" == "pc"
%posttrans pc
set -eu
set -o pipefail
SYS_FIRMWARE_EFI_DIR=/sys/firmware/efi
BOOT_DIR=/boot
find_grub_devices() {
local boot_device
local component_devs=()
local block_devs=()
# Exit if UEFI system running
if test -d $SYS_FIRMWARE_EFI_DIR ; then
exit 0
fi
# grub2-probe is required for device finding
if ! command -v grub2-probe &>/dev/null; then
exit 0;
fi
# Get block devices where GRUB is located. We assume GRUB is on the same device
# as /boot partition is. In case that device is an md (Multiple Device) device, all
# of the component devices of such a device are considered.
boot_device=$(grub2-probe --target=device $BOOT_DIR)
# Check if a given device is an md (Multiple Device) device
# It is expected that the "mdadm" command is available,
# if it's not it is assumed the device is not an md device.
if command -v mdadm &>/dev/null && \
mdadm --detail --verbose --brief "$boot_device" &> /dev/null; then
out=$(mdadm --detail --verbose --brief "$boot_device")
# output would look like:
# ARRAY /dev/md0 level=raid1 num-devices=2 metadata=1.2 name=localhost.localdomain:0 UUID=c4acea6e:d56e1598:91822e3f:fb26832c disable=line-too-long devices=/dev/vda1,/dev/vdb1
for d in $(echo "$out" | sed -n -e 's/.* devices=\([^ ]*\).*/\1/p' | sed 's/,/ /g'); do
component_devs+=("$d")
done
else
component_devs+=("$boot_device")
fi
# Get blocks from partitions
for d in "${component_devs[@]}"; do
block_devs+=("$(lsblk -spnlo name "$d" | tail -1)")
done
# Filter those GRUB blocks
for d in "${block_devs[@]}"; do
if dd if="$d" bs=446 count=1 status=none | grep -aq "GRUB"; then
echo "$d"
fi
done
}
grub_install () {
if ! command -v grub2-install &>/dev/null; then
exit 0
fi
for d in $(find_grub_devices); do
echo "Installing on $d" >&2
grub2-install "$d"
done
}
grub_install || :
%endif
%files common -f grub.lang
%dir %{_libdir}/grub/
%dir %{_datarootdir}/grub/