fepitre / rpms / pungi

Forked from rpms/pungi 5 years ago
Clone
35a6361
From fcc431622fc0305248bb966271c71c8d17fd5f69 Mon Sep 17 00:00:00 2001
35a6361
From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= <lsedlar@redhat.com>
35a6361
Date: Wed, 11 Apr 2018 09:19:53 +0200
35a6361
Subject: [PATCH 2/3] Revert "Other repo for OstreeInstaller"
35a6361
35a6361
This reverts commit 5c081cb545715c2a912ff50fa57554e89d905868.
35a6361
---
35a6361
 pungi/checks.py                      |  3 ++-
35a6361
 pungi/phases/ostree_installer.py     |  8 ++-----
35a6361
 pungi/util.py                        | 21 +++++-------------
35a6361
 tests/test_ostree_installer_phase.py | 43 +++++++++++++++---------------------
35a6361
 4 files changed, 28 insertions(+), 47 deletions(-)
35a6361
35a6361
diff --git a/pungi/checks.py b/pungi/checks.py
35a6361
index 6233d5d7..189ca948 100644
35a6361
--- a/pungi/checks.py
35a6361
+++ b/pungi/checks.py
35a6361
@@ -938,7 +938,7 @@ def make_schema():
35a6361
                             "tag_ref": {"type": "boolean"},
35a6361
                             "ostree_ref": {"type": "string"},
35a6361
                         },
35a6361
-                        "required": ["treefile", "config_url", "ostree_repo"],
35a6361
+                        "required": ["treefile", "config_url", "repo", "ostree_repo"],
35a6361
                         "additionalProperties": False,
35a6361
                     }),
35a6361
                 ]
35a6361
@@ -959,6 +959,7 @@ def make_schema():
35a6361
                     "template_repo": {"type": "string"},
35a6361
                     "template_branch": {"type": "string"},
35a6361
                 },
35a6361
+                "required": ["repo"],
35a6361
                 "additionalProperties": False,
35a6361
             }),
35a6361
 
35a6361
diff --git a/pungi/phases/ostree_installer.py b/pungi/phases/ostree_installer.py
35a6361
index b7843195..9bf5e255 100644
35a6361
--- a/pungi/phases/ostree_installer.py
35a6361
+++ b/pungi/phases/ostree_installer.py
35a6361
@@ -9,7 +9,7 @@ from kobo import shortcuts
35a6361
 
35a6361
 from .base import ConfigGuardedPhase, PhaseLoggerMixin
35a6361
 from .. import util
35a6361
-from ..util import get_volid, get_repo_urls, version_generator, translate_path
35a6361
+from ..util import get_volid, get_repo_urls, version_generator
35a6361
 from ..wrappers import kojiwrapper, iso, lorax, scm
35a6361
 
35a6361
 
35a6361
@@ -64,11 +64,7 @@ class OstreeInstallerThread(WorkerThread):
35a6361
         self.pool.log_info('[BEGIN] %s' % msg)
35a6361
         self.logdir = compose.paths.log.topdir('%s/%s/ostree_installer-%s' % (arch, variant, self.num))
35a6361
 
35a6361
-        repo_baseurl = compose.paths.work.arch_repo('$basearch', create_dir=False)
35a6361
-        repos = get_repo_urls(None,  # compose==None. Special value says that method should ignore deprecated variant-type repo
35a6361
-                              shortcuts.force_list(config['repo']) + shortcuts.force_list(translate_path(compose, repo_baseurl)),
35a6361
-                              arch=arch,
35a6361
-                              logger=self.pool)
35a6361
+        repos = get_repo_urls(compose, shortcuts.force_list(config['repo']), arch=arch)
35a6361
         repos = [url.replace('$arch', arch) for url in repos]
35a6361
         output_dir = os.path.join(compose.paths.work.topdir(arch), variant.uid, 'ostree_installer')
35a6361
         util.makedirs(os.path.dirname(output_dir))
35a6361
diff --git a/pungi/util.py b/pungi/util.py
35a6361
index 261f3f25..8ea945da 100644
35a6361
--- a/pungi/util.py
35a6361
+++ b/pungi/util.py
35a6361
@@ -678,8 +678,6 @@ def get_repo_url(compose, repo, arch='$basearch'):
35a6361
     Convert repo to repo URL.
35a6361
 
35a6361
     @param compose - required for access to variants
35a6361
-        special value compose==None determines that method is called during
35a6361
-        OSTreeInstaller phase where variant-type source repository is deprecated
35a6361
     @param repo - string or a dict which at least contains 'baseurl' key
35a6361
     @param arch - string to be used as arch in repo url
35a6361
     """
35a6361
@@ -690,17 +688,14 @@ def get_repo_url(compose, repo, arch='$basearch'):
35a6361
             raise RuntimeError('Baseurl is required in repo dict %s' % str(repo))
35a6361
     if '://' not in repo:
35a6361
         # this is a variant name
35a6361
-        if compose is not None:
35a6361
-            v = compose.all_variants.get(repo)
35a6361
-            if not v:
35a6361
-                raise RuntimeError('There is no variant %s to get repo from.' % repo)
35a6361
-        else:
35a6361
-            return None
35a6361
+        v = compose.all_variants.get(repo)
35a6361
+        if not v:
35a6361
+            raise RuntimeError('There is no variant %s to get repo from.' % repo)
35a6361
         repo = translate_path(compose, compose.paths.compose.repository(arch, v, create_dir=False))
35a6361
     return repo
35a6361
 
35a6361
 
35a6361
-def get_repo_urls(compose, repos, arch='$basearch', logger=None):
35a6361
+def get_repo_urls(compose, repos, arch='$basearch'):
35a6361
     """
35a6361
     Convert repos to a list of repo URLs.
35a6361
 
35a6361
@@ -711,11 +706,7 @@ def get_repo_urls(compose, repos, arch='$basearch', logger=None):
35a6361
     urls = []
35a6361
     for repo in repos:
35a6361
         repo = get_repo_url(compose, repo, arch=arch)
35a6361
-        if repo is None:
35a6361
-            if logger:
35a6361
-                logger.log_warning("Variant-type source repository is deprecated and will be ignored during 'OSTreeInstaller' phase: %s" % (repo))
35a6361
-        else:
35a6361
-            urls.append(repo)
35a6361
+        urls.append(repo)
35a6361
     return urls
35a6361
 
35a6361
 
35a6361
@@ -773,7 +764,7 @@ def get_repo_dicts(repos, logger=None):
35a6361
         repo_dict = get_repo_dict(repo)
35a6361
         if repo_dict == {}:
35a6361
             if logger:
35a6361
-                logger.log_warning("Variant-type source repository is deprecated and will be ignored during 'OSTree' phase: %s" % (repo))
35a6361
+                logger.log_warning("Variant-type source repository is deprecated and will be ignored during 'ostree' phase: %s" % (repo))
35a6361
         else:
35a6361
             repo_dicts.append(repo_dict)
35a6361
     return repo_dicts
35a6361
diff --git a/tests/test_ostree_installer_phase.py b/tests/test_ostree_installer_phase.py
35a6361
index 1c7af1ad..ba56d8c7 100644
35a6361
--- a/tests/test_ostree_installer_phase.py
35a6361
+++ b/tests/test_ostree_installer_phase.py
35a6361
@@ -14,7 +14,6 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
35a6361
 
35a6361
 from tests import helpers
35a6361
 from pungi.phases import ostree_installer as ostree
35a6361
-from six.moves import shlex_quote
35a6361
 
35a6361
 
35a6361
 LOG_PATH = 'logs/x86_64/Everything/ostree_installer-1'
35a6361
@@ -59,9 +58,6 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
             'koji_profile': 'koji',
35a6361
             'runroot_tag': 'rrt',
35a6361
             'image_volid_formats': ['{release_short}-{variant}-{arch}'],
35a6361
-            'translate_paths': [
35a6361
-                (self.topdir + '/work', 'http://example.com/work')
35a6361
-            ],
35a6361
         })
35a6361
 
35a6361
     def assertImageAdded(self, compose, ImageCls, iso):
35a6361
@@ -88,7 +84,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
         ]
35a6361
 
35a6361
         for s in force_list(sources):
35a6361
-            lorax_cmd.append(shlex_quote('--source=%s' % s))
35a6361
+            lorax_cmd.append('--source=%s' % s)
35a6361
 
35a6361
         lorax_cmd.append('--variant=Everything')
35a6361
         lorax_cmd.append('--nomacboot')
35a6361
@@ -141,7 +137,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
         self.compose.supported = False
35a6361
         pool = mock.Mock()
35a6361
         cfg = {
35a6361
-            'repo': 'Everything',  # this variant-type repo is deprecated, in result will be replaced with default repo
35a6361
+            'repo': 'Everything',
35a6361
             'release': '20160321.n.0',
35a6361
         }
35a6361
         koji = KojiWrapper.return_value
35a6361
@@ -159,7 +155,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
         t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
35a6361
 
35a6361
         self.assertRunrootCall(koji,
35a6361
-                               'http://example.com/work/$basearch/repo',
35a6361
+                               'file://%s/compose/Everything/x86_64/os' % self.topdir,
35a6361
                                cfg['release'],
35a6361
                                extra=['--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)])
35a6361
         self.assertIsoLinked(link, get_file_size, get_mtime, final_iso_path)
35a6361
@@ -194,11 +190,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
 
35a6361
         t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
35a6361
 
35a6361
-        self.assertRunrootCall(koji,
35a6361
-                               ('http://example.com/repo/x86_64/',
35a6361
-                                'http://example.com/work/$basearch/repo'),
35a6361
-                               cfg['release'],
35a6361
-                               isfinal=True,
35a6361
+        self.assertRunrootCall(koji, 'http://example.com/repo/x86_64/', cfg['release'], isfinal=True,
35a6361
                                extra=['--logfile=%s/%s/lorax.log' % (self.topdir, LOG_PATH)])
35a6361
         self.assertIsoLinked(link, get_file_size, get_mtime, final_iso_path)
35a6361
         self.assertImageAdded(self.compose, ImageCls, iso)
35a6361
@@ -217,7 +209,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
         cfg = {
35a6361
             'release': '20160321.n.0',
35a6361
             'repo': [
35a6361
-                'Everything',  # this variant-type repo is deprecated, in result will be replaced with default repo
35a6361
+                'Everything',
35a6361
                 'https://example.com/extra-repo1.repo',
35a6361
                 'https://example.com/extra-repo2.repo',
35a6361
             ],
35a6361
@@ -234,9 +226,9 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
         t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
35a6361
 
35a6361
         sources = [
35a6361
+            'file://%s/compose/Everything/x86_64/os' % self.topdir,
35a6361
             'https://example.com/extra-repo1.repo',
35a6361
-            'https://example.com/extra-repo2.repo',
35a6361
-            'http://example.com/work/$basearch/repo',
35a6361
+            'https://example.com/extra-repo2.repo'
35a6361
         ]
35a6361
 
35a6361
         self.assertRunrootCall(koji, sources, cfg['release'], isfinal=True,
35a6361
@@ -255,8 +247,8 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
         cfg = {
35a6361
             'release': '20160321.n.0',
35a6361
             'repo': [
35a6361
-                'Everything',  # this variant-type repo is deprecated, in result will be replaced with default repo
35a6361
-                'Server',  # this variant-type repo is deprecated, in result will be replaced with default repo
35a6361
+                'Everything',
35a6361
+                'Server',
35a6361
                 'https://example.com/extra-repo1.repo',
35a6361
                 'https://example.com/extra-repo2.repo',
35a6361
             ],
35a6361
@@ -273,9 +265,10 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
         t.process((self.compose, self.compose.variants['Everything'], 'x86_64', cfg), 1)
35a6361
 
35a6361
         sources = [
35a6361
+            'file://%s/compose/Everything/x86_64/os' % self.topdir,
35a6361
+            'file://%s/compose/Server/x86_64/os' % self.topdir,
35a6361
             'https://example.com/extra-repo1.repo',
35a6361
-            'https://example.com/extra-repo2.repo',
35a6361
-            'http://example.com/work/$basearch/repo',
35a6361
+            'https://example.com/extra-repo2.repo'
35a6361
         ]
35a6361
 
35a6361
         self.assertRunrootCall(koji, sources, cfg['release'], isfinal=True,
35a6361
@@ -326,7 +319,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
                                  get_dir_from_scm):
35a6361
         pool = mock.Mock()
35a6361
         cfg = {
35a6361
-            'repo': 'Everything',  # this variant-type repo is deprecated, in result will be replaced with default repo
35a6361
+            'repo': 'Everything',
35a6361
             'release': '20160321.n.0',
35a6361
             'add_template': ['some_file.txt'],
35a6361
             'add_arch_template': ['other_file.txt'],
35a6361
@@ -353,7 +346,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
                                      'branch': 'f24', 'dir': '.'},
35a6361
                                     templ_dir, logger=pool._logger)])
35a6361
         self.assertRunrootCall(koji,
35a6361
-                               'http://example.com/work/$basearch/repo',
35a6361
+                               'file://%s/compose/Everything/x86_64/os' % self.topdir,
35a6361
                                cfg['release'],
35a6361
                                isfinal=True,
35a6361
                                extra=['--add-template=%s/some_file.txt' % templ_dir,
35a6361
@@ -374,7 +367,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
                                                    get_file_size, get_mtime, ImageCls, run):
35a6361
         pool = mock.Mock()
35a6361
         cfg = {
35a6361
-            'repo': 'Everything',  # this variant-type repo is deprecated, in result will be replaced with default repo
35a6361
+            'repo': 'Everything',
35a6361
             'release': '!RELEASE_FROM_LABEL_DATE_TYPE_RESPIN',
35a6361
             "installpkgs": ["fedora-productimg-atomic"],
35a6361
             "add_template": ["/spin-kickstarts/atomic-installer/lorax-configure-repo.tmpl"],
35a6361
@@ -406,7 +399,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
 
35a6361
         self.assertRunrootCall(
35a6361
             koji,
35a6361
-            'http://example.com/work/$basearch/repo',
35a6361
+            'file://%s/compose/Everything/x86_64/os' % self.topdir,
35a6361
             '20151203.t.0',
35a6361
             isfinal=True,
35a6361
             extra=['--installpkgs=fedora-productimg-atomic',
35a6361
@@ -435,7 +428,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
                                        get_file_size, get_mtime, ImageCls, run):
35a6361
         pool = mock.Mock()
35a6361
         cfg = {
35a6361
-            'repo': 'Everything',  # this variant-type repo is deprecated, in result will be replaced with default repo
35a6361
+            'repo': 'Everything',
35a6361
             'release': None,
35a6361
             "installpkgs": ["fedora-productimg-atomic"],
35a6361
             "add_template": ["/spin-kickstarts/atomic-installer/lorax-configure-repo.tmpl"],
35a6361
@@ -467,7 +460,7 @@ class OstreeThreadTest(helpers.PungiTestCase):
35a6361
 
35a6361
         self.assertRunrootCall(
35a6361
             koji,
35a6361
-            'http://example.com/work/$basearch/repo',
35a6361
+            'file://%s/compose/Everything/x86_64/os' % self.topdir,
35a6361
             '20151203.t.0',
35a6361
             isfinal=True,
35a6361
             extra=['--installpkgs=fedora-productimg-atomic',
35a6361
-- 
35a6361
2.13.6
35a6361