From ddd02891b0b32289abe8756cf833ee3bb8211e58 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 7 Dec 2021 14:13:11 -0800 Subject: [PATCH] mkksiso: Check the iso's arch against the host's mkksiso cannot be run on an iso from another arch, some of the files and tools are arch specific. Catch this problem and tell the user that the iso doesn't match the host's architecture. Related: rhbz#2028048 --- docs/mkksiso.rst | 4 +++- src/sbin/mkksiso | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/mkksiso.rst b/docs/mkksiso.rst index f1222739..dc47716c 100644 --- a/docs/mkksiso.rst +++ b/docs/mkksiso.rst @@ -10,7 +10,9 @@ the iso is booted. If the original iso was created with EFI and Mac support the kickstart boot.iso will include this support as well. ``mkksiso`` needs to be run as root, it depends on mounting the original iso -and you need to be root to be able to do that. +and you need to be root to be able to do that. The host system architecture +needs to match that of the iso. ``mkksiso`` will raise an error if it finds a +.discinfo on the iso with a mismatched arch. mkksiso cmdline arguments diff --git a/src/sbin/mkksiso b/src/sbin/mkksiso index afbf8088..fecbe109 100755 --- a/src/sbin/mkksiso +++ b/src/sbin/mkksiso @@ -398,6 +398,16 @@ class MakeKickstartISO(): self.label = self.iso.label if volid is None else volid if not self.label: raise RuntimeError("No volume id found, cannot create iso.") + + # If the iso contains a .discinfo file check the arch against the host's + if os.path.exists(os.path.join(self.iso.mount_dir, ".discinfo")): + with open(os.path.join(self.iso.mount_dir, ".discinfo")) as f: + discinfo = [l.strip() for l in f.readlines()] + + log.info("iso arch = %s", discinfo[2]) + if os.uname().machine != discinfo[2]: + raise RuntimeError("iso arch does not match the host arch.") + log.info("Volume Id = %s", self.label) if os.path.exists(os.path.join(self.iso.mount_dir, "images/efiboot.img")):