diff --git a/include/libdnf5/repo/repo.hpp b/include/libdnf5/repo/repo.hpp index fb64c28321..1b2c971258 100644 --- a/include/libdnf5/repo/repo.hpp +++ b/include/libdnf5/repo/repo.hpp @@ -149,22 +149,12 @@ class Repo { /// @return `true` if metadata are in sync with the origin, `false` otherwise. bool is_in_sync(); - /// @deprecated It is going to be removed without a warning - /// Downloads repository metadata. - // @replaces libdnf:repo/Repo.hpp:method:Repo.downloadMetadata(const std::string & destdir) - void download_metadata(const std::string & destdir); - /// @deprecated It is going to be removed without a warning /// Loads the repository objects into sacks. /// /// Also writes the libsolv's solv/solvx cache files. void load(); - /// Not API, unsupported - /// Append a rpm database into the system repository. The type of the repo must be Type::SYSTEM. - // TODO(jrohel) this will add packages with conflicting rpmdb ids, which will break some operations - void load_extra_system_repo(const std::string & rootdir); - /// Returns whether the using of "includes" is enabled /// If enabled, only packages listed in the "includepkgs" will be used from the repository. // @replaces libdnf:repo/Repo.hpp:method:Repo.getUseIncludes() @@ -318,29 +308,6 @@ class Repo { // @replaces libdnf:repo/Repo.hpp:method:Repo.getMirrors() std::vector get_mirrors() const; - /// @deprecated It is redundant because repo class has direct access to Base and Vars - /// Sets substitutions. Substitutions are used to substitute variables in repository configuration. - // @replaces libdnf:repo/Repo.hpp:method:Repo.setSubstitutions(const std::map & substitutions) - void set_substitutions(const std::map & substitutions); - - /// @deprecated It is going to be removed without a warning - /// Not API, unsupported - void add_libsolv_testcase(const std::string & path); - - /// @deprecated It is going to be removed without a warning - /// Not API, unsupported - /// Adds an RPM package at `path` to the repository. - /// - /// If `with_hdrid` is `true`, the RPM is loaded with the - /// `RPM_ADD_WITH_HDRID | RPM_ADD_WITH_SHA256SUM` flags, meaning libsolv will - /// calculate the SHA256 checksum of the RPM header and store it. This adds - /// overhead but has the advantage of TODO(lukash) describe the advantage. - /// @param path The path to the RPM file. - /// @param with_hdrid If true, libsolv calculates header checksum and stores it. - /// @throws RepoRpmError if the RPM file can't be read or is corrupted. - /// @return PackageId of the added package. - libdnf5::rpm::Package add_rpm_package(const std::string & path, bool with_hdrid); - libdnf5::repo::RepoWeakPtr get_weak_ptr(); /// @return The `Base` object to which this object belongs. @@ -359,6 +326,24 @@ class Repo { friend class PackageDownloader; friend class solv::Pool; + /// Downloads repository metadata. + // @replaces libdnf:repo/Repo.hpp:method:Repo.downloadMetadata(const std::string & destdir) + void download_metadata(const std::string & destdir); + + void add_libsolv_testcase(const std::string & path); + + /// Adds an RPM package at `path` to the repository. + /// + /// If `with_hdrid` is `true`, the RPM is loaded with the + /// `RPM_ADD_WITH_HDRID | RPM_ADD_WITH_SHA256SUM` flags, meaning libsolv will + /// calculate the SHA256 checksum of the RPM header and store it. This adds + /// overhead but has the advantage of TODO(lukash) describe the advantage. + /// @param path The path to the RPM file. + /// @param with_hdrid If true, libsolv calculates header checksum and stores it. + /// @throws RepoRpmError if the RPM file can't be read or is corrupted. + /// @return PackageId of the added package. + libdnf5::rpm::Package add_rpm_package(const std::string & path, bool with_hdrid); + void make_solv_repo(); void load_available_repo(); diff --git a/libdnf5/repo/repo.cpp b/libdnf5/repo/repo.cpp index f995fdd149..2efccb3b64 100644 --- a/libdnf5/repo/repo.cpp +++ b/libdnf5/repo/repo.cpp @@ -237,12 +237,6 @@ void Repo::load() { p_impl->loaded = true; } -void Repo::load_extra_system_repo(const std::string & rootdir) { - libdnf_user_assert(p_impl->type == Type::SYSTEM, "repo type must be SYSTEM to load an extra system repo"); - libdnf_user_assert(p_impl->solv_repo, "repo must be loaded to load an extra system repo"); - p_impl->solv_repo->load_system_repo(rootdir); -} - void Repo::add_libsolv_testcase(const std::string & path) { make_solv_repo(); @@ -306,10 +300,6 @@ int Repo::get_expires_in() const { return p_impl->config.get_metadata_expire_option().get_value() - static_cast(get_age()); } -void Repo::set_substitutions(const std::map & substitutions) { - p_impl->downloader->substitutions = substitutions; -} - std::string Repo::get_metadata_path(const std::string & metadata_type) { return p_impl->downloader->get_metadata_path(metadata_type); } diff --git a/test/libdnf5/rpm/test_package_query.cpp b/test/libdnf5/rpm/test_package_query.cpp index 5cafc38938..68d4aecb5e 100644 --- a/test/libdnf5/rpm/test_package_query.cpp +++ b/test/libdnf5/rpm/test_package_query.cpp @@ -20,6 +20,7 @@ along with libdnf. If not, see . #include "test_package_query.hpp" +#include "../shared/private_accessor.hpp" #include "../shared/utils.hpp" #include @@ -36,6 +37,9 @@ using namespace libdnf5::rpm; namespace { +create_private_getter_template; +create_getter(add_rpm_package, &libdnf5::repo::Repo::add_rpm_package); + // make constructor public so we can create Package instances in the tests class TestPackage : public Package { public: @@ -347,7 +351,7 @@ void RpmPackageQueryTest::test_filter_nevra_packgset() { add_repo_solv("solv-repo1"); std::string rpm_path = "cmdline-rpms/cmdline-1.2-3.noarch.rpm"; - repo_sack->get_system_repo()->add_rpm_package(PROJECT_BINARY_DIR "/test/data/" + rpm_path, false); + (*(repo_sack->get_system_repo()).*get(add_rpm_package{}))(PROJECT_BINARY_DIR "/test/data/" + rpm_path, false); add_cmdline_pkg(rpm_path); PackageQuery query1(base); @@ -447,7 +451,7 @@ void RpmPackageQueryTest::test_filter_name_arch2() { add_repo_solv("solv-repo1"); std::string rpm_path = "cmdline-rpms/cmdline-1.2-3.noarch.rpm"; - repo_sack->get_system_repo()->add_rpm_package(PROJECT_BINARY_DIR "/test/data/" + rpm_path, false); + (*(repo_sack->get_system_repo()).*get(add_rpm_package{}))(PROJECT_BINARY_DIR "/test/data/" + rpm_path, false); add_cmdline_pkg(rpm_path); PackageQuery query1(base); diff --git a/test/python3/libdnf5/repo/test_repo.py b/test/python3/libdnf5/repo/test_repo.py index 4941489b3f..9963051f05 100644 --- a/test/python3/libdnf5/repo/test_repo.py +++ b/test/python3/libdnf5/repo/test_repo.py @@ -93,13 +93,3 @@ def repokey_import(self, id, user_id, fingerprint, url, timestamp): self.assertEqual(dl_cbs.fastest_mirror_cnt, 0) self.assertEqual(dl_cbs.handle_mirror_failure_cnt, 0) self.assertEqual(cbs.repokey_import_cnt, 0) - - def test_load_extra_system_repo_incorrectly(self): - # Try to load extra system repo on non-system repo - repo = self.repo_sack.create_repo('test') - self.assertRaises( - RuntimeError, repo.load_extra_system_repo, 'some-root-dir') - - # Try to load extra system repo on non-loaded repo - repo = self.repo_sack.get_system_repo() - self.assertRaises(RuntimeError, repo.load_extra_system_repo, 'dir') diff --git a/test/shared/base_test_case.cpp b/test/shared/base_test_case.cpp index aba58cca48..62e1f8464d 100644 --- a/test/shared/base_test_case.cpp +++ b/test/shared/base_test_case.cpp @@ -183,6 +183,7 @@ namespace { // Accessor of private Base::p_impl, see private_accessor.hpp create_private_getter_template; create_getter(priv_impl, &libdnf5::Base::p_impl); +create_getter(add_rpm_package, &libdnf5::repo::Repo::add_rpm_package); } // namespace @@ -197,7 +198,8 @@ libdnf5::rpm::Package BaseTestCase::add_system_pkg( (base.*get(priv_impl()))->get_system_state().set_package_reason(na, reason); - return repo_sack->get_system_repo()->add_rpm_package(PROJECT_BINARY_DIR "/test/data/" + relative_path, false); + return (*(repo_sack->get_system_repo()).*get(add_rpm_package{}))( + PROJECT_BINARY_DIR "/test/data/" + relative_path, false); }