Reuse arch pkgset repos
JIRA: COMPOSE-4217 Signed-off-by: Haibo Lin <hlin@redhat.com>
This commit is contained in:
parent
63ec1adc22
commit
65251d983a
@ -22,7 +22,12 @@ from kobo.threads import run_in_threads
|
|||||||
|
|
||||||
from pungi.arch import get_valid_arches
|
from pungi.arch import get_valid_arches
|
||||||
from pungi.wrappers.createrepo import CreaterepoWrapper
|
from pungi.wrappers.createrepo import CreaterepoWrapper
|
||||||
from pungi.util import is_arch_multilib, PartialFuncWorkerThread, PartialFuncThreadPool
|
from pungi.util import (
|
||||||
|
copy_all,
|
||||||
|
is_arch_multilib,
|
||||||
|
PartialFuncWorkerThread,
|
||||||
|
PartialFuncThreadPool,
|
||||||
|
)
|
||||||
from pungi.module_util import Modulemd, collect_module_defaults
|
from pungi.module_util import Modulemd, collect_module_defaults
|
||||||
from pungi.phases.createrepo import add_modular_metadata
|
from pungi.phases.createrepo import add_modular_metadata
|
||||||
|
|
||||||
@ -85,8 +90,9 @@ def run_create_global_repo(compose, cmd, logfile):
|
|||||||
|
|
||||||
|
|
||||||
def create_arch_repos(compose, path_prefix, paths, pkgset, mmds):
|
def create_arch_repos(compose, path_prefix, paths, pkgset, mmds):
|
||||||
|
reuse = getattr(pkgset, "reuse", None)
|
||||||
run_in_threads(
|
run_in_threads(
|
||||||
_create_arch_repo,
|
_create_arch_repo if reuse is None else _reuse_arch_repo,
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
compose,
|
compose,
|
||||||
@ -150,6 +156,19 @@ def _create_arch_repo(worker_thread, args, task_num):
|
|||||||
compose.log_info("[DONE ] %s", msg)
|
compose.log_info("[DONE ] %s", msg)
|
||||||
|
|
||||||
|
|
||||||
|
def _reuse_arch_repo(worker_thread, args, task_num):
|
||||||
|
"""Reuse a single pkgset repo for given arch."""
|
||||||
|
compose, arch, _, paths, pkgset, _ = args
|
||||||
|
repo_dir = compose.paths.work.pkgset_repo(pkgset.name, arch=arch)
|
||||||
|
paths[arch] = repo_dir
|
||||||
|
old_repo_dir = compose.paths.old_compose_path(repo_dir)
|
||||||
|
msg = "Copying repodata for reuse: %s" % old_repo_dir
|
||||||
|
|
||||||
|
compose.log_info("[BEGIN] %s", msg)
|
||||||
|
copy_all(old_repo_dir, repo_dir)
|
||||||
|
compose.log_info("[DONE ] %s", msg)
|
||||||
|
|
||||||
|
|
||||||
class MaterializedPackageSet(object):
|
class MaterializedPackageSet(object):
|
||||||
"""A wrapper for PkgsetBase object that represents the package set created
|
"""A wrapper for PkgsetBase object that represents the package set created
|
||||||
as repos on the filesystem.
|
as repos on the filesystem.
|
||||||
|
@ -114,3 +114,89 @@ class TestMaterializedPkgsetCreate(helpers.PungiTestCase):
|
|||||||
os.path.join(self.topdir, "logs/x86_64/arch_repo_modulemd.foo.x86_64.log"),
|
os.path.join(self.topdir, "logs/x86_64/arch_repo_modulemd.foo.x86_64.log"),
|
||||||
)
|
)
|
||||||
cmd.return_value.add_module_stream.assert_called_once_with(mmd["x86_64"][0])
|
cmd.return_value.add_module_stream.assert_called_once_with(mmd["x86_64"][0])
|
||||||
|
|
||||||
|
|
||||||
|
class TestCreateArchRepos(helpers.PungiTestCase):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestCreateArchRepos, self).setUp()
|
||||||
|
self.compose = helpers.DummyCompose(self.topdir, {})
|
||||||
|
self.prefix = "/prefix"
|
||||||
|
self.paths = {}
|
||||||
|
self.pkgset = mock.Mock()
|
||||||
|
self.pkgset.reuse = None
|
||||||
|
self.pkgset.name = "foo"
|
||||||
|
|
||||||
|
@mock.patch("pungi.phases.pkgset.common._create_arch_repo")
|
||||||
|
def test_call_create_arch_repo(self, mock_create):
|
||||||
|
common.create_arch_repos(
|
||||||
|
self.compose, self.prefix, self.paths, self.pkgset, None
|
||||||
|
)
|
||||||
|
mock_create.assert_has_calls(
|
||||||
|
[
|
||||||
|
mock.call(
|
||||||
|
mock.ANY,
|
||||||
|
(self.compose, "amd64", self.prefix, self.paths, self.pkgset, None),
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
mock.call(
|
||||||
|
mock.ANY,
|
||||||
|
(
|
||||||
|
self.compose,
|
||||||
|
"x86_64",
|
||||||
|
self.prefix,
|
||||||
|
self.paths,
|
||||||
|
self.pkgset,
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
@mock.patch("pungi.phases.pkgset.common._reuse_arch_repo")
|
||||||
|
def test_call_reuse_arch_repo(self, mock_reuse):
|
||||||
|
self.pkgset.reuse = "/path/to/old/global/repo"
|
||||||
|
common.create_arch_repos(
|
||||||
|
self.compose, self.prefix, self.paths, self.pkgset, None
|
||||||
|
)
|
||||||
|
mock_reuse.assert_has_calls(
|
||||||
|
[
|
||||||
|
mock.call(
|
||||||
|
mock.ANY,
|
||||||
|
(self.compose, "amd64", self.prefix, self.paths, self.pkgset, None),
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
mock.call(
|
||||||
|
mock.ANY,
|
||||||
|
(
|
||||||
|
self.compose,
|
||||||
|
"x86_64",
|
||||||
|
self.prefix,
|
||||||
|
self.paths,
|
||||||
|
self.pkgset,
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
@mock.patch("pungi.phases.pkgset.common.copy_all")
|
||||||
|
def test_reuse_arch_repo(self, mock_copy_all):
|
||||||
|
self.pkgset.reuse = "/path/to/old/global/repo"
|
||||||
|
old_repo = "/path/to/old/repo"
|
||||||
|
self.compose.paths.old_compose_path = mock.Mock(return_value=old_repo)
|
||||||
|
common._reuse_arch_repo(
|
||||||
|
mock.Mock(),
|
||||||
|
(self.compose, "x86_64", self.prefix, self.paths, self.pkgset, None),
|
||||||
|
1,
|
||||||
|
)
|
||||||
|
mock_copy_all.assert_called_once_with(
|
||||||
|
old_repo, os.path.join(self.compose.topdir, "work/x86_64/repo/foo")
|
||||||
|
)
|
||||||
|
self.compose.log_info.assert_has_calls(
|
||||||
|
[
|
||||||
|
mock.call("[BEGIN] %s", "Copying repodata for reuse: %s" % old_repo),
|
||||||
|
mock.call("[DONE ] %s", "Copying repodata for reuse: %s" % old_repo),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user