From 8b572191f41c2e00270c9963f04f55c42c0f57a2 Mon Sep 17 00:00:00 2001 From: Dennis Gilmore Date: Apr 29 2016 20:22:04 +0000 Subject: [createiso] Add back running isohybrid on x86 disk images rhbz#1331317 when we refactored how we make dvds in df400002d8a7520609e27e8e46973342e0ab4985 we lost the ability to boot the dvd as a disk image. Signed-off-by: Dennis Gilmore --- diff --git a/pungi/createiso.py b/pungi/createiso.py index 243aee7..b7d6202 100644 --- a/pungi/createiso.py +++ b/pungi/createiso.py @@ -45,6 +45,15 @@ def implant_md5(iso, opts): shortcuts.run(cmd, stdout=True, show_cmd=True, workdir=opts.output_dir) +def run_isohybrid(iso, opts): + """If the image is bootable, it needs to include an MBR or GPT so that it + can actually be booted. This is done by running isohybrid on the image. + """ + if opts.buildinstall_method and opts.arch in ["x86_64", "i386"]: + cmd = iso.get_isohybrid_cmd(opts.iso_name, opts.arch) + shortcuts.run(cmd, stdout=True, show_cmd=True, workdir=opts.output_dir) + + def make_manifest(iso, opts): shortcuts.run(iso.get_manifest_cmd(opts.iso_name), stdout=True, show_cmd=True, workdir=opts.output_dir) @@ -68,6 +77,7 @@ def make_jigdo(opts): def run(opts): iso = IsoWrapper() make_image(iso, opts) + run_isohybrid(iso, opts) implant_md5(iso, opts) make_manifest(iso, opts) if opts.jigdo_dir: diff --git a/pungi/wrappers/iso.py b/pungi/wrappers/iso.py index 695f883..cf79375 100644 --- a/pungi/wrappers/iso.py +++ b/pungi/wrappers/iso.py @@ -205,6 +205,15 @@ class IsoWrapper(kobo.log.LoggingBase): result = line.rsplit(":")[-1].strip() return result + def get_isohybrid_cmd(self, iso_path, arch): + # isohybrid is in syslinux which is x86 only + cmd = ["/usr/bin/isohybrid"] + # uefi is only supported on x86_64 + if arch == "x86_64": + cmd.append("--uefi") + cmd.append(iso_path) + return cmd + def get_manifest_cmd(self, iso_name): return "isoinfo -R -f -i %s | grep -v '/TRANS.TBL$' | sort >> %s.manifest" % (pipes.quote(iso_name), pipes.quote(iso_name)) diff --git a/tests/test_createiso_script.py b/tests/test_createiso_script.py index 9200194..6597ef2 100755 --- a/tests/test_createiso_script.py +++ b/tests/test_createiso_script.py @@ -13,7 +13,7 @@ from tests import helpers from pungi import createiso -class OstreeScriptTest(helpers.PungiTestCase): +class CreateIsoScriptTest(helpers.PungiTestCase): def assertEqualCalls(self, actual, expected): self.assertEqual(len(actual), len(expected)) @@ -21,7 +21,7 @@ class OstreeScriptTest(helpers.PungiTestCase): self.assertEqual(x, y) def setUp(self): - super(OstreeScriptTest, self).setUp() + super(CreateIsoScriptTest, self).setUp() self.outdir = os.path.join(self.topdir, 'isos') @mock.patch('kobo.shortcuts.run') @@ -79,6 +79,8 @@ class OstreeScriptTest(helpers.PungiTestCase): show_cmd=True, stdout=True, workdir=self.outdir), mock.call(['pungi-pylorax-find-templates', '/usr/share/lorax'], show_cmd=True, stdout=True), + mock.call(['/usr/bin/isohybrid', '--uefi', 'DP-1.0-20160405.t.3-x86_64.iso'], + show_cmd=True, stdout=True, workdir=self.outdir), mock.call(['/usr/bin/implantisomd5', 'DP-1.0-20160405.t.3-x86_64.iso'], show_cmd=True, stdout=True, workdir=self.outdir), mock.call('isoinfo -R -f -i DP-1.0-20160405.t.3-x86_64.iso | grep -v \'/TRANS.TBL$\' | sort >> DP-1.0-20160405.t.3-x86_64.iso.manifest', @@ -86,6 +88,43 @@ class OstreeScriptTest(helpers.PungiTestCase): ) @mock.patch('kobo.shortcuts.run') + def test_bootable_run_on_i386(self, run): + # This will call isohybrid, but not with --uefi switch + run.return_value = (0, '/usr/share/lorax') + + createiso.main([ + '--output-dir={}'.format(self.outdir), + '--iso-name=DP-1.0-20160405.t.3-i386.iso', + '--volid=DP-1.0-20160405.t.3', + '--graft-points=graft-list', + '--arch=i386', + '--buildinstall-method=lorax', + ]) + + self.maxDiff = None + self.assertItemsEqual( + run.call_args_list, + [mock.call(['/usr/bin/genisoimage', '-untranslated-filenames', + '-volid', 'DP-1.0-20160405.t.3', '-J', '-joliet-long', + '-rational-rock', '-translation-table', + '-input-charset', 'utf-8', '-x', './lost+found', + '-b', 'isolinux/isolinux.bin', '-c', 'isolinux/boot.cat', + '-no-emul-boot', + '-boot-load-size', '4', '-boot-info-table', + '-o', 'DP-1.0-20160405.t.3-i386.iso', + '-graft-points', '-path-list', 'graft-list'], + show_cmd=True, stdout=True, workdir=self.outdir), + mock.call(['pungi-pylorax-find-templates', '/usr/share/lorax'], + show_cmd=True, stdout=True), + mock.call(['/usr/bin/isohybrid', 'DP-1.0-20160405.t.3-i386.iso'], + show_cmd=True, stdout=True, workdir=self.outdir), + mock.call(['/usr/bin/implantisomd5', 'DP-1.0-20160405.t.3-i386.iso'], + show_cmd=True, stdout=True, workdir=self.outdir), + mock.call('isoinfo -R -f -i DP-1.0-20160405.t.3-i386.iso | grep -v \'/TRANS.TBL$\' | sort >> DP-1.0-20160405.t.3-i386.iso.manifest', + show_cmd=True, stdout=True, workdir=self.outdir)] + ) + + @mock.patch('kobo.shortcuts.run') def test_bootable_run_ppc64(self, run): run.return_value = (0, '/usr/share/lorax')