[iso] fix Fedora UEFI support

* One of the ANNOYING distros that relies on an extended label to
  find the install media and is now doing that for Grub/EFI.
* Closes #547
This commit is contained in:
Pete Batard 2015-08-13 23:31:12 +01:00
parent 29588ac684
commit ab6f0ef0bb
3 changed files with 35 additions and 28 deletions

View file

@ -153,11 +153,11 @@ static BOOL check_iso_props(const char* psz_dirname, int64_t i_file_length, cons
}
// Check for the Grub config file
if ((safe_stricmp(psz_dirname, grub_dirname) == 0) && (safe_stricmp(psz_basename, grub_cfg) == 0)) {
if (scan_only)
if (scan_only) {
if ((safe_stricmp(psz_dirname, grub_dirname) == 0) && (safe_stricmp(psz_basename, grub_cfg) == 0))
iso_report.has_grub2 = TRUE;
else
props->is_grub_cfg = TRUE;
} else if (safe_stricmp(psz_basename, grub_cfg) == 0) {
props->is_grub_cfg = TRUE;
}
if (scan_only) {
@ -237,6 +237,7 @@ static BOOL check_iso_props(const char* psz_dirname, int64_t i_file_length, cons
return FALSE;
}
// Apply various workarounds to Linux config files
static void fix_config(const char* psz_fullpath, const char* psz_path, const char* psz_basename, EXTRACT_PROPS* props)
{
size_t i, nul_pos;
@ -249,26 +250,31 @@ static void fix_config(const char* psz_fullpath, const char* psz_path, const cha
for (i=0; i<nul_pos; i++)
if (src[i] == '/') src[i] = '\\';
if (props->is_syslinux_cfg) {
// Workaround for isolinux 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.
// 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.
if ((props->is_syslinux_cfg) || (props->is_grub_cfg)) {
iso_label = replace_char(iso_report.label, ' ', "\\x20");
usb_label = replace_char(iso_report.usb_label, ' ', "\\x20");
if ((iso_label != NULL) && (usb_label != NULL)) {
if (replace_in_token_data(src, "append", iso_label, usb_label, TRUE) != NULL)
if (replace_in_token_data(src, (props->is_syslinux_cfg) ? "append" : "linuxefi", iso_label, usb_label, TRUE) != NULL)
uprintf(" Patched %s: '%s' ⇨ '%s'\n", src, iso_label, usb_label);
// Fix dual BIOS + EFI support for tails and other ISOs
if ( (safe_stricmp(psz_path, efi_dirname) == 0) && (safe_stricmp(psz_basename, syslinux_cfg[0]) == 0) &&
(!iso_report.has_efi_syslinux) && (dst = safe_strdup(src)) ) {
dst[nul_pos-12] = 's'; dst[nul_pos-11] = 'y'; dst[nul_pos-10] = 's';
CopyFileA(src, dst, TRUE);
uprintf("Duplicated %s to %s\n", src, dst);
free(dst);
}
}
} else if (props->is_grub_cfg) {
// Workaround for FreeNAS
safe_free(iso_label);
safe_free(usb_label);
}
// Fix dual BIOS + EFI support for tails and other ISOs
if ( (props->is_syslinux_cfg) && (safe_stricmp(psz_path, efi_dirname) == 0) &&
(safe_stricmp(psz_basename, syslinux_cfg[0]) == 0) &&
(!iso_report.has_efi_syslinux) && (dst = safe_strdup(src)) ) {
dst[nul_pos-12] = 's'; dst[nul_pos-11] = 'y'; dst[nul_pos-10] = 's';
CopyFileA(src, dst, TRUE);
uprintf("Duplicated %s to %s\n", src, dst);
free(dst);
}
// Workaround for FreeNAS
if (props->is_grub_cfg) {
iso_label = malloc(MAX_PATH);
usb_label = malloc(MAX_PATH);
if ((iso_label != NULL) && (usb_label != NULL)) {
@ -277,9 +283,10 @@ static void fix_config(const char* psz_fullpath, const char* psz_path, const cha
if (replace_in_token_data(src, "set", iso_label, usb_label, TRUE) != NULL)
uprintf(" Patched %s: '%s' ⇨ '%s'\n", src, iso_label, usb_label);
}
safe_free(iso_label);
safe_free(usb_label);
}
safe_free(iso_label);
safe_free(usb_label);
free(src);
}