[ostree-installer] Allow using external repos as source
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
bb4afea4f1
commit
c8341e1806
@ -1033,7 +1033,7 @@ an OSTree repository. This always runs in Koji as a ``runroot`` task.
|
||||
The configuration dict for each variant arch pair must have this key:
|
||||
|
||||
* ``source_repo_from`` -- (*str*) Name of variant serving as source
|
||||
repository.
|
||||
repository or a URL pointing the the repo.
|
||||
|
||||
These keys are optional:
|
||||
|
||||
|
@ -50,9 +50,7 @@ class OstreeInstallerThread(WorkerThread):
|
||||
self.pool.log_info('[BEGIN] %s' % msg)
|
||||
self.logdir = compose.paths.log.topdir('{}/ostree_installer'.format(arch))
|
||||
|
||||
source_variant = compose.variants[config['source_repo_from']]
|
||||
source_repo = translate_path(
|
||||
compose, compose.paths.compose.repository(arch, source_variant, create_dir=False))
|
||||
source_repo = self._get_source_repo(compose, arch, config['source_repo_from'])
|
||||
output_dir = os.path.join(compose.paths.work.topdir(arch), variant.uid, 'ostree_installer')
|
||||
util.makedirs(os.path.dirname(output_dir))
|
||||
|
||||
@ -67,6 +65,18 @@ class OstreeInstallerThread(WorkerThread):
|
||||
self._add_to_manifest(compose, variant, arch, filename)
|
||||
self.pool.log_info('[DONE ] %s' % msg)
|
||||
|
||||
def _get_source_repo(self, compose, arch, source):
|
||||
"""
|
||||
If `source` is a URL, return it as-is (possibly replacing $arch with
|
||||
actual arch. Otherwise treat is a a variant name and return path to
|
||||
repo in that variant.
|
||||
"""
|
||||
if '://' in source:
|
||||
return source.replace('$arch', arch)
|
||||
source_variant = compose.variants[source]
|
||||
return translate_path(
|
||||
compose, compose.paths.compose.repository(arch, source_variant, create_dir=False))
|
||||
|
||||
def _clone_templates(self, url, branch='master'):
|
||||
if not url:
|
||||
self.template_dir = None
|
||||
|
@ -162,6 +162,69 @@ class OstreeThreadTest(helpers.PungiTestCase):
|
||||
self.assertEqual(run.call_args_list,
|
||||
[mock.call('cp -av {0}/work/x86_64/Everything/ostree_installer/* {0}/compose/Everything/x86_64/iso/'.format(self.topdir))])
|
||||
|
||||
@mock.patch('kobo.shortcuts.run')
|
||||
@mock.patch('productmd.images.Image')
|
||||
@mock.patch('pungi.util.get_mtime')
|
||||
@mock.patch('pungi.util.get_file_size')
|
||||
@mock.patch('pungi.wrappers.iso.IsoWrapper')
|
||||
@mock.patch('os.link')
|
||||
@mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper')
|
||||
def test_run(self, KojiWrapper, link, IsoWrapper,
|
||||
get_file_size, get_mtime, ImageCls, run):
|
||||
compose = helpers.DummyCompose(self.topdir, {
|
||||
'release_name': 'Fedora',
|
||||
'release_version': 'Rawhide',
|
||||
'koji_profile': 'koji',
|
||||
'runroot_tag': 'rrt',
|
||||
})
|
||||
pool = mock.Mock()
|
||||
cfg = {
|
||||
'source_repo_from': 'http://example.com/repo/$arch/',
|
||||
'release': '20160321.n.0',
|
||||
}
|
||||
koji = KojiWrapper.return_value
|
||||
koji.run_runroot_cmd.return_value = {
|
||||
'task_id': 1234,
|
||||
'retcode': 0,
|
||||
'output': 'Foo bar\n',
|
||||
}
|
||||
get_file_size.return_value = 1024
|
||||
get_mtime.return_value = 13579
|
||||
final_iso_path = self.topdir + '/compose/Everything/x86_64/iso/image-name'
|
||||
|
||||
t = ostree.OstreeInstallerThread(pool)
|
||||
|
||||
t.process((compose, compose.variants['Everything'], 'x86_64', cfg), 1)
|
||||
|
||||
self.assertEqual(koji.get_runroot_cmd.call_args_list,
|
||||
[mock.call('rrt', 'x86_64',
|
||||
['lorax',
|
||||
'--product=Fedora',
|
||||
'--version=Rawhide',
|
||||
'--release=20160321.n.0',
|
||||
'--source=http://example.com/repo/x86_64/',
|
||||
'--variant=Everything',
|
||||
'--nomacboot',
|
||||
self.topdir + '/work/x86_64/Everything/ostree_installer'],
|
||||
channel=None, mounts=[self.topdir],
|
||||
packages=['pungi', 'lorax', 'ostree'],
|
||||
task_id=True, use_shell=True)])
|
||||
self.assertEqual(koji.run_runroot_cmd.call_args_list,
|
||||
[mock.call(koji.get_runroot_cmd.return_value,
|
||||
log_file=self.topdir + '/logs/x86_64/ostree_installer/runroot.log')])
|
||||
self.assertEqual(link.call_args_list,
|
||||
[mock.call(self.topdir + '/work/x86_64/Everything/ostree_installer/images/boot.iso',
|
||||
final_iso_path)])
|
||||
self.assertEqual(get_file_size.call_args_list, [mock.call(final_iso_path)])
|
||||
self.assertEqual(get_mtime.call_args_list, [mock.call(final_iso_path)])
|
||||
self.assertImageAdded(compose, ImageCls, IsoWrapper)
|
||||
self.assertEqual(compose.get_image_name.call_args_list,
|
||||
[mock.call('x86_64', compose.variants['Everything'], disc_type='dvd')])
|
||||
self.assertTrue(os.path.isdir(self.topdir + '/work/x86_64/Everything/'))
|
||||
self.assertFalse(os.path.isdir(self.topdir + '/work/x86_64/Everything/ostree_installer'))
|
||||
self.assertEqual(run.call_args_list,
|
||||
[mock.call('cp -av {0}/work/x86_64/Everything/ostree_installer/* {0}/compose/Everything/x86_64/iso/'.format(self.topdir))])
|
||||
|
||||
@mock.patch('kobo.shortcuts.run')
|
||||
@mock.patch('productmd.images.Image')
|
||||
@mock.patch('pungi.util.get_mtime')
|
||||
|
Loading…
Reference in New Issue
Block a user