Skip to content

Commit

Permalink
Hide/Remove deprecated libdnf5::repo::Repo API
Browse files Browse the repository at this point in the history
There is still public `load()` which is marked as deprecated but it
cannot be easily hidden because dnfdaemon uses it as well.
  • Loading branch information
kontura committed Mar 5, 2024
1 parent c4d2c9e commit 204994d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 56 deletions.
51 changes: 18 additions & 33 deletions include/libdnf5/repo/repo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -318,29 +308,6 @@ class Repo {
// @replaces libdnf:repo/Repo.hpp:method:Repo.getMirrors()
std::vector<std::string> 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<std::string, std::string> & substitutions)
void set_substitutions(const std::map<std::string, std::string> & 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.
Expand All @@ -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();
Expand Down
10 changes: 0 additions & 10 deletions libdnf5/repo/repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -306,10 +300,6 @@ int Repo::get_expires_in() const {
return p_impl->config.get_metadata_expire_option().get_value() - static_cast<int>(get_age());
}

void Repo::set_substitutions(const std::map<std::string, std::string> & 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);
}
Expand Down
8 changes: 6 additions & 2 deletions test/libdnf5/rpm/test_package_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.

#include "test_package_query.hpp"

#include "../shared/private_accessor.hpp"
#include "../shared/utils.hpp"

#include <libdnf5/rpm/package_query.hpp>
Expand All @@ -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:
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 0 additions & 10 deletions test/python3/libdnf5/repo/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
4 changes: 3 additions & 1 deletion test/shared/base_test_case.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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);
}


Expand Down

0 comments on commit 204994d

Please sign in to comment.