[createiso] Use shell script for runroot

Instead of installing pungi itself in the runroot, we can prepare the
commands to be run on compose box, write the shell script into work/
directory, which is mounted in the chroot, and execute that. This way
there is no business logic in runroot (except for finding lorax
templates).

The main advantage of this approach is that we don't need to pull any
extra dependencies into buildroot.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-07-28 13:05:38 +02:00
parent 6a682f64fe
commit f37a14fb60
7 changed files with 276 additions and 327 deletions

View file

@ -14,6 +14,7 @@ import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from tests import helpers
from pungi.createiso import CreateIsoOpts
from pungi.phases import createiso
@ -64,10 +65,11 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
mock.call('No RPMs found for Server.src, skipping ISO')]
)
@mock.patch('pungi.createiso.write_script')
@mock.patch('pungi.phases.createiso.prepare_iso')
@mock.patch('pungi.phases.createiso.split_iso')
@mock.patch('pungi.phases.createiso.ThreadPool')
def test_start_one_worker(self, ThreadPool, split_iso, prepare_iso):
def test_start_one_worker(self, ThreadPool, split_iso, prepare_iso, write_script):
compose = helpers.DummyCompose(self.topdir, {
'release_short': 'test',
'release_version': '1.0',
@ -94,6 +96,17 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
[mock.call(compose, 'x86_64', compose.variants['Server'])])
self.assertEqual(len(pool.add.call_args_list), 1)
self.maxDiff = None
self.assertItemsEqual(
[x[0][0] for x in write_script.call_args_list],
[CreateIsoOpts(
output_dir='%s/compose/Server/x86_64/iso' % self.topdir,
iso_name='image-name',
volid='test-1.0 Server.x86_64',
graft_points='dummy-graft-points',
arch='x86_64',
supported=True,
jigdo_dir='%s/compose/Server/x86_64/jigdo' % self.topdir,
os_tree='%s/compose/Server/x86_64/os' % self.topdir)])
self.assertItemsEqual(
pool.queue_put.call_args_list,
[mock.call((
@ -101,13 +114,7 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
{
'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir,
'bootable': False,
'cmd': ['pungi-createiso',
'--output-dir=%s/compose/Server/x86_64/iso' % self.topdir,
'--iso-name=image-name', '--volid=test-1.0 Server.x86_64',
'--graft-points=dummy-graft-points',
'--arch=x86_64', '--supported',
'--jigdo-dir=%s/compose/Server/x86_64/jigdo' % self.topdir,
'--os-tree=%s/compose/Server/x86_64/os' % self.topdir],
'cmd': ['bash', self.topdir + '/work/x86_64/tmp-Server/createiso-image-name.sh'],
'label': '',
'disc_num': 1,
'disc_count': 1,
@ -117,18 +124,18 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
))]
)
@mock.patch('pungi.createiso.write_script')
@mock.patch('pungi.phases.createiso.prepare_iso')
@mock.patch('pungi.phases.createiso.split_iso')
@mock.patch('pungi.phases.createiso.ThreadPool')
def test_bootable(self, ThreadPool, split_iso, prepare_iso):
def test_bootable(self, ThreadPool, split_iso, prepare_iso, write_script):
compose = helpers.DummyCompose(self.topdir, {
'release_short': 'test',
'release_version': '1.0',
'release_is_layered': False,
'buildinstall_method': 'lorax',
'bootable': True,
'createiso_skip': [
]
'createiso_skip': []
})
helpers.touch(os.path.join(
compose.paths.compose.os_tree('x86_64', compose.variants['Server']),
@ -157,20 +164,31 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
mock.call(compose, 'src', compose.variants['Server'])])
self.assertEqual(len(pool.add.call_args_list), 2)
self.maxDiff = None
self.assertItemsEqual(
[x[0][0] for x in write_script.call_args_list],
[CreateIsoOpts(output_dir='%s/compose/Server/x86_64/iso' % self.topdir,
iso_name='image-name',
volid='test-1.0 Server.x86_64',
graft_points='dummy-graft-points',
arch='x86_64',
buildinstall_method='lorax',
supported=True,
jigdo_dir='%s/compose/Server/x86_64/jigdo' % self.topdir,
os_tree='%s/compose/Server/x86_64/os' % self.topdir),
CreateIsoOpts(output_dir='%s/compose/Server/source/iso' % self.topdir,
iso_name='image-name',
volid='test-1.0 Server.src',
graft_points='dummy-graft-points',
arch='src',
supported=True,
jigdo_dir='%s/compose/Server/source/jigdo' % self.topdir,
os_tree='%s/compose/Server/source/tree' % self.topdir)])
self.assertItemsEqual(
pool.queue_put.call_args_list,
[mock.call((compose,
{'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir,
'bootable': True,
'cmd': ['pungi-createiso',
'--output-dir=%s/compose/Server/x86_64/iso' % self.topdir,
'--iso-name=image-name', '--volid=test-1.0 Server.x86_64',
'--graft-points=dummy-graft-points',
'--arch=x86_64',
'--buildinstall-method=lorax',
'--supported',
'--jigdo-dir=%s/compose/Server/x86_64/jigdo' % self.topdir,
'--os-tree=%s/compose/Server/x86_64/os' % self.topdir],
'cmd': ['bash', self.topdir + '/work/x86_64/tmp-Server/createiso-image-name.sh'],
'label': '',
'disc_num': 1,
'disc_count': 1},
@ -179,13 +197,7 @@ class CreateisoPhaseTest(helpers.PungiTestCase):
mock.call((compose,
{'iso_path': '%s/compose/Server/source/iso/image-name' % self.topdir,
'bootable': False,
'cmd': ['pungi-createiso',
'--output-dir=%s/compose/Server/source/iso' % self.topdir,
'--iso-name=image-name', '--volid=test-1.0 Server.src',
'--graft-points=dummy-graft-points',
'--arch=src', '--supported',
'--jigdo-dir=%s/compose/Server/source/jigdo' % self.topdir,
'--os-tree=%s/compose/Server/source/tree' % self.topdir],
'cmd': ['bash', self.topdir + '/work/src/tmp-Server/createiso-image-name.sh'],
'label': '',
'disc_num': 1,
'disc_count': 1},
@ -238,7 +250,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
[mock.call('f25-build', 'x86_64', cmd['cmd'], channel=None,
mounts=[self.topdir],
packages=['coreutils', 'genisoimage', 'isomd5sum',
'jigdo', 'pungi'],
'jigdo'],
task_id=True, use_shell=True)])
self.assertEqual(
run_runroot.call_args_list,
@ -272,6 +284,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
'runroot': True,
'runroot_tag': 'f25-build',
'koji_profile': 'koji',
'create_jigdo': False,
})
cmd = {
'iso_path': '%s/compose/Server/x86_64/iso/image-name' % self.topdir,
@ -301,8 +314,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
self.assertEqual(get_runroot_cmd.call_args_list,
[mock.call('f25-build', 'x86_64', cmd['cmd'], channel=None,
mounts=[self.topdir],
packages=['coreutils', 'genisoimage', 'isomd5sum',
'jigdo', 'pungi'],
packages=['coreutils', 'genisoimage', 'isomd5sum'],
task_id=True, use_shell=True)])
self.assertEqual(
run_runroot.call_args_list,
@ -368,7 +380,7 @@ class CreateisoThreadTest(helpers.PungiTestCase):
[mock.call('f25-build', 'x86_64', cmd['cmd'], channel=None,
mounts=[self.topdir],
packages=['coreutils', 'genisoimage', 'isomd5sum',
'jigdo', 'pungi', 'lorax'],
'jigdo', 'lorax'],
task_id=True, use_shell=True)])
self.assertEqual(
run_runroot.call_args_list,

View file

@ -6,6 +6,7 @@ import mock
import os
import sys
import StringIO
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
@ -15,224 +16,183 @@ from pungi import createiso
class CreateIsoScriptTest(helpers.PungiTestCase):
def assertEqualCalls(self, actual, expected):
self.assertEqual(len(actual), len(expected))
for x, y in zip(actual, expected):
self.assertEqual(x, y)
def setUp(self):
super(CreateIsoScriptTest, self).setUp()
self.outdir = os.path.join(self.topdir, 'isos')
@mock.patch('kobo.shortcuts.run')
def test_minimal_run(self, run):
createiso.main([
'--output-dir=%s' % 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 = StringIO.StringIO()
self.maxDiff = None
self.assertEqual(
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',
'-o', 'DP-1.0-20160405.t.3-x86_64.iso',
'-graft-points', '-path-list', 'graft-list'],
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',
show_cmd=True, stdout=True, workdir=self.outdir)]
def assertScript(self, cmds):
script = self.out.getvalue().strip().split('\n')
self.assertEqual(script[:3],
['#!/bin/bash',
'set -ex',
'cd %s' % self.outdir])
self.assertEqual(script[3:], cmds)
def test_minimal_run(self):
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)
self.assertScript(
[' '.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']),
'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']
)
@mock.patch('kobo.shortcuts.run')
def test_bootable_run(self, run):
run.return_value = (0, '/usr/share/lorax')
def test_bootable_run(self):
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)
createiso.main([
'--output-dir=%s' % 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.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',
'-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'],
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',
show_cmd=True, stdout=True, workdir=self.outdir)]
self.assertScript(
[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']),
'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']
)
@mock.patch('kobo.shortcuts.run')
def test_bootable_run_on_i386(self, run):
def test_bootable_run_on_i386(self):
# This will call isohybrid, but not with --uefi switch
run.return_value = (0, '/usr/share/lorax')
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)
createiso.main([
'--output-dir=%s' % 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)]
self.assertScript(
[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']),
'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']
)
@mock.patch('kobo.shortcuts.run')
def test_bootable_run_ppc64(self, run):
run.return_value = (0, '/usr/share/lorax')
def test_bootable_run_ppc64(self):
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)
createiso.main([
'--output-dir=%s' % 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.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',
'-x', './lost+found',
'-part', '-hfs', '-r', '-l', '-sysid', 'PPC', '-no-desktop',
'-allow-multidot', '-chrp-boot', '-map', '/usr/share/lorax/config_files/ppc/mapping',
'-hfs-bless', '/ppc/mac',
'-o', 'DP-1.0-20160405.t.3-ppc64.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/implantisomd5', 'DP-1.0-20160405.t.3-ppc64.iso'],
show_cmd=True, stdout=True, workdir=self.outdir),
mock.call('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',
show_cmd=True, stdout=True, workdir=self.outdir)]
self.assertScript(
[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']),
'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']
)
@mock.patch('kobo.shortcuts.run')
def test_bootable_run_buildinstall(self, run):
createiso.main([
'--output-dir=%s' % 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',
])
def test_bootable_run_buildinstall(self):
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)
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',
'-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'],
show_cmd=True, stdout=True, workdir=self.outdir),
mock.call(['/usr/bin/implantisomd5', 'DP-1.0-20160405.t.3-ppc64.iso'],
show_cmd=True, stdout=True, workdir=self.outdir),
mock.call('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',
show_cmd=True, stdout=True, workdir=self.outdir)]
self.assertScript(
[' '.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']),
'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']
)
@mock.patch('sys.stderr')
@mock.patch('kobo.shortcuts.run')
def test_run_with_jigdo_bad_args(self, run, stderr):
with self.assertRaises(SystemExit):
createiso.main([
'--output-dir=%s' % 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,
])
with self.assertRaises(RuntimeError):
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')
def test_run_with_jigdo(self, run):
createiso.main([
'--output-dir=%s' % 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.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',
'-o', 'DP-1.0-20160405.t.3-x86_64.iso',
'-graft-points', '-path-list', 'graft-list'],
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',
show_cmd=True, stdout=True, workdir=self.outdir),
mock.call(['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//'],
show_cmd=True, stdout=True, workdir=self.outdir)]
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)
self.assertScript(
[' '.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']),
'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',
' '.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//'])]
)