Optionally do old_compose per release type

This would make sure that e.g. "updates" composes don't try to use "updates-testing" as an
old_compose_path, which would create practically useless deltarpms and for no repodata
reuse at all.

Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
This commit is contained in:
Patrick Uiterwijk 2017-11-06 14:56:08 +01:00
parent 385002fe94
commit 1a10a1fe83
5 changed files with 33 additions and 3 deletions

View File

@ -626,6 +626,10 @@ def make_schema():
"enum": ["yum", "dnf"],
},
"old_composes_per_release_type": {
"type": "boolean",
"default": False,
},
"hashed_directories": {
"type": "boolean",
"default": False,

View File

@ -275,6 +275,7 @@ def _get_old_package_dirs(compose, repo_dir):
compose.old_composes,
compose.ci_base.release.short,
compose.ci_base.release.version,
compose.ci_base.release.type_suffix if compose.conf['old_composes_per_release_type'] else None,
compose.ci_base.base_product.short if compose.ci_base.release.is_layered else None,
compose.ci_base.base_product.version if compose.ci_base.release.is_layered else None,
allowed_statuses=['FINISHED', 'FINISHED_INCOMPLETE'],

View File

@ -55,7 +55,14 @@ def create_global_repo(compose, path_prefix):
old_compose_path = None
update_md_path = None
if compose.old_composes:
old_compose_path = find_old_compose(compose.old_composes, compose.conf["release_short"], compose.conf["release_version"], compose.conf.get("base_product_short"), compose.conf.get("base_product_version"))
old_compose_path = find_old_compose(
compose.old_composes,
compose.ci_base.release.short,
compose.ci_base.release.version,
compose.ci_base.release.type_suffix if compose.conf['old_composes_per_release_type'] else None,
compose.ci_base.base_product.short if compose.ci_base.release.is_layered else None,
compose.ci_base.base_product.version if compose.ci_base.release.is_layered else None,
)
if old_compose_path is None:
compose.log_info("No suitable old compose found in: %s" % compose.old_composes)
else:

View File

@ -395,8 +395,8 @@ def get_file_size(path):
def find_old_compose(old_compose_dirs, release_short, release_version,
base_product_short=None, base_product_version=None,
allowed_statuses=None):
release_type_suffix=None, base_product_short=None,
base_product_version=None, allowed_statuses=None):
allowed_statuses = allowed_statuses or ("FINISHED", "FINISHED_INCOMPLETE", "DOOMED")
composes = []
@ -417,6 +417,8 @@ def find_old_compose(old_compose_dirs, release_short, release_version,
# TODO: read .composeinfo
pattern = "%s-%s" % (release_short, release_version)
if release_type_suffix:
pattern += release_type_suffix
if base_product_short:
pattern += "-%s" % base_product_short
if base_product_version:
@ -425,6 +427,12 @@ def find_old_compose(old_compose_dirs, release_short, release_version,
if not i.startswith(pattern):
continue
suffix = i[len(pattern):]
if release_type_suffix and (len(suffix) < 2 or not suffix[1].isdigit()):
# This covers the case where we are looking for -updates, but there
# is an updates-testing as well.
continue
path = os.path.join(compose_dir, i)
if not os.path.isdir(path):
continue

View File

@ -253,6 +253,16 @@ class TestFindOldCompose(unittest.TestCase):
old = util.find_old_compose(self.tmp_dir, 'Fedora', 'Rawhide')
self.assertEqual(old, self.tmp_dir + '/Fedora-Rawhide-20160229.1')
def test_find_correct_type(self):
touch(self.tmp_dir + '/Fedora-26-updates-20160229.0/STATUS', 'FINISHED')
touch(self.tmp_dir + '/Fedora-26-updates-testing-20160229.0/STATUS', 'FINISHED')
old = util.find_old_compose(self.tmp_dir, 'Fedora', '26', '-updates')
self.assertEqual(old, self.tmp_dir + '/Fedora-26-updates-20160229.0')
old = util.find_old_compose(self.tmp_dir, 'Fedora', '26', '-updates-testing')
self.assertEqual(old, self.tmp_dir + '/Fedora-26-updates-testing-20160229.0')
old = util.find_old_compose(self.tmp_dir, 'Fedora', '26')
self.assertEqual(old, self.tmp_dir + '/Fedora-26-updates-testing-20160229.0')
def test_find_latest_with_two_digit_respin(self):
touch(self.tmp_dir + '/Fedora-Rawhide-20160228.n.9/STATUS', 'FINISHED')
touch(self.tmp_dir + '/Fedora-Rawhide-20160228.n.10/STATUS', 'FINISHED')