diff --git a/pungi/paths.py b/pungi/paths.py index 67c24d10..857c2b8f 100644 --- a/pungi/paths.py +++ b/pungi/paths.py @@ -425,13 +425,13 @@ class WorkPaths(object): makedirs(path) return path - def pkgset_file_cache(self): + def pkgset_file_cache(self, pkgset_name): """ Returns the path to file in which the cached version of PackageSetBase.file_cache should be stored. """ - return os.path.join( - self.topdir(arch="global"), "pkgset_file_cache.pickle") + filename = "pkgset_%s_file_cache.pickle" % pkgset_name + return os.path.join(self.topdir(arch="global"), filename) class ComposePaths(object): diff --git a/pungi/phases/pkgset/common.py b/pungi/phases/pkgset/common.py index 02defd4e..b7081ee1 100644 --- a/pungi/phases/pkgset/common.py +++ b/pungi/phases/pkgset/common.py @@ -59,6 +59,7 @@ def get_create_global_repo_cmd(compose, path_prefix, repo_dir_global, pkgset): compose.paths.work.package_list(arch="global", pkgset=pkgset), remove_path_prefix=path_prefix, ) + pkgset.save_file_cache(compose.paths.work.pkgset_file_cache(pkgset.name)) # find an old compose suitable for repodata reuse old_compose_path = None diff --git a/pungi/phases/pkgset/sources/source_koji.py b/pungi/phases/pkgset/sources/source_koji.py index cb7ab137..01d200f4 100644 --- a/pungi/phases/pkgset/sources/source_koji.py +++ b/pungi/phases/pkgset/sources/source_koji.py @@ -476,7 +476,7 @@ def _get_modules_from_koji_tags( ) -def _find_old_file_cache_path(compose): +def _find_old_file_cache_path(compose, tag_name): """ Finds the old compose with "pkgset_file_cache.pickled" and returns the path to it. If no compose is found, returns None. @@ -492,7 +492,7 @@ def _find_old_file_cache_path(compose): if not old_compose_path: return None - old_file_cache_dir = compose.paths.work.pkgset_file_cache() + old_file_cache_dir = compose.paths.work.pkgset_file_cache(tag_name) rel_dir = relative_path(old_file_cache_dir, compose.topdir.rstrip('/') + '/') old_file_cache_path = os.path.join(old_compose_path, rel_dir) if not os.path.exists(old_file_cache_path): @@ -596,7 +596,16 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event): populate_only_packages=populate_only_packages_to_gather, cache_region=compose.cache_region, extra_builds=extra_builds) - # TODO find cache for this tag + + # Check if we have cache for this tag from previous compose. If so, use + # it. + old_cache_path = _find_old_file_cache_path(compose, compose_tag) + if old_cache_path: + pkgset.set_old_file_cache( + pungi.phases.pkgset.pkgsets.KojiPackageSet.load_old_file_cache( + old_cache_path + ) + ) is_traditional = compose_tag in compose.conf.get("pkgset_koji_tag", []) should_inherit = inherit if is_traditional else inherit_modules @@ -640,8 +649,6 @@ def populate_global_pkgset(compose, koji_wrapper, path_prefix, event): # Optimization for case where we have just single compose # tag - we do not have to merge in this case... variant.pkgsets.add(compose_tag) - # TODO pickle pkgset to disk - # TODO save pkgset file cache pkgsets.append( MaterializedPackageSet.create( compose, pkgset, path_prefix, mmd=tag_to_mmd.get(pkgset.name)