ALBS-66: Prepare Jenkins jobs for building distribution of AlmaLinux 8.5

- Script `create_packages_json` can duplicate the packages with
  same version in different variants

Change-Id: I3c79ad06c4c22442423c12d5fa06baf82d663a3f
This commit is contained in:
soksanichenko 2021-11-10 15:29:59 +02:00
parent b2c49dcaf6
commit f2ed64d952

View File

@ -271,7 +271,7 @@ class PackagesGenerator:
)
)
)
all_packages = defaultdict(dict)
all_packages = defaultdict(lambda: {'variants': list()})
for repo_info in self.repos:
packages = {} # type: Dict[AnyStr, cr.Package]
repomd_records = self._get_repomd_records(
@ -292,7 +292,9 @@ class PackagesGenerator:
# it presents in the list of included packages
continue
if package_key not in all_packages:
all_packages[package_key]['variant'] = repo_info.name
all_packages[package_key]['variants'].append(
repo_info.name
)
all_packages[package_key]['arch'] = repo_info.arch
all_packages[package_key]['package'] = package
all_packages[package_key]['type'] = repo_info.is_reference
@ -305,37 +307,44 @@ class PackagesGenerator:
package,
all_packages[package_key]['package']
) > 0:
all_packages[package_key]['variant'] = repo_info.name
all_packages[package_key]['variants'] = [repo_info.name]
all_packages[package_key]['arch'] = repo_info.arch
all_packages[package_key]['package'] = package
elif self.compare_pkgs_version(
package,
all_packages[package_key]['package']
) == 0:
all_packages[package_key]['variants'].append(
repo_info.name
)
for package_dict in all_packages.values():
repo_name = package_dict['variant']
repo_arch = package_dict['arch']
package = package_dict['package']
package_name = package.name
package_arch = package.arch
if any(re.search(excluded_package, package_name)
for excluded_package in self.excluded_packages):
continue
src_package_name = dnf.subject.Subject(
package.rpm_sourcerpm,
).get_nevra_possibilities(
forms=hawkey.FORM_NEVRA,
)
if len(src_package_name) > 1:
# We should stop utility if we can't get exact name of srpm
raise ValueError(
'We can\'t get exact name of srpm '
f'by its NEVRA "{package.rpm_sourcerpm}"'
for variant in package_dict['variants']:
repo_arch = package_dict['arch']
package = package_dict['package']
package_name = package.name
package_arch = package.arch
if any(re.search(excluded_package, package_name)
for excluded_package in self.excluded_packages):
continue
src_package_name = dnf.subject.Subject(
package.rpm_sourcerpm,
).get_nevra_possibilities(
forms=hawkey.FORM_NEVRA,
)
else:
src_package_name = src_package_name[0].name
pkgs_list = packages_json[repo_name][
repo_arch][src_package_name]
added_pkg = f'{package_name}.{package_arch}'
if added_pkg not in pkgs_list:
pkgs_list.append(added_pkg)
if len(src_package_name) > 1:
# We should stop utility if we can't get exact name of srpm
raise ValueError(
'We can\'t get exact name of srpm '
f'by its NEVRA "{package.rpm_sourcerpm}"'
)
else:
src_package_name = src_package_name[0].name
pkgs_list = packages_json[variant][
repo_arch][src_package_name]
added_pkg = f'{package_name}.{package_arch}'
if added_pkg not in pkgs_list:
pkgs_list.append(added_pkg)
return packages_json