1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
// Copyright Contributors to the DNF5 project.
// Copyright Contributors to the libdnf project.
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// This file is part of libdnf: https://github.com/rpm-software-management/libdnf/
//
// Libdnf is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or
// (at your option) any later version.
//
// Libdnf is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#ifndef LIBDNF5_MODULE_MODULE_SACK_HPP
#define LIBDNF5_MODULE_MODULE_SACK_HPP
#include "module_status.hpp"
#include "libdnf5/base/base_weak.hpp"
#include "libdnf5/base/solver_problems.hpp"
#include "libdnf5/common/weak_ptr.hpp"
#include "libdnf5/defs.h"
#include "libdnf5/module/module_item.hpp"
#include "libdnf5/module/module_sack_weak.hpp"
#include <map>
#include <memory>
#include <string>
#include <vector>
namespace libdnf5 {
class Goal;
}
namespace libdnf5::base {
class Transaction;
}
namespace libdnf5::repo {
class Repo;
class RepoSack;
} // namespace libdnf5::repo
namespace libdnf5::module {
/// Container with data and methods related to modules
class LIBDNF_API ModuleSack {
public:
~ModuleSack();
ModuleSackWeakPtr get_weak_ptr();
/// @return All module items.
/// @since 5.0
const std::vector<std::unique_ptr<ModuleItem>> & get_modules();
/// @return Active module items. I.e. module items whose RPMs are included in the set of available packages.
/// @since 5.0
std::vector<ModuleItem *> get_active_modules();
// TODO(pkratoch): Implement getting default streams and profiles.
/// @return Default stream for given module.
/// @since 5.0
const std::string & get_default_stream(const std::string & name) const;
/// @return List of all default profiles for given module stream.
/// @since 5.0
std::vector<std::string> get_default_profiles(std::string module_name, std::string module_stream);
/// Resolve which module items are active. This means requesting all enabled streams or default streams (default
/// streams only from not-enabled non-disabled modules), while excluding all disabled module streams.
///
/// @return A pair of problems in resolving to report and GoalProblem.
/// @since 5.0
std::pair<base::SolverProblems, GoalProblem> resolve_active_module_items();
private:
friend class libdnf5::Base;
friend class libdnf5::Goal;
friend class libdnf5::base::Transaction;
friend class libdnf5::repo::Repo;
friend class libdnf5::repo::RepoSack;
friend ModuleItem;
friend class ModuleGoalPrivate;
friend class ModuleQuery;
LIBDNF_LOCAL ModuleSack(const BaseWeakPtr & base);
LIBDNF_LOCAL BaseWeakPtr get_base() const;
/// Load information about modules from file to ModuleSack. It is critical to load all module information from
/// all available repositories when modular metadata are available.
LIBDNF_LOCAL void add(const std::string & file_content, const std::string & repo_id);
// TODO(pkratoch): Implement adding defaults from "/etc/dnf/modules.defaults.d/", which are defined by user.
// They are added with priority 1000 after everything else is loaded.
/// Add and resolve defaults.
/// @since 5.0
//
// @replaces libdnf:ModulePackageContainer.hpp:method:ModulePackageContainer.addDefaultsFromDisk()
// @replaces libdnf:ModulePackageContainer.hpp:method:ModulePackageContainer.moduleDefaultsResolve()
LIBDNF_LOCAL void add_defaults_from_disk();
WeakPtrGuard<ModuleSack, false> data_guard;
bool active_modules_resolved = false;
class LIBDNF_LOCAL Impl;
std::unique_ptr<Impl> p_impl;
};
} // namespace libdnf5::module
#endif // LIBDNF5_MODULE_MODULE_SACK_HPP
|