From c0f7f407ca2649becdf2bb33683c6689ebb085f5 Mon Sep 17 00:00:00 2001 From: fehlix Date: Mon, 23 Nov 2026 21:57:44 +0100 Subject: [PATCH 1/2] Make the hybrid ISO in one native xorriso run (MX/Debian) src/work.cpp, createIso(), MX/Debian paths (isolinux and --grub-mbr): the xorriso call is a list of native xorriso commands (commented, same as build-iso's make_xorriso_iso), passed via bash "$@" - no shell parsing of paths, umask 022 kept. One run makes the hybrid ISO: - isolinux: isohdpfx.bin MBR (package isolinux) + efi.img as GPT/MBR EFI partition (before: separate "isohybrid --uefi" run) - --grub-mbr: GRUB's boot_hybrid.img from the template (same GRUB build as its eltorito.img) + efi.img appended as EFI partition. Before there was no GRUB MBR at all (BIOS from USB could not work) and isohybrid ran on a GRUB image it does not know. - partition 1 starts at 32 KiB (partition_offset 16), MBR type 0x00 - as Debian's ISOs; fdisk/parted show a clean table - Intel Macs (HFS+, APM, blessed boot.efi) automatically when the template carries System/Library/CoreServices/boot.efi The isohybrid step only runs as fallback when isohdpfx.bin is missing. "Make isohybrid" off: plain ISO as before. Arch path unchanged. debian/control: + isolinux (Depends). Tested: the same xorriso argument list on a split tree like mx-snapshot uses (iso-template + iso-2/antiX/linuxfs), November 2026 ISO + new boot set: QEMU BIOS, UEFI, UEFI Secure Boot, 32-bit UEFI; DVD and USB; menus everywhere; desktop reached. A real snapshot run needs root (to do). --- debian/control | 2 + src/work.cpp | 122 ++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 108 insertions(+), 16 deletions(-) diff --git a/debian/control b/debian/control index 166de923..e7e412dd 100644 --- a/debian/control +++ b/debian/control @@ -13,6 +13,7 @@ Depends: mx-iso-template | iso-template (>= 16.1mx15), mx-remaster (>= 25.12.01), squashfs-tools, syslinux-utils, + isolinux, xdg-user-dirs, xorriso (>= 1.4.6), sudo | pkexec | gksu, @@ -34,6 +35,7 @@ Depends: mx-iso-template | iso-template (>= 16.1mx15), mx-remaster (>= 25.12.01), squashfs-tools, syslinux-utils, + isolinux, xdg-user-dirs, xorriso (>= 1.4.6), sudo | pkexec | gksu, diff --git a/src/work.cpp b/src/work.cpp index 3174a127..ef83923d 100644 --- a/src/work.cpp +++ b/src/work.cpp @@ -88,6 +88,17 @@ quint64 parseDuKilobytes(const QString &output, bool *ok) return firstField.toULongLong(ok); } +// First path in candidates that exists, or an empty string. +QString firstExistingFile(const QStringList &candidates) +{ + for (const QString &candidate : candidates) { + if (QFileInfo::exists(candidate)) { + return candidate; + } + } + return {}; +} + QString mksquashfsHelp() { QProcess process; @@ -1126,24 +1137,102 @@ bool Work::createIso(const QString &filename) // The volume label is user-influenced (fullDistroName), so it rides in $3. cmd = R"(xorriso -as mkisofs -l -V "$3" -R -J -pad -iso-level 3)" + isohybridArgs + bootArgs + R"( -o "$1" . "$2")"; - } else if (settings->grubmbr) { - // grub for mbr boot instead of isolinux - cmd = R"(xorriso -as mkisofs -l -V MXLIVE -R -J -pad -iso-level 3 -no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info )" - R"(-b boot/grub/i386-pc/eltorito.img -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -isohybrid-apm-hfsplus -isohybrid-gpt-basdat -o "$1" . "$2")"; - } else { - cmd = R"(xorriso -as mkisofs -l -V MXLIVE -R -J -pad -iso-level 3 -no-emul-boot -boot-load-size 4 -boot-info-table )" - R"(-b boot/isolinux/isolinux.bin -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -c )" - R"(boot/isolinux/isolinux.cat -o "$1" . "$2")"; } - if (Cmd().getOut("umask", Cmd::QuietMode::Yes) != "0022") { - cmd.prepend("umask 022; "); + // MX/Debian: one native xorriso run makes the hybrid ISO (DVD + USB stick, + // BIOS + UEFI); no separate isohybrid step. Same commands as build-iso's + // make_xorriso_iso. The argument list goes to xorriso unchanged via + // bash "$@" (no shell parsing of paths; bash only for umask 022). + QStringList bashArgs; + bool hybridDone = false; + if (!settings->isArch) { + const QString templateDir = settings->workDir + "/iso-template"; + QStringList xargs { + "-report_about", "UPDATE", // progress, no chatter + "-outdev", settings->snapshotDir + "/" + filename, // the new ISO file + "-blank", "as_needed", // replace an existing file + "-volid", volumeLabel, // volume label (max 32 chars) + "-joliet", "on", // + Joliet names (Windows) + "-compliance", "iso_9660_level=3", // files > 4 GiB allowed (linuxfs) + "-map", templateDir, "/", // iso-template -> ISO root + "-map", settings->workDir + "/iso-2", "/", // + iso-2 (antiX/linuxfs) + "-chown_r", "0", "/", "--", // owner root ... + "-chgrp_r", "0", "/", "--", // ... and group root + }; + // Intel Macs (grub-mkrescue style), only when the template has the Mac files + if (QFileInfo::exists(templateDir + "/System/Library/CoreServices/boot.efi")) { + xargs << "-hfsplus" << "on" // + HFS+ filesystem (Macs read it) + << "-boot_image" << "any" << "apm_block_size=2048" // + Apple Partition Map + << "-find" << "/System/Library/CoreServices/boot.efi" + << "-exec" << "set_hfs_bless" << "intel_bootfile" << "--" // the file the Mac boots + << "-find" << "/System/Library/CoreServices/.disk_label" + << "-exec" << "set_hfs_crtp" << "chrp" << "tbxj" << "--"; // name in the boot picker + } + // Hybrid MBR boot code for BIOS from USB: must match the BIOS boot image + QString mbrPath; + if (settings->makeIsohybrid) { + if (settings->grubmbr) { + // GRUB's own MBR, from the template: same GRUB build as its eltorito.img + mbrPath = firstExistingFile({templateDir + "/boot/grub/i386-pc/boot_hybrid.img"}); + if (mbrPath.isEmpty()) { + qWarning() << "boot_hybrid.img not in the template; no BIOS boot from USB."; + } + } else { + mbrPath = firstExistingFile({"/usr/lib/ISOLINUX/isohdpfx.bin", "/usr/lib/syslinux/bios/isohdpfx.bin", + "/usr/lib/syslinux/isohdpfx.bin", "/usr/share/syslinux/isohdpfx.bin"}); + if (mbrPath.isEmpty()) { + qWarning() << "isohdpfx.bin not found (package isolinux); falling back to isohybrid."; + } + } + } + // BIOS: first El Torito entry + if (settings->grubmbr) { + if (!mbrPath.isEmpty()) { + xargs << "-boot_image" << "grub" << ("grub2_mbr=" + mbrPath) // GRUB MBR code + << "-boot_image" << "any" << "partition_table=on"; // MBR partition table + } + xargs << "-boot_image" << "any" << "cat_path=/boot/grub/boot.cat" // boot catalog + << "-boot_image" << "grub" << "bin_path=/boot/grub/i386-pc/eltorito.img" // BIOS: GRUB + << "-boot_image" << "grub" << "grub2_boot_info=on"; // patch image location in + } else { + if (!mbrPath.isEmpty()) { + xargs << "-boot_image" << "isolinux" << ("system_area=" + mbrPath) // isolinux MBR code + << "-boot_image" << "isolinux" << "partition_table=on"; // MBR partition table + } + xargs << "-boot_image" << "any" << "cat_path=/boot/isolinux/isolinux.cat" // boot catalog + << "-boot_image" << "isolinux" << "bin_path=/boot/isolinux/isolinux.bin"; // BIOS: isolinux + } + xargs << "-boot_image" << "any" << "emul_type=no_emulation" // no floppy emulation + << "-boot_image" << "any" << "load_size=2048" // BIOS loads 2 KiB + << "-boot_image" << "any" << "boot_info_table=on"; // boot info table + // UEFI: second El Torito entry + EFI partition for USB sticks + xargs << "-boot_image" << "any" << "next" + << "-boot_image" << "any" << "efi_path=/boot/grub/efi.img"; // UEFI from DVD + if (!mbrPath.isEmpty()) { + if (settings->grubmbr) { + // with GRUB's MBR: a copy of efi.img as MBR partition 2, type EFI + xargs << "-append_partition" << "2" << "0xef" << templateDir + "/boot/grub/efi.img"; + } else { + // with the isolinux MBR: efi.img as GPT + MBR partition (inside the ISO) + xargs << "-boot_image" << "isolinux" << "partition_entry=gpt_basdat"; + } + xargs << "-boot_image" << "any" << "partition_offset=16" // partition 1 at 32 KiB + << "-boot_image" << "any" << "partition_cyl_align=off" // no cylinder padding + << "-boot_image" << "any" << "iso_mbr_part_type=0x00"; // MBR type as Debian + hybridDone = true; + } + qDebug() << "xorriso" << xargs; + bashArgs = QStringList {"-c", "umask 022; exec xorriso \"$@\"", "_"} + xargs; + } else { + if (Cmd().getOut("umask", Cmd::QuietMode::Yes) != "0022") { + cmd.prepend("umask 022; "); + } + bashArgs = QStringList {"-c", cmd, "_", settings->snapshotDir + "/" + filename, + settings->workDir + "/iso-2", volumeLabel}; } + emit message(tr("Creating CD/DVD image file...")); - if (!shell.proc("/bin/bash", - {"-c", cmd, "_", settings->snapshotDir + "/" + filename, settings->workDir + "/iso-2", - volumeLabel}, - nullptr, nullptr, Cmd::QuietMode::No)) { + if (!shell.proc("/bin/bash", bashArgs, nullptr, nullptr, Cmd::QuietMode::No)) { if (cleanupStarted) { return false; } @@ -1157,8 +1246,9 @@ bool Work::createIso(const QString &filename) return false; } - // Make it isohybrid (Arch already folded the hybrid MBR into xorriso above) - if (settings->makeIsohybrid && !settings->isArch) { + // Make it isohybrid - only when xorriso could not do it (no isohdpfx.bin); + // Arch folds the hybrid MBR into its xorriso call above + if (settings->makeIsohybrid && !settings->isArch && !hybridDone) { emit message(tr("Making hybrid iso")); if (!shell.proc("isohybrid", {"--uefi", settings->snapshotDir + "/" + filename}, nullptr, nullptr, Cmd::QuietMode::No)) { From 6334c6cb850c35e66546e691ec74eb55078e3675 Mon Sep 17 00:00:00 2001 From: fehlix Date: Tue, 24 Nov 2026 00:10:22 +0100 Subject: [PATCH 2/2] Review fixes for the native xorriso run - Mac files: add the .disk_label -find/-exec only when the file exists (xorriso aborted with "Cannot find path" when a template had boot.efi but no .disk_label). - Mac files only with "make isohybrid": HFS+ brings an Apple Partition Map, so a plain ISO (make_isohybrid=no) stays without a system area, as before. - -compliance iso_9660_level=3:no_emul_toc and -padding included: the backup GPT header is now in the last sector of the ISO file (as with isohybrid before); no_emul_toc as the old -as mkisofs command did. - debian/control: xorriso (>= 1.4.8) - iso_mbr_part_type= is new in libisoburn 1.4.8. - GRUB mode without boot_hybrid.img: skip isohybrid (it only knows isolinux.bin and stopped the build); the warning says the ISO then boots from DVD only. --- debian/control | 4 ++-- src/work.cpp | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/debian/control b/debian/control index e7e412dd..514cedd9 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,7 @@ Depends: mx-iso-template | iso-template (>= 16.1mx15), syslinux-utils, isolinux, xdg-user-dirs, - xorriso (>= 1.4.6), + xorriso (>= 1.4.8), sudo | pkexec | gksu, ${misc:Depends}, ${shlibs:Depends} @@ -37,7 +37,7 @@ Depends: mx-iso-template | iso-template (>= 16.1mx15), syslinux-utils, isolinux, xdg-user-dirs, - xorriso (>= 1.4.6), + xorriso (>= 1.4.8), sudo | pkexec | gksu, ${misc:Depends}, ${shlibs:Depends} diff --git a/src/work.cpp b/src/work.cpp index ef83923d..17e9f507 100644 --- a/src/work.cpp +++ b/src/work.cpp @@ -1153,20 +1153,27 @@ bool Work::createIso(const QString &filename) "-blank", "as_needed", // replace an existing file "-volid", volumeLabel, // volume label (max 32 chars) "-joliet", "on", // + Joliet names (Windows) - "-compliance", "iso_9660_level=3", // files > 4 GiB allowed (linuxfs) + "-compliance", "iso_9660_level=3:no_emul_toc", // files > 4 GiB allowed; no emulated TOC (as -as mkisofs) + "-padding", "included", // padding inside the image: backup GPT in the last sector "-map", templateDir, "/", // iso-template -> ISO root "-map", settings->workDir + "/iso-2", "/", // + iso-2 (antiX/linuxfs) "-chown_r", "0", "/", "--", // owner root ... "-chgrp_r", "0", "/", "--", // ... and group root }; - // Intel Macs (grub-mkrescue style), only when the template has the Mac files - if (QFileInfo::exists(templateDir + "/System/Library/CoreServices/boot.efi")) { + // Intel Macs (grub-mkrescue style), only when the template has the Mac files. + // HFS+ comes with an Apple Partition Map, so only for a hybrid ISO: with + // "make isohybrid" off the ISO stays plain (no system area), as before. + const QString macDir = templateDir + "/System/Library/CoreServices"; + if (settings->makeIsohybrid && QFileInfo::exists(macDir + "/boot.efi")) { xargs << "-hfsplus" << "on" // + HFS+ filesystem (Macs read it) << "-boot_image" << "any" << "apm_block_size=2048" // + Apple Partition Map << "-find" << "/System/Library/CoreServices/boot.efi" - << "-exec" << "set_hfs_bless" << "intel_bootfile" << "--" // the file the Mac boots - << "-find" << "/System/Library/CoreServices/.disk_label" - << "-exec" << "set_hfs_crtp" << "chrp" << "tbxj" << "--"; // name in the boot picker + << "-exec" << "set_hfs_bless" << "intel_bootfile" << "--"; // the file the Mac boots + // name in the boot picker - only if present (xorriso aborts on a missing path) + if (QFileInfo::exists(macDir + "/.disk_label")) { + xargs << "-find" << "/System/Library/CoreServices/.disk_label" + << "-exec" << "set_hfs_crtp" << "chrp" << "tbxj" << "--"; + } } // Hybrid MBR boot code for BIOS from USB: must match the BIOS boot image QString mbrPath; @@ -1175,7 +1182,9 @@ bool Work::createIso(const QString &filename) // GRUB's own MBR, from the template: same GRUB build as its eltorito.img mbrPath = firstExistingFile({templateDir + "/boot/grub/i386-pc/boot_hybrid.img"}); if (mbrPath.isEmpty()) { - qWarning() << "boot_hybrid.img not in the template; no BIOS boot from USB."; + // isohybrid cannot handle a GRUB boot image either: skip it below + qWarning() << "boot_hybrid.img not in the template: the ISO boots from DVD only" + " (no USB boot; isohybrid is skipped in GRUB mode)."; } } else { mbrPath = firstExistingFile({"/usr/lib/ISOLINUX/isohdpfx.bin", "/usr/lib/syslinux/bios/isohdpfx.bin", @@ -1248,7 +1257,8 @@ bool Work::createIso(const QString &filename) // Make it isohybrid - only when xorriso could not do it (no isohdpfx.bin); // Arch folds the hybrid MBR into its xorriso call above - if (settings->makeIsohybrid && !settings->isArch && !hybridDone) { + // (not in GRUB mode: isohybrid only knows isolinux.bin and would stop the build) + if (settings->makeIsohybrid && !settings->isArch && !hybridDone && !settings->grubmbr) { emit message(tr("Making hybrid iso")); if (!shell.proc("isohybrid", {"--uefi", settings->snapshotDir + "/" + filename}, nullptr, nullptr, Cmd::QuietMode::No)) {