Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EFI load option UUID #415

Merged
merged 5 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Define hexdump textconv with "git config diff.efivars.textconv hd"
tests/efivars/* diff=efivars
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+++ b/tests/efivars/PlatformLangCodes-8be4df61-93ca-11d2-aa0d-00e098032b8c
@@ -0,0 +1,3 @@
+00000000  06 00 00 00 65 6e 3b 66  72 3b 65 6e 2d 55 53 3b  |....en;fr;en-US;|
+00000010  66 72 2d 46 52 00                                 |fr-FR.|
+00000016

Interesting, I wonder where French came from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 This comes from TianoCore (EDK2), so my guess is someone bothered to do French translations for it. Yeah, now I see some translations.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config.status
config.sub
configure
depcomp
eos-update-efi-uuid
fallback-fb-setup/fallback-fb-setup
install-sh
missing
Expand Down
10 changes: 10 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ SUBDIRS = dracut factory-reset fallback-fb-setup flatpak-repos nvidia psi-monito
EXTRA_DIST = debian .flake8
CLEANFILES =

AM_CFLAGS = -Wall -Werror

# Install systemd units, generators, preset files, and udev rules
# under $prefix for distcheck
AM_DISTCHECK_CONFIGURE_FLAGS = \
Expand Down Expand Up @@ -92,6 +94,14 @@ dist_sbin_SCRIPTS = \
eos-update-flatpak-repos \
$(NULL)

sbin_PROGRAMS = \
eos-update-efi-uuid \
$(NULL)

eos_update_efi_uuid_SOURCES = eos-update-efi-uuid.c
eos_update_efi_uuid_CFLAGS = $(AM_CFLAGS) $(EFIBOOT_CFLAGS)
eos_update_efi_uuid_LDADD = $(EFIBOOT_LIBS)

dist_libexec_SCRIPTS = \
eos-migrate-chromium-profile \
eos-migrate-firefox-profile \
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ case $target_cpu in
esac
AC_SUBST(FLATPAK_ARCH)

PKG_CHECK_MODULES([EFIBOOT], [efiboot efivar])

AC_CONFIG_FILES([
Makefile
dracut/Makefile
Expand Down
3 changes: 3 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ Build-Depends: automake,
gir1.2-ostree-1.0 <!nocheck>,
gir1.2-eosmetrics-0 <!nocheck>,
libdbus-1-dev,
libefiboot-dev,
libefivar-dev,
libpolkit-gobject-1-dev,
pkg-config,
python3 <!nocheck>,
python3-gi <!nocheck>,
python3-parted <!nocheck>,
python3-pytest <!nocheck>,
python3-systemd <!nocheck>,
systemd,
udev,
Expand Down
18 changes: 16 additions & 2 deletions dracut/repartition/endless-repartition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ else
marker=$(sfdisk --force --part-attrs $root_disk $partno)
fi

# Read the ESP's current UUID so we can update load options below.
orig_esp_uuid=
if [ "$pt_label" = "gpt" ]; then
orig_esp_uuid=$(sfdisk --force --part-uuid $root_disk 1)
fi

case "$marker" in
*GUID:55* | dd)
;;
Expand Down Expand Up @@ -199,6 +205,15 @@ udevadm settle

[ "$ret" != "0" ] && exit 0

# Read the ESP's new UUID and update any invalidated load options.
new_esp_uuid=
if [ "$pt_label" = "gpt" ]; then
new_esp_uuid=$(sfdisk --force --part-uuid $root_disk 1)
fi
if [ -d /sys/firmware/efi ] && [ -n "$orig_esp_uuid" ] && [ -n "$new_esp_uuid" ]; then
eos-update-efi-uuid -v "$orig_esp_uuid" "$new_esp_uuid"
fi

# Loop devices need a prod
if [ -n "$using_loop" ]; then
partx --update --verbose $root_disk
Expand All @@ -214,8 +229,7 @@ udevadm settle
# If we're an sd-booting image we need to fix-up the copy of the
# ESP UUID that sd-boot gave us so systemd mounts the ESP
esp_var=$(echo /sys/firmware/efi/efivars/LoaderDevicePartUUID*)
if [ -f "${esp_var}" ]; then
new_esp_uuid=$(sfdisk $root_disk --part-uuid 1)
if [ -f "${esp_var}" ] && [ -n "${new_esp_uuid}" ]; then
#We need to start with 0x06 0x00 0x00 0x00 and end with 0x00 0x00
#iconv will add the extra 0s
# Shell gotcha - \06\00 works... until ${new_esp_uuid} starts with a decimal digit.
Expand Down
1 change: 1 addition & 0 deletions dracut/repartition/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ depends() {
}

install() {
dracut_install eos-update-efi-uuid
dracut_install sfdisk
dracut_install blockdev
dracut_install readlink
Expand Down
Loading