From c10a4ca33724c3459bb2bd9893ba83ad33b7e493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Wed, 6 Jun 2018 15:44:11 +0200 Subject: [PATCH] ostree-installer: Skip comps repo if there are no comps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the compose is not using comps, we can't pass the comps to lorax, since it doesn't exist and it would cause a crash. Signed-off-by: Lubomír Sedlář --- pungi/phases/ostree_installer.py | 13 ++++++++--- tests/test_ostree_installer_phase.py | 34 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/pungi/phases/ostree_installer.py b/pungi/phases/ostree_installer.py index 12f62b25..587ff2c5 100644 --- a/pungi/phases/ostree_installer.py +++ b/pungi/phases/ostree_installer.py @@ -63,13 +63,20 @@ class OstreeInstallerThread(WorkerThread): self.logdir = compose.paths.log.topdir('%s/%s/ostree_installer-%s' % (arch, variant, self.num)) repo_baseurl = compose.paths.work.arch_repo('$basearch', create_dir=False) - comps_baseurl = compose.paths.work.comps_repo('$basearch', variant=variant, create_dir=False) repos = get_repo_urls(None, # compose==None. Special value says that method should ignore deprecated variant-type repo shortcuts.force_list(config['repo']) - + shortcuts.force_list(translate_path(compose, repo_baseurl)) - + shortcuts.force_list(translate_path(compose, comps_baseurl)), + + shortcuts.force_list(translate_path(compose, repo_baseurl)), arch=arch, logger=self.pool) + if compose.has_comps: + repos.append( + translate_path( + compose, + compose.paths.work.comps_repo( + '$basearch', variant=variant, create_dir=False + ), + ) + ) repos = [url.replace('$arch', arch) for url in repos] output_dir = os.path.join(compose.paths.work.topdir(arch), variant.uid, 'ostree_installer') util.makedirs(os.path.dirname(output_dir)) diff --git a/tests/test_ostree_installer_phase.py b/tests/test_ostree_installer_phase.py index dc2b11c6..7569e348 100644 --- a/tests/test_ostree_installer_phase.py +++ b/tests/test_ostree_installer_phase.py @@ -326,6 +326,40 @@ class OstreeThreadTest(helpers.PungiTestCase): self.assertRunrootCall(koji, sources, cfg['release'], isfinal=True, extra=['--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)]) + @mock.patch('pungi.util.copy_all') + @mock.patch('productmd.images.Image') + @mock.patch('pungi.util.get_mtime') + @mock.patch('pungi.util.get_file_size') + @mock.patch('pungi.phases.ostree_installer.iso') + @mock.patch('os.link') + @mock.patch('pungi.wrappers.kojiwrapper.KojiWrapper') + def test_run_without_comps( + self, KojiWrapper, link, iso, get_file_size, get_mtime, ImageCls, copy_all + ): + self.compose.has_comps = False + pool = mock.Mock() + cfg = { + 'release': '20160321.n.0', + 'repo': [], + } + koji = KojiWrapper.return_value + koji.run_runroot_cmd.return_value = { + 'task_id': 1234, + 'retcode': 0, + 'output': 'Foo bar\n', + } + + t = ostree.OstreeInstallerThread(pool) + + t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1) + + sources = [ + 'http://example.com/work/$basearch/repo', + ] + + self.assertRunrootCall(koji, sources, cfg['release'], isfinal=True, + extra=['--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)]) + @mock.patch('pungi.util.copy_all') @mock.patch('productmd.images.Image') @mock.patch('pungi.util.get_mtime')