mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-28 07:44:52 +00:00
Transition existing installations to unified GRUB configuration
The previous commits, especially b14117, unified the grub config locations across all platforms. In brief, this means that in the case of EFI, the config file in the EFI System Partition (ESP) is now meant to be a small stub config file that will in turn load the main configuration in /boot/grub2, which is used on all other platforms as well. For new installations all this is done by the Anaconda installer. But existing installations also need to be adapted. Add a %posttrans script to the grub2-common package that will, if a non-unified installation is detected, transition it into a unified one. This is done by moving the main grub.cfg file from the ESP to /boot/grub2, creating minimal stub on the ESP instead. Additionally, the grubenv file is also moved from the ESP to /boot/grub2. The detection of the non-unified installation is done by checking if the grub.cfg on the ESP contains the 'configfile' directive. If so, it is assumed the system has a unified grub configuration. Signed-off-by: Christian Kellner <christian@kellner.me>
This commit is contained in:
parent
b141171629
commit
a32aa179fa
1 changed files with 29 additions and 0 deletions
29
grub2.spec
29
grub2.spec
|
@ -344,6 +344,35 @@ mv -f /boot/grub2.tmp/*.mod \
|
|||
/boot/grub2/ &&
|
||||
rm -r /boot/grub2.tmp/ || :
|
||||
|
||||
%posttrans common
|
||||
set -eu
|
||||
|
||||
EFI_HOME=/boot/efi/EFI/fedora
|
||||
GRUB_HOME=/boot/grub2
|
||||
|
||||
if grep -q "configfile" ${EFI_HOME}/grub.cfg; then
|
||||
exit 0 # already unified, nothing to do
|
||||
fi
|
||||
|
||||
# create a stub grub2 config in EFI
|
||||
BOOT_DEVICE=$(df -P /boot | awk 'END{print $1}')
|
||||
BOOT_UUID=$(blkid -s UUID -o value "${BOOT_DEVICE}")
|
||||
GRUB_DIR=$(grub2-mkrelpath ${GRUB_HOME})
|
||||
|
||||
cat << EOF > ${EFI_HOME}/grub.cfg.stb
|
||||
search --no-floppy --fs-uuid --set=dev ${BOOT_UUID}
|
||||
set prefix=(\$dev)${GRUB_DIR}
|
||||
export \$prefix
|
||||
configfile \$prefix/grub.cfg
|
||||
EOF
|
||||
|
||||
cp -av ${EFI_HOME}/grubenv ${EFI_HOME}/grubenv.rpmsave
|
||||
mv --force ${EFI_HOME}/grubenv ${GRUB_HOME}/grubenv
|
||||
|
||||
cp -av ${EFI_HOME}/grub.cfg ${EFI_HOME}/grub.cfg.rpmsave
|
||||
cp -av ${EFI_HOME}/grub.cfg ${GRUB_HOME}/
|
||||
mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
|
||||
|
||||
%files common -f grub.lang
|
||||
%dir %{_libdir}/grub/
|
||||
%dir %{_datarootdir}/grub/
|
||||
|
|
Loading…
Reference in a new issue