2016-04-04 13:49:30 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import mock
|
2023-05-16 14:17:34 +00:00
|
|
|
from parameterized import parameterized
|
2016-04-04 13:49:30 +00:00
|
|
|
|
|
|
|
import os
|
2017-09-05 08:01:21 +00:00
|
|
|
from six.moves import StringIO
|
2016-04-04 13:49:30 +00:00
|
|
|
|
|
|
|
from tests import helpers
|
|
|
|
from pungi import createiso
|
|
|
|
|
|
|
|
|
2016-04-28 21:27:19 +00:00
|
|
|
class CreateIsoScriptTest(helpers.PungiTestCase):
|
2016-04-14 08:14:51 +00:00
|
|
|
def setUp(self):
|
2016-04-28 21:27:19 +00:00
|
|
|
super(CreateIsoScriptTest, self).setUp()
|
2020-01-22 10:02:22 +00:00
|
|
|
self.outdir = os.path.join(self.topdir, "isos")
|
2017-09-05 08:01:21 +00:00
|
|
|
self.out = StringIO()
|
2016-04-04 13:49:30 +00:00
|
|
|
self.maxDiff = None
|
|
|
|
|
2016-07-28 11:05:38 +00:00
|
|
|
def assertScript(self, cmds):
|
2020-01-22 10:02:22 +00:00
|
|
|
script = self.out.getvalue().strip().split("\n")
|
|
|
|
self.assertEqual(script[:3], ["#!/bin/bash", "set -ex", "cd %s" % self.outdir])
|
2016-07-28 11:05:38 +00:00
|
|
|
self.assertEqual(script[3:], cmds)
|
|
|
|
|
|
|
|
def test_minimal_run(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
createiso.write_script(
|
|
|
|
createiso.CreateIsoOpts(
|
|
|
|
output_dir=self.outdir,
|
|
|
|
iso_name="DP-1.0-20160405.t.3-x86_64.iso",
|
|
|
|
volid="DP-1.0-20160405.t.3",
|
|
|
|
graft_points="graft-list",
|
|
|
|
arch="x86_64",
|
|
|
|
),
|
|
|
|
self.out,
|
|
|
|
)
|
2016-07-28 11:05:38 +00:00
|
|
|
self.assertScript(
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
" ".join(
|
|
|
|
[
|
|
|
|
"/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",
|
|
|
|
"-o",
|
|
|
|
"DP-1.0-20160405.t.3-x86_64.iso",
|
|
|
|
"-graft-points",
|
|
|
|
"-path-list",
|
|
|
|
"graft-list",
|
|
|
|
]
|
|
|
|
),
|
|
|
|
" ".join(["/usr/bin/implantisomd5", "DP-1.0-20160405.t.3-x86_64.iso"]),
|
2020-02-06 07:09:32 +00:00
|
|
|
"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", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
]
|
2016-07-28 11:05:38 +00:00
|
|
|
)
|
2016-04-04 13:49:30 +00:00
|
|
|
|
2016-07-28 11:05:38 +00:00
|
|
|
def test_bootable_run(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
createiso.write_script(
|
|
|
|
createiso.CreateIsoOpts(
|
|
|
|
output_dir=self.outdir,
|
|
|
|
iso_name="DP-1.0-20160405.t.3-x86_64.iso",
|
|
|
|
volid="DP-1.0-20160405.t.3",
|
|
|
|
graft_points="graft-list",
|
|
|
|
arch="x86_64",
|
|
|
|
buildinstall_method="lorax",
|
|
|
|
),
|
|
|
|
self.out,
|
|
|
|
)
|
2016-07-28 11:05:38 +00:00
|
|
|
|
|
|
|
self.assertScript(
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
createiso.FIND_TEMPLATE_SNIPPET,
|
|
|
|
" ".join(
|
|
|
|
[
|
|
|
|
"/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",
|
|
|
|
"-eltorito-alt-boot",
|
|
|
|
"-e",
|
|
|
|
"images/efiboot.img",
|
|
|
|
"-no-emul-boot",
|
|
|
|
"-o",
|
|
|
|
"DP-1.0-20160405.t.3-x86_64.iso",
|
|
|
|
"-graft-points",
|
|
|
|
"-path-list",
|
|
|
|
"graft-list",
|
|
|
|
]
|
|
|
|
),
|
|
|
|
" ".join(
|
|
|
|
["/usr/bin/isohybrid", "--uefi", "DP-1.0-20160405.t.3-x86_64.iso"]
|
|
|
|
),
|
|
|
|
" ".join(["/usr/bin/implantisomd5", "DP-1.0-20160405.t.3-x86_64.iso"]),
|
2020-02-06 07:09:32 +00:00
|
|
|
"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", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
]
|
2016-04-04 13:49:30 +00:00
|
|
|
)
|
|
|
|
|
2016-07-28 11:05:38 +00:00
|
|
|
def test_bootable_run_on_i386(self):
|
2016-04-28 21:27:19 +00:00
|
|
|
# This will call isohybrid, but not with --uefi switch
|
2020-01-22 10:02:22 +00:00
|
|
|
createiso.write_script(
|
|
|
|
createiso.CreateIsoOpts(
|
|
|
|
output_dir=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.out,
|
|
|
|
)
|
2016-07-28 11:05:38 +00:00
|
|
|
|
|
|
|
self.assertScript(
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
createiso.FIND_TEMPLATE_SNIPPET,
|
|
|
|
" ".join(
|
|
|
|
[
|
|
|
|
"/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",
|
|
|
|
]
|
|
|
|
),
|
|
|
|
" ".join(["/usr/bin/isohybrid", "DP-1.0-20160405.t.3-i386.iso"]),
|
|
|
|
" ".join(["/usr/bin/implantisomd5", "DP-1.0-20160405.t.3-i386.iso"]),
|
2020-02-06 07:09:32 +00:00
|
|
|
"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", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
]
|
2016-04-28 21:27:19 +00:00
|
|
|
)
|
|
|
|
|
2016-07-28 11:05:38 +00:00
|
|
|
def test_bootable_run_ppc64(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
createiso.write_script(
|
|
|
|
createiso.CreateIsoOpts(
|
|
|
|
output_dir=self.outdir,
|
|
|
|
iso_name="DP-1.0-20160405.t.3-ppc64.iso",
|
|
|
|
volid="DP-1.0-20160405.t.3",
|
|
|
|
graft_points="graft-list",
|
|
|
|
arch="ppc64",
|
|
|
|
buildinstall_method="lorax",
|
|
|
|
),
|
|
|
|
self.out,
|
|
|
|
)
|
2016-07-28 11:05:38 +00:00
|
|
|
|
|
|
|
self.assertScript(
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
createiso.FIND_TEMPLATE_SNIPPET,
|
|
|
|
" ".join(
|
|
|
|
[
|
|
|
|
"/usr/bin/genisoimage",
|
|
|
|
"-untranslated-filenames",
|
|
|
|
"-volid",
|
|
|
|
"DP-1.0-20160405.t.3",
|
|
|
|
"-J",
|
|
|
|
"-joliet-long",
|
|
|
|
"-rational-rock",
|
|
|
|
"-translation-table",
|
|
|
|
"-x",
|
|
|
|
"./lost+found",
|
|
|
|
"-part",
|
|
|
|
"-hfs",
|
|
|
|
"-r",
|
|
|
|
"-l",
|
|
|
|
"-sysid",
|
|
|
|
"PPC",
|
|
|
|
"-no-desktop",
|
|
|
|
"-allow-multidot",
|
|
|
|
"-chrp-boot",
|
|
|
|
"-map",
|
|
|
|
"$TEMPLATE/config_files/ppc/mapping",
|
|
|
|
"-hfs-bless",
|
|
|
|
"/ppc/mac",
|
|
|
|
"-o",
|
|
|
|
"DP-1.0-20160405.t.3-ppc64.iso",
|
|
|
|
"-graft-points",
|
|
|
|
"-path-list",
|
|
|
|
"graft-list",
|
|
|
|
]
|
|
|
|
),
|
|
|
|
" ".join(["/usr/bin/implantisomd5", "DP-1.0-20160405.t.3-ppc64.iso"]),
|
2020-02-06 07:09:32 +00:00
|
|
|
"isoinfo -R -f -i DP-1.0-20160405.t.3-ppc64.iso | grep -v '/TRANS.TBL$' | sort >> DP-1.0-20160405.t.3-ppc64.iso.manifest", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
]
|
2016-04-04 13:49:30 +00:00
|
|
|
)
|
|
|
|
|
2017-12-14 09:08:30 +00:00
|
|
|
def test_bootable_run_on_s390x(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
createiso.write_script(
|
|
|
|
createiso.CreateIsoOpts(
|
|
|
|
output_dir=self.outdir,
|
|
|
|
iso_name="DP-1.0-20160405.t.3-s390x.iso",
|
|
|
|
volid="DP-1.0-20160405.t.3",
|
|
|
|
graft_points="graft-list",
|
|
|
|
arch="s390x",
|
|
|
|
buildinstall_method="lorax",
|
|
|
|
),
|
|
|
|
self.out,
|
|
|
|
)
|
2017-12-14 09:08:30 +00:00
|
|
|
|
|
|
|
self.assertScript(
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
createiso.FIND_TEMPLATE_SNIPPET,
|
|
|
|
" ".join(
|
|
|
|
[
|
|
|
|
"/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",
|
|
|
|
"-eltorito-boot images/cdboot.img",
|
|
|
|
"-no-emul-boot",
|
|
|
|
"-o",
|
|
|
|
"DP-1.0-20160405.t.3-s390x.iso",
|
|
|
|
"-graft-points",
|
|
|
|
"-path-list",
|
|
|
|
"graft-list",
|
|
|
|
]
|
|
|
|
),
|
|
|
|
" ".join(["/usr/bin/implantisomd5", "DP-1.0-20160405.t.3-s390x.iso"]),
|
2020-02-06 07:09:32 +00:00
|
|
|
"isoinfo -R -f -i DP-1.0-20160405.t.3-s390x.iso | grep -v '/TRANS.TBL$' | sort >> DP-1.0-20160405.t.3-s390x.iso.manifest", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
]
|
2017-12-14 09:08:30 +00:00
|
|
|
)
|
|
|
|
|
2016-07-28 11:05:38 +00:00
|
|
|
def test_bootable_run_buildinstall(self):
|
2020-01-22 10:02:22 +00:00
|
|
|
createiso.write_script(
|
|
|
|
createiso.CreateIsoOpts(
|
|
|
|
output_dir=self.outdir,
|
|
|
|
iso_name="DP-1.0-20160405.t.3-ppc64.iso",
|
|
|
|
volid="DP-1.0-20160405.t.3",
|
|
|
|
graft_points="graft-list",
|
|
|
|
arch="ppc64",
|
|
|
|
buildinstall_method="buildinstall",
|
|
|
|
),
|
|
|
|
self.out,
|
|
|
|
)
|
2016-07-28 11:05:38 +00:00
|
|
|
|
|
|
|
self.assertScript(
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
" ".join(
|
|
|
|
[
|
|
|
|
"/usr/bin/genisoimage",
|
|
|
|
"-untranslated-filenames",
|
|
|
|
"-volid",
|
|
|
|
"DP-1.0-20160405.t.3",
|
|
|
|
"-J",
|
|
|
|
"-joliet-long",
|
|
|
|
"-rational-rock",
|
|
|
|
"-translation-table",
|
|
|
|
"-x",
|
|
|
|
"./lost+found",
|
|
|
|
"-part",
|
|
|
|
"-hfs",
|
|
|
|
"-r",
|
|
|
|
"-l",
|
|
|
|
"-sysid",
|
|
|
|
"PPC",
|
|
|
|
"-no-desktop",
|
|
|
|
"-allow-multidot",
|
|
|
|
"-chrp-boot",
|
|
|
|
"-map",
|
|
|
|
"/usr/lib/anaconda-runtime/boot/mapping",
|
|
|
|
"-hfs-bless",
|
|
|
|
"/ppc/mac",
|
|
|
|
"-o",
|
|
|
|
"DP-1.0-20160405.t.3-ppc64.iso",
|
|
|
|
"-graft-points",
|
|
|
|
"-path-list",
|
|
|
|
"graft-list",
|
|
|
|
]
|
|
|
|
),
|
|
|
|
" ".join(["/usr/bin/implantisomd5", "DP-1.0-20160405.t.3-ppc64.iso"]),
|
2020-02-06 07:09:32 +00:00
|
|
|
"isoinfo -R -f -i DP-1.0-20160405.t.3-ppc64.iso | grep -v '/TRANS.TBL$' | sort >> DP-1.0-20160405.t.3-ppc64.iso.manifest", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
]
|
2016-04-04 13:49:30 +00:00
|
|
|
)
|
|
|
|
|
2020-01-22 10:02:22 +00:00
|
|
|
@mock.patch("sys.stderr")
|
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2016-04-04 13:49:30 +00:00
|
|
|
def test_run_with_jigdo_bad_args(self, run, stderr):
|
2016-07-28 11:05:38 +00:00
|
|
|
with self.assertRaises(RuntimeError):
|
2020-01-22 10:02:22 +00:00
|
|
|
createiso.write_script(
|
|
|
|
createiso.CreateIsoOpts(
|
|
|
|
output_dir=self.outdir,
|
|
|
|
iso_name="DP-1.0-20160405.t.3-x86_64.iso",
|
|
|
|
volid="DP-1.0-20160405.t.3",
|
|
|
|
graft_points="graft-list",
|
|
|
|
arch="x86_64",
|
|
|
|
jigdo_dir="%s/jigdo" % self.topdir,
|
|
|
|
),
|
|
|
|
self.out,
|
|
|
|
)
|
|
|
|
|
|
|
|
@mock.patch("kobo.shortcuts.run")
|
2016-04-04 13:49:30 +00:00
|
|
|
def test_run_with_jigdo(self, run):
|
2020-01-22 10:02:22 +00:00
|
|
|
createiso.write_script(
|
|
|
|
createiso.CreateIsoOpts(
|
|
|
|
output_dir=self.outdir,
|
|
|
|
iso_name="DP-1.0-20160405.t.3-x86_64.iso",
|
|
|
|
volid="DP-1.0-20160405.t.3",
|
|
|
|
graft_points="graft-list",
|
|
|
|
arch="x86_64",
|
|
|
|
jigdo_dir="%s/jigdo" % self.topdir,
|
|
|
|
os_tree="%s/os" % self.topdir,
|
|
|
|
),
|
|
|
|
self.out,
|
|
|
|
)
|
2016-07-28 11:05:38 +00:00
|
|
|
|
|
|
|
self.assertScript(
|
2020-01-22 10:02:22 +00:00
|
|
|
[
|
|
|
|
" ".join(
|
|
|
|
[
|
|
|
|
"/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",
|
|
|
|
"-o",
|
|
|
|
"DP-1.0-20160405.t.3-x86_64.iso",
|
|
|
|
"-graft-points",
|
|
|
|
"-path-list",
|
|
|
|
"graft-list",
|
|
|
|
]
|
|
|
|
),
|
|
|
|
" ".join(["/usr/bin/implantisomd5", "DP-1.0-20160405.t.3-x86_64.iso"]),
|
2020-02-06 07:09:32 +00:00
|
|
|
"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", # noqa: E501
|
2020-01-22 10:02:22 +00:00
|
|
|
" ".join(
|
|
|
|
[
|
|
|
|
"jigdo-file",
|
|
|
|
"make-template",
|
|
|
|
"--force",
|
|
|
|
"--image=%s/isos/DP-1.0-20160405.t.3-x86_64.iso" % self.topdir,
|
|
|
|
"--jigdo=%s/jigdo/DP-1.0-20160405.t.3-x86_64.iso.jigdo"
|
|
|
|
% self.topdir,
|
|
|
|
"--template=%s/jigdo/DP-1.0-20160405.t.3-x86_64.iso.template"
|
|
|
|
% self.topdir,
|
|
|
|
"--no-servers-section",
|
|
|
|
"--report=noprogress",
|
|
|
|
self.topdir + "/os//",
|
|
|
|
]
|
|
|
|
),
|
|
|
|
]
|
2016-04-04 13:49:30 +00:00
|
|
|
)
|
2023-05-16 14:17:34 +00:00
|
|
|
|
|
|
|
@parameterized.expand(
|
|
|
|
[("644", 0o644), ("664", 0o664), ("666", 0o666), ("2644", 0o2644)]
|
|
|
|
)
|
|
|
|
def test_get_perms_non_executable(self, test_name, mode):
|
|
|
|
path = helpers.touch(os.path.join(self.topdir, "f"), mode=mode)
|
|
|
|
self.assertEqual(createiso._get_perms(path), 0o444)
|
|
|
|
|
|
|
|
@parameterized.expand(
|
|
|
|
[
|
|
|
|
("544", 0o544),
|
|
|
|
("554", 0o554),
|
|
|
|
("555", 0o555),
|
|
|
|
("744", 0o744),
|
|
|
|
("755", 0o755),
|
|
|
|
("774", 0o774),
|
|
|
|
("775", 0o775),
|
|
|
|
("777", 0o777),
|
|
|
|
("2775", 0o2775),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
def test_get_perms_executable(self, test_name, mode):
|
|
|
|
path = helpers.touch(os.path.join(self.topdir, "f"), mode=mode)
|
|
|
|
self.assertEqual(createiso._get_perms(path), 0o555)
|