1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[iso] fix GRUB boot for newer Arch and derivatives

* Arch recently added a "search --no-floppy --set=root --label <LABEL>" into their
  grub.cfg, which we didn't have provision for patching, which means that, as soon
  as the user changed the label or used an Arch derivative with a label that isn't
  compliant with FAT (e.g. Athena Linux), search, and therefore boot would fail.
* Also alter the code so that we modify for more than one token if needed.
* Closes #2086
This commit is contained in:
Pete Batard 2022-11-13 20:57:26 +00:00
parent 4cfe1c9947
commit 165127d221
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
2 changed files with 17 additions and 14 deletions

View file

@ -363,20 +363,23 @@ static void fix_config(const char* psz_fullpath, const char* psz_path, const cha
// Workaround for config files requiring an ISO label for kernel append that may be // Workaround for config files requiring an ISO label for kernel append that may be
// different from our USB label. Oh, and these labels must have spaces converted to \x20. // different from our USB label. Oh, and these labels must have spaces converted to \x20.
if ((props->is_cfg) || (props->is_conf)) { if ((props->is_cfg) || (props->is_conf)) {
// Older versions of GRUB EFI used "linuxefi", newer just use "linux".
// Also, in their great wisdom, the openSUSE maintainers added a 'set linux=linux'
// line to their grub.cfg, which means that their kernel option token is no longer
//'linux' but '$linux'... and we have to add a workaround for that.
// Finally, newer Arch and derivatives added an extra "search --label ..." command
// in GRUB which we need to cater for in supplement to the kernel line.
static const char* grub_token[] = { "linux", "linuxefi", "$linux", "search" };
iso_label = replace_char(img_report.label, ' ', "\\x20"); iso_label = replace_char(img_report.label, ' ', "\\x20");
usb_label = replace_char(img_report.usb_label, ' ', "\\x20"); usb_label = replace_char(img_report.usb_label, ' ', "\\x20");
if ((iso_label != NULL) && (usb_label != NULL)) { if ((iso_label != NULL) && (usb_label != NULL)) {
if (props->is_grub_cfg) { if (props->is_grub_cfg) {
// Older versions of GRUB EFI used "linuxefi", newer just use "linux" for (int i = 0; i < ARRAYSIZE(grub_token); i++)
if ((replace_in_token_data(src, "linux", iso_label, usb_label, TRUE) != NULL) || if (replace_in_token_data(src, grub_token[i], iso_label, usb_label, TRUE) != NULL)
(replace_in_token_data(src, "linuxefi", iso_label, usb_label, TRUE) != NULL) || modified = TRUE;
// In their great wisdom, the openSUSE maintainers added a 'set linux=linux' if (modified)
// line to their grub.cfg, which means that their kernel option token is no
// longer 'linux' but '$linux'... and we have to add a workaround for that.
(replace_in_token_data(src, "$linux", iso_label, usb_label, TRUE) != NULL)) {
uprintf(" Patched %s: '%s' ➔ '%s'\n", src, iso_label, usb_label); uprintf(" Patched %s: '%s' ➔ '%s'\n", src, iso_label, usb_label);
modified = TRUE;
}
} else if (replace_in_token_data(src, (props->is_conf) ? "options" : "append", } else if (replace_in_token_data(src, (props->is_conf) ? "options" : "append",
iso_label, usb_label, TRUE) != NULL) { iso_label, usb_label, TRUE) != NULL) {
uprintf(" Patched %s: '%s' ➔ '%s'\n", src, iso_label, usb_label); uprintf(" Patched %s: '%s' ➔ '%s'\n", src, iso_label, usb_label);

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326 IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.21.1943" CAPTION "Rufus 3.21.1944"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0 FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -396,8 +396,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,21,1943,0 FILEVERSION 3,21,1944,0
PRODUCTVERSION 3,21,1943,0 PRODUCTVERSION 3,21,1944,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -415,13 +415,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie" VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting" VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.21.1943" VALUE "FileVersion", "3.21.1944"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.21.exe" VALUE "OriginalFilename", "rufus-3.21.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.21.1943" VALUE "ProductVersion", "3.21.1944"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"