Worked around RPM package resolution bug. (#4666)

* Worked around RPM package resolution bug.

* Fixed dependencies for `libkcapi`.
This commit is contained in:
Pawel Winogrodzki 2023-01-23 15:25:35 -08:00 коммит произвёл GitHub
Родитель 3583d84e61
Коммит 300602549f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 19 добавлений и 20 удалений

Просмотреть файл

@ -45,8 +45,8 @@ done \
ln -s libkcapi.so.%{version}.hmac \\\
"$lib_path"/fipscheck/libkcapi.so.%{vmajor}.hmac \
%{nil}
%global fipscheck_evr 1.5.0-9
%global hmaccalc_evr 0.9.14-10%{?dist}
%global fipscheck_next_evr 1.5.0-10%{?dist}
%global hmaccalc_next_evr 0.9.14-11%{?dist}
%if %{with_sysctl_tweak}
# Priority for the sysctl.d preset.
%global sysctl_prio 50
@ -58,7 +58,7 @@ ln -s libkcapi.so.%{version}.hmac \\\
Summary: User space interface to the Linux Kernel Crypto API
Name: libkcapi
Version: %{vmajor}.%{vminor}.%{vpatch}
Release: 1%{?dist}
Release: 2%{?dist}
License: BSD OR GPLv2
Vendor: Microsoft Corporation
Distribution: Mariner
@ -105,9 +105,9 @@ Header files for applications that use %{name}.
%package fipscheck
Summary: Drop-in replacements for fipscheck/fipshmac provided by the %{name} package
Requires: %{name}%{?_isa} = %{version}-%{release}
Obsoletes: fipscheck <= %{fipscheck_evr}
Provides: fipscheck = %{fipscheck_evr}.1
Provides: fipscheck%{?_isa} = %{fipscheck_evr}.1
Obsoletes: fipscheck < %{fipscheck_next_evr}
Provides: fipscheck = %{fipscheck_next_evr}
Provides: fipscheck%{?_isa} = %{fipscheck_next_evr}
%description fipscheck
Provides drop-in replacements for fipscheck and fipshmac tools (from
@ -116,9 +116,9 @@ package fipscheck) using %{name}.
%package hmaccalc
Summary: Drop-in replacements for hmaccalc provided by the %{name} package
Requires: %{name}%{?_isa} = %{version}-%{release}
Obsoletes: hmaccalc <= %{hmaccalc_evr}
Provides: hmaccalc = %{hmaccalc_evr}.1
Provides: hmaccalc%{?_isa} = %{hmaccalc_evr}.1
Obsoletes: hmaccalc < %{hmaccalc_next_evr}
Provides: hmaccalc = %{hmaccalc_next_evr}
Provides: hmaccalc%{?_isa} = %{hmaccalc_next_evr}
%description hmaccalc
Provides drop-in replacements for sha*hmac tools (from package
@ -256,6 +256,9 @@ find %{buildroot} -type f -name "*.la" -delete -print
%{_libexecdir}/%{name}/*
%changelog
* Thu Jan 19 2023 Pawel Winogrodzki <pawelwi@microsoft.com> - 1.3.1-2
- Fixing 'Obsoletes' and 'Provides' for 'fipscheck' and 'hmaccalc' subpackages.
* Mon Jan 10 2022 Henry Li <lihl@microsoft.com> - 1.3.1-1
- Upgrade to version 1.3.1

Просмотреть файл

@ -323,7 +323,6 @@ func (r *RpmRepoCloner) WhatProvides(pkgVer *pkgjson.PackageVer) (packageNames [
releaseverCliArg,
}
foundPackages := make(map[string]bool)
// Consider the built (local) RPMs first, then the already cached (e.g. tooolchain), and finally all remote packages.
repoOrderList := []string{builtRepoID, cacheRepoID, allRepoIDs}
for _, repoID := range repoOrderList {
@ -344,12 +343,13 @@ func (r *RpmRepoCloner) WhatProvides(pkgVer *pkgjson.PackageVer) (packageNames [
return
}
// MUST keep order of packages printed by TDNF.
// TDNF will print the packages starting from the highest version, which allows us to work around an RPM bug:
// https://github.com/rpm-software-management/rpm/issues/2359
for _, matches := range packageLookupNameMatchRegex.FindAllStringSubmatch(stdout, -1) {
packageName := matches[packageNameIndex]
if _, found := foundPackages[packageName]; !found {
foundPackages[packageName] = true
logger.Log.Debugf("'%s' is available from package '%s'", pkgVer.Name, packageName)
}
packageNames = append(packageNames, packageName)
logger.Log.Debugf("'%s' is available from package '%s'", pkgVer.Name, packageName)
}
return
@ -358,21 +358,17 @@ func (r *RpmRepoCloner) WhatProvides(pkgVer *pkgjson.PackageVer) (packageNames [
return
}
if len(foundPackages) > 0 {
if len(packageNames) > 0 {
logger.Log.Debug("Found required package(s), skipping further search in other repos.")
break
}
}
if len(foundPackages) == 0 {
if len(packageNames) == 0 {
err = fmt.Errorf("could not resolve %s", pkgVer.Name)
return
}
for packageName := range foundPackages {
packageNames = append(packageNames, packageName)
}
logger.Log.Debugf("Translated '%s' to package(s): %s", pkgVer.Name, strings.Join(packageNames, " "))
return
}