pkgset: Create repos in a single place
Both pkgset sources use the same logic to create per-arch repos. There is no reason to have that code in both places. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
8994aa5d88
commit
e674c2f574
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import threading
|
||||||
|
|
||||||
from kobo.shortcuts import run, relative_path
|
from kobo.shortcuts import run, relative_path
|
||||||
from kobo.threads import run_in_threads
|
from kobo.threads import run_in_threads
|
||||||
@ -27,7 +28,6 @@ from pungi.util import is_arch_multilib, find_old_compose, collect_module_defaul
|
|||||||
from pungi.phases.createrepo import add_modular_metadata
|
from pungi.phases.createrepo import add_modular_metadata
|
||||||
|
|
||||||
|
|
||||||
# TODO: per arch?
|
|
||||||
def populate_arch_pkgsets(compose, path_prefix, global_pkgset):
|
def populate_arch_pkgsets(compose, path_prefix, global_pkgset):
|
||||||
result = {}
|
result = {}
|
||||||
exclusive_noarch = compose.conf['pkgset_exclusive_arch_considers_noarch']
|
exclusive_noarch = compose.conf['pkgset_exclusive_arch_considers_noarch']
|
||||||
@ -122,3 +122,19 @@ def _create_arch_repo(worker_thread, args, task_num):
|
|||||||
)
|
)
|
||||||
|
|
||||||
compose.log_info("[DONE ] %s" % msg)
|
compose.log_info("[DONE ] %s" % msg)
|
||||||
|
|
||||||
|
|
||||||
|
def materialize_pkgset(compose, pkgset_global, path_prefix):
|
||||||
|
"""Create per-arch pkgsets and create repodata for each arch."""
|
||||||
|
cmd = get_create_global_repo_cmd(compose, path_prefix)
|
||||||
|
t = threading.Thread(target=run_create_global_repo, args=(compose, cmd))
|
||||||
|
t.start()
|
||||||
|
|
||||||
|
package_sets = populate_arch_pkgsets(compose, path_prefix, pkgset_global)
|
||||||
|
package_sets["global"] = pkgset_global
|
||||||
|
|
||||||
|
t.join()
|
||||||
|
|
||||||
|
create_arch_repos(compose, path_prefix)
|
||||||
|
|
||||||
|
return package_sets
|
||||||
|
@ -19,7 +19,6 @@ from six.moves import cPickle as pickle
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
import threading
|
|
||||||
|
|
||||||
from kobo.rpmlib import parse_nvra
|
from kobo.rpmlib import parse_nvra
|
||||||
from kobo.shortcuts import force_list, relative_path
|
from kobo.shortcuts import force_list, relative_path
|
||||||
@ -31,10 +30,7 @@ from pungi.arch import get_valid_arches, getBaseArch
|
|||||||
from pungi.util import is_arch_multilib, retry, find_old_compose
|
from pungi.util import is_arch_multilib, retry, find_old_compose
|
||||||
from pungi import Modulemd
|
from pungi import Modulemd
|
||||||
|
|
||||||
from pungi.phases.pkgset.common import (create_arch_repos,
|
from pungi.phases.pkgset.common import materialize_pkgset
|
||||||
populate_arch_pkgsets,
|
|
||||||
get_create_global_repo_cmd,
|
|
||||||
run_create_global_repo)
|
|
||||||
from pungi.phases.gather import get_packages_to_gather
|
from pungi.phases.gather import get_packages_to_gather
|
||||||
|
|
||||||
import pungi.phases.pkgset.source
|
import pungi.phases.pkgset.source
|
||||||
@ -194,16 +190,7 @@ def get_pkgset_from_koji(compose, koji_wrapper, path_prefix):
|
|||||||
event_info = get_koji_event_info(compose, koji_wrapper)
|
event_info = get_koji_event_info(compose, koji_wrapper)
|
||||||
pkgset_global = populate_global_pkgset(compose, koji_wrapper, path_prefix, event_info)
|
pkgset_global = populate_global_pkgset(compose, koji_wrapper, path_prefix, event_info)
|
||||||
|
|
||||||
cmd = get_create_global_repo_cmd(compose, path_prefix)
|
package_sets = materialize_pkgset(compose, pkgset_global, path_prefix)
|
||||||
t = threading.Thread(target=run_create_global_repo, args=(compose, cmd))
|
|
||||||
t.start()
|
|
||||||
|
|
||||||
package_sets = populate_arch_pkgsets(compose, path_prefix, pkgset_global)
|
|
||||||
package_sets["global"] = pkgset_global
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
create_arch_repos(compose, path_prefix)
|
|
||||||
|
|
||||||
return package_sets
|
return package_sets
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import threading
|
|
||||||
from six.moves import cPickle as pickle
|
from six.moves import cPickle as pickle
|
||||||
|
|
||||||
from kobo.shortcuts import run
|
from kobo.shortcuts import run
|
||||||
@ -25,10 +24,7 @@ from pungi.arch import get_valid_arches
|
|||||||
from pungi.util import makedirs, is_arch_multilib
|
from pungi.util import makedirs, is_arch_multilib
|
||||||
from pungi.wrappers.pungi import PungiWrapper
|
from pungi.wrappers.pungi import PungiWrapper
|
||||||
|
|
||||||
from pungi.phases.pkgset.common import (run_create_global_repo,
|
from pungi.phases.pkgset.common import materialize_pkgset
|
||||||
get_create_global_repo_cmd,
|
|
||||||
create_arch_repos,
|
|
||||||
populate_arch_pkgsets)
|
|
||||||
from pungi.phases.gather import get_prepopulate_packages, get_packages_to_gather
|
from pungi.phases.gather import get_prepopulate_packages, get_packages_to_gather
|
||||||
from pungi.linker import LinkerPool
|
from pungi.linker import LinkerPool
|
||||||
|
|
||||||
@ -117,17 +113,8 @@ def get_pkgset_from_repos(compose):
|
|||||||
flist = sorted(set(flist))
|
flist = sorted(set(flist))
|
||||||
pkgset_global = populate_global_pkgset(compose, flist, path_prefix)
|
pkgset_global = populate_global_pkgset(compose, flist, path_prefix)
|
||||||
|
|
||||||
cmd = get_create_global_repo_cmd(compose, path_prefix)
|
package_sets = materialize_pkgset(compose, pkgset_global, path_prefix)
|
||||||
t = threading.Thread(target=run_create_global_repo, args=(compose, cmd))
|
|
||||||
t.start()
|
|
||||||
|
|
||||||
package_sets = populate_arch_pkgsets(compose, path_prefix, pkgset_global)
|
|
||||||
|
|
||||||
t.join()
|
|
||||||
|
|
||||||
create_arch_repos(compose, path_prefix)
|
|
||||||
|
|
||||||
package_sets["global"] = pkgset_global
|
|
||||||
return package_sets, path_prefix
|
return package_sets, path_prefix
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,10 +198,10 @@ class TestGetPackageSetFromKoji(helpers.PungiTestCase):
|
|||||||
self.koji_wrapper.koji_proxy.getLastEvent.return_value = EVENT_INFO
|
self.koji_wrapper.koji_proxy.getLastEvent.return_value = EVENT_INFO
|
||||||
self.koji_wrapper.koji_proxy.getTag.return_value = TAG_INFO
|
self.koji_wrapper.koji_proxy.getTag.return_value = TAG_INFO
|
||||||
|
|
||||||
@mock.patch('pungi.phases.pkgset.sources.source_koji.create_arch_repos')
|
@mock.patch('pungi.phases.pkgset.common.create_arch_repos')
|
||||||
@mock.patch('pungi.phases.pkgset.sources.source_koji.run_create_global_repo')
|
@mock.patch('pungi.phases.pkgset.common.run_create_global_repo')
|
||||||
@mock.patch('pungi.phases.pkgset.sources.source_koji.get_create_global_repo_cmd')
|
@mock.patch('pungi.phases.pkgset.common.get_create_global_repo_cmd')
|
||||||
@mock.patch('pungi.phases.pkgset.sources.source_koji.populate_arch_pkgsets')
|
@mock.patch('pungi.phases.pkgset.common.populate_arch_pkgsets')
|
||||||
@mock.patch('pungi.phases.pkgset.sources.source_koji.populate_global_pkgset')
|
@mock.patch('pungi.phases.pkgset.sources.source_koji.populate_global_pkgset')
|
||||||
def test_get_package_sets(self, pgp, pap, gcgrc, rcgr, car):
|
def test_get_package_sets(self, pgp, pap, gcgrc, rcgr, car):
|
||||||
expected = {'x86_64': mock.Mock()}
|
expected = {'x86_64': mock.Mock()}
|
||||||
|
Loading…
Reference in New Issue
Block a user