Browse Source

Allow ignoring certain dependencies/libraries when checking for problems

move-only-function
Martchus 1 year ago
parent
commit
5127ca351f
  1. 32
      libpkg/data/database.cpp
  2. 6
      libpkg/data/database.h
  3. 13
      librepomgr/buildactions/buildactionmeta.cpp
  4. 1
      librepomgr/buildactions/buildactionmeta.h
  5. 14
      librepomgr/buildactions/repomanagement.cpp

32
libpkg/data/database.cpp

@ -191,14 +191,18 @@ void Database::replacePackages(const std::vector<std::shared_ptr<Package>> &newP
}
/*!
* \brief Determines which packages are unresolvable.
* \brief Determines which packages are unresolvable assuming new packages are added to the database and certain provides are removed.
* \param config The configuration supposed to contain database dependencies.
* \param newPackages Packages which should be added to the database.
* \param removedProvides Provides which will be removed from the database.
* \remarks "Resolvable" means here (so far) just that all dependencies are present. It does not mean "installable".
* \param newPackages Packages which are assumed to be added to the database.
* \param removedProvides Provides which are assumed to be removed from the database.
* \param depsToIgnore Specifies dependencies to be ignored if missing (version constraints not supported).
* \param libsToIgnore Specifies libraries to be ignored if missing.
* \remarks "Resolvable" means here (so far) just that all dependencies are present. It does not mean a package is "installable" because
* conflicts between dependencies might still prevent that.
*/
std::unordered_map<std::shared_ptr<Package>, UnresolvedDependencies> Database::detectUnresolvedPackages(
Config &config, const std::vector<std::shared_ptr<Package>> &newPackages, const DependencySet &removedProvides)
std::unordered_map<std::shared_ptr<Package>, UnresolvedDependencies> Database::detectUnresolvedPackages(Config &config,
const std::vector<std::shared_ptr<Package>> &newPackages, const DependencySet &removedProvides,
const std::unordered_set<std::string_view> &depsToIgnore, const std::unordered_set<std::string_view> &libsToIgnore)
{
std::unordered_map<std::shared_ptr<Package>, UnresolvedDependencies> unresolvedPackages;
@ -220,6 +224,11 @@ std::unordered_map<std::shared_ptr<Package>, UnresolvedDependencies> Database::d
const auto &[dependencyName, dependencyDetail] = requiredDep;
const auto &affectedPackages = dependencyDetail.relevantPackages;
// skip dependencies to ignore
if (depsToIgnore.find(dependencyName) != depsToIgnore.end()) {
continue;
}
// skip if new packages provide dependency
if (newProvides.provides(dependencyName, dependencyDetail)) {
continue;
@ -263,20 +272,25 @@ std::unordered_map<std::shared_ptr<Package>, UnresolvedDependencies> Database::d
// check whether all required libraries are still provided
for (const auto &[requiredLib, affectedPackages] : requiredLibs) {
// skip libs to ignore
if (libsToIgnore.find(requiredLib) != libsToIgnore.end()) {
continue;
}
// skip if new packages provide dependency
if (newLibProvides.count(requiredLib)) {
if (newLibProvides.find(requiredLib) != newLibProvides.end()) {
continue;
}
// skip if db provides dependency
if (providedLibs.count(requiredLib)) {
if (providedLibs.find(requiredLib) != providedLibs.end()) {
continue;
}
// skip if dependency is provided by a database this database depends on
const auto checkDb = [this, &config, &requiredLib = requiredLib](const std::string &dbName) {
if (const auto *const db = config.findDatabase(dbName, arch)) {
if (db->providedLibs.count(requiredLib)) {
if (db->providedLibs.find(requiredLib) != db->providedLibs.end()) {
return true;
}
}

6
libpkg/data/database.h

@ -113,8 +113,10 @@ struct LIBPKG_EXPORT Database : public ReflectiveRapidJSON::JsonSerializable<Dat
void updatePackage(const std::shared_ptr<Package> &package);
void forceUpdatePackage(const std::shared_ptr<Package> &package);
void replacePackages(const std::vector<std::shared_ptr<Package>> &newPackages, CppUtilities::DateTime lastModified);
std::unordered_map<std::shared_ptr<Package>, UnresolvedDependencies> detectUnresolvedPackages(
Config &config, const std::vector<std::shared_ptr<Package>> &newPackages, const DependencySet &removedPackages);
std::unordered_map<std::shared_ptr<Package>, UnresolvedDependencies> detectUnresolvedPackages(Config &config,
const std::vector<std::shared_ptr<Package>> &newPackages, const DependencySet &removedPackages,
const std::unordered_set<std::string_view> &depsToIgnore = std::unordered_set<std::string_view>(),
const std::unordered_set<std::string_view> &libsToIgnore = std::unordered_set<std::string_view>());
PackageUpdates checkForUpdates(const std::vector<Database *> &updateSources, UpdateCheckOptions options = UpdateCheckOptions::None);
PackageLocation locatePackage(const std::string &packageName) const;
std::string filesPathFromRegularPath() const;

13
librepomgr/buildactions/buildactionmeta.cpp

@ -246,7 +246,18 @@ BuildActionMetaInfo::BuildActionMetaInfo()
.name = "Check for problems",
.type = "check-for-problems",
.flags = {},
.settings = {},
.settings = {
BuildActionSettingMetaInfo{
.name = "Dependencies to ignore",
.desc = "A white-space separated list of dependencies not to care about if missing (version constraints not supported)",
.param = "ignore-optdepts",
},
BuildActionSettingMetaInfo{
.name = "Libraries to ignore",
.desc = "A white-space separated list of library dependencies not to care about if missing",
.param = "ignore-libdeps",
},
},
.directory = true,
.sourceDb = false,
.destinationDb = true,

1
librepomgr/buildactions/buildactionmeta.h

@ -78,6 +78,7 @@ enum class CleanRepositoryFlags : BuildActionFlagType {
None,
DryRun = (1 << 0),
};
enum class CheckForProblemsSettings : std::size_t { IgnoreDeps, IgnoreLibDeps };
enum class PrepareBuildSettings : std::size_t { PKGBUILDsDirs };
enum class ConductBuildSettings : std::size_t { ChrootDir, ChrootDefaultUser, CCacheDir, PackageCacheDir, TestFilesDir };
enum class CustomCommandSettings : std::size_t { Command };

14
librepomgr/buildactions/repomanagement.cpp

@ -378,6 +378,16 @@ CheckForProblems::CheckForProblems(ServiceSetup &setup, const std::shared_ptr<Bu
void CheckForProblems::run()
{
// read settings
auto &metaInfo = m_setup.building.metaInfo;
auto metaInfoLock = metaInfo.lockToRead();
const auto &typeInfo = metaInfo.typeInfoForId(BuildActionType::CheckForProblems);
const auto ignoreDepsSetting = typeInfo.settings[static_cast<std::size_t>(CheckForProblemsSettings::IgnoreDeps)].param;
const auto ignoreLibDepsSetting = typeInfo.settings[static_cast<std::size_t>(CheckForProblemsSettings::IgnoreLibDeps)].param;
metaInfoLock.unlock();
const auto ignoreDeps = splitStringSimple<std::unordered_set<std::string_view>>(std::string_view(findSetting(ignoreDepsSetting)), " ");
const auto ignoreLibDeps = splitStringSimple<std::unordered_set<std::string_view>>(std::string_view(findSetting(ignoreLibDepsSetting)), " ");
// initialize build action
auto configReadLock = init(BuildActionAccess::ReadConfig, RequiredDatabases::OneOrMoreDestinations, RequiredParameters::None);
if (std::holds_alternative<std::monostate>(configReadLock)) {
@ -419,8 +429,8 @@ void CheckForProblems::run()
}
// check for unresolved dependencies and missing libraries
checkForUnresolvedPackages:
auto unresolvedPackages
= db->detectUnresolvedPackages(m_setup.config, std::vector<std::shared_ptr<LibPkg::Package>>(), LibPkg::DependencySet());
auto unresolvedPackages = db->detectUnresolvedPackages(
m_setup.config, std::vector<std::shared_ptr<LibPkg::Package>>(), LibPkg::DependencySet(), ignoreDeps, ignoreLibDeps);
for (auto &[package, unresolvedDeps] : unresolvedPackages) {
problems.emplace_back(RepositoryProblem{ .desc = std::move(unresolvedDeps), .pkg = package->name });
}

Loading…
Cancel
Save