[buildinstall] Add customizing disc type

This patch adds configuration option to change disc type used in file
name. So far this can only be changed for link to images/boot.iso.

Resolves: #109
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-03-08 12:36:28 +01:00
parent ad104f994a
commit 0c9ad96a31
3 changed files with 63 additions and 2 deletions

View File

@ -233,12 +233,18 @@ There a couple common format specifiers available for both the options:
* base_product_version
**image_volid_layered_product_formats** [optional]
(*list*) -- A listof format strings for generating volume id for layered
(*list*) -- A list of format strings for generating volume id for layered
products. The keys available are the same as for ``image_volid_formats``.
**volume_id_substitutions** [optional]
(*dict*) -- A mapping of string replacements to shorten the volume id.
**disc_types** [optional]
(*dict*) -- A mapping for customizing ``disc_type`` used in image names.
Available keys are:
* ``boot`` -- for ``boot.iso`` images created in *buildinstall* phase
Example
-------
::
@ -259,6 +265,10 @@ Example
'TC': 'T',
}
disc_types = {
'boot': 'netinst',
}
Signing
=======

View File

@ -316,6 +316,8 @@ def link_boot_iso(compose, arch, variant):
if arch == "src":
return
disc_type = compose.conf.get('disc_types', {}).get('boot', 'boot')
symlink_isos_to = compose.conf.get("symlink_isos_to", None)
os_tree = compose.paths.compose.os_tree(arch, variant)
# TODO: find in treeinfo?
@ -324,7 +326,7 @@ def link_boot_iso(compose, arch, variant):
return
msg = "Linking boot.iso (arch: %s, variant: %s)" % (arch, variant)
filename = compose.get_image_name(arch, variant, disc_type="boot",
filename = compose.get_image_name(arch, variant, disc_type=disc_type,
disc_num=None, suffix=".iso")
new_boot_iso_path = compose.paths.compose.iso_path(arch, variant, filename,
symlink_to=symlink_isos_to)

View File

@ -611,6 +611,55 @@ class TestSymlinkIso(PungiTestCase):
self.assertEqual(self.compose.im.add.mock_calls,
[mock.call('Server', 'x86_64', image)])
@mock.patch('pungi.phases.buildinstall.Image')
@mock.patch('pungi.phases.buildinstall.get_mtime')
@mock.patch('pungi.phases.buildinstall.get_file_size')
@mock.patch('pungi.phases.buildinstall.IsoWrapper')
@mock.patch('pungi.phases.buildinstall.run')
def test_hardlink_with_custom_type(self, run, IsoWrapperCls, get_file_size, get_mtime, ImageCls):
self.compose.conf = {
'buildinstall_symlink': False,
'disc_types': {'boot': 'netinst'},
}
IsoWrapper = IsoWrapperCls.return_value
get_file_size.return_value = 1024
get_mtime.return_value = 13579
link_boot_iso(self.compose, 'x86_64', self.compose.variants['Server'])
tgt = self.topdir + '/compose/Server/x86_64/iso/image-name'
self.assertTrue(os.path.isfile(tgt))
self.assertEqual(os.stat(tgt).st_ino,
os.stat(self.topdir + '/compose/Server/x86_64/os/images/boot.iso').st_ino)
self.assertItemsEqual(
self.compose.get_image_name.mock_calls,
[mock.call('x86_64', self.compose.variants['Server'],
disc_type='netinst', disc_num=None, suffix='.iso')])
self.assertItemsEqual(IsoWrapper.get_implanted_md5.mock_calls,
[mock.call(tgt)])
self.assertItemsEqual(IsoWrapper.get_manifest_cmd.mock_calls,
[mock.call('image-name')])
self.assertItemsEqual(IsoWrapper.get_volume_id.mock_calls,
[mock.call(tgt)])
self.assertItemsEqual(run.mock_calls,
[mock.call(IsoWrapper.get_manifest_cmd.return_value,
workdir=self.topdir + '/compose/Server/x86_64/iso')])
image = ImageCls.return_value
self.assertEqual(image.path, 'Server/x86_64/iso/image-name')
self.assertEqual(image.mtime, 13579)
self.assertEqual(image.size, 1024)
self.assertEqual(image.arch, 'x86_64')
self.assertEqual(image.type, "boot")
self.assertEqual(image.format, "iso")
self.assertEqual(image.disc_number, 1)
self.assertEqual(image.disc_count, 1)
self.assertEqual(image.bootable, True)
self.assertEqual(image.implant_md5, IsoWrapper.get_implanted_md5.return_value)
self.assertEqual(self.compose.im.add.mock_calls,
[mock.call('Server', 'x86_64', image)])
if __name__ == "__main__":
unittest.main()