Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide/Remove deprecated methods #1294

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions dnf5/include/dnf5/shared_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ void create_destdir_option(dnf5::Command & command);
/// The values are stored in the `downloadonly` configuration option
void create_downloadonly_option(dnf5::Command & command);

/// Create the `--forcearch` option for a command provided as an argument.
/// The values are stored in the `forcearch` configuration option
[[deprecated("--forcearch is now a global argument")]] void create_forcearch_option(dnf5::Command & command);

} // namespace dnf5

Expand Down
35 changes: 0 additions & 35 deletions dnf5/shared_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,41 +63,6 @@ void create_destdir_option(dnf5::Command & command) {
command.get_argument_parser_command()->register_named_arg(destdir);
}

void create_forcearch_option(dnf5::Command & command) {
auto & ctx = command.get_context();
auto & parser = ctx.get_argument_parser();
auto forcearch = parser.add_new_named_arg("forcearch");
forcearch->set_long_name("forcearch");
forcearch->set_description("Force the use of a different architecture.");
forcearch->set_has_value(true);
forcearch->set_arg_value_help("FORCEARCH");
forcearch->set_parse_hook_func([&ctx](
[[maybe_unused]] libdnf5::cli::ArgumentParser::NamedArg * arg,
[[maybe_unused]] const char * option,
const char * value) {
auto supported_arches = libdnf5::rpm::get_supported_arches();
if (std::find(supported_arches.begin(), supported_arches.end(), value) == supported_arches.end()) {
std::string available_arches{};
auto it = supported_arches.begin();
if (it != supported_arches.end()) {
available_arches.append("\"" + *it + "\"");
++it;
for (; it != supported_arches.end(); ++it) {
available_arches.append(", \"" + *it + "\"");
}
}
throw libdnf5::cli::ArgumentParserInvalidValueError(
M_("Unsupported architecture \"{0}\". Please choose one from {1}"),
std::string(value),
available_arches);
}
ctx.base.get_config().get_ignorearch_option().set(libdnf5::Option::Priority::COMMANDLINE, true);
ctx.base.get_vars()->set("arch", value, libdnf5::Vars::Priority::COMMANDLINE);
return true;
});
command.get_argument_parser_command()->register_named_arg(forcearch);
}

void create_downloadonly_option(dnf5::Command & command) {
auto & parser = command.get_context().get_argument_parser();
auto downloadonly = parser.add_new_named_arg("downloadonly");
Expand Down
10 changes: 0 additions & 10 deletions include/libdnf5/logger/factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.

namespace libdnf5 {

// File logger destination filename.
/// @deprecated The filename should be set by API user.
constexpr const char * FILE_LOGGER_FILENAME = "dnf5.log";

/// @deprecated It is going to be removed.
/// @brief Helper method for creating a file logger.
/// @param base Reference to Base for loading the configured logger path.
/// @return Instance of a new file logger.
std::unique_ptr<libdnf5::Logger> create_file_logger(libdnf5::Base & base);

/// @brief Helper method for creating a file logger in `logdir` location with given file name.
/// @param base Reference to Base for loading the configured logger path.
/// @param filename Name of the log file.
Expand Down
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
4 changes: 0 additions & 4 deletions libdnf5/logger/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,4 @@ std::unique_ptr<libdnf5::Logger> create_rotating_file_logger(Base & base, const
}


std::unique_ptr<libdnf5::Logger> create_file_logger(Base & base) {
return create_file_logger(base, FILE_LOGGER_FILENAME);
}

} // namespace libdnf5
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
14 changes: 4 additions & 10 deletions test/libdnf5/logger/test_file_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using namespace std::filesystem;

CPPUNIT_TEST_SUITE_REGISTRATION(FileLoggerTest);

constexpr const char * FILE_LOGGER_FILENAME = "dnf5.log";

void FileLoggerTest::setUp() {
BaseTestCase::setUp();
Expand All @@ -37,7 +38,7 @@ void FileLoggerTest::setUp() {
auto temp_logdir = path("/var/log/FileLoggerTestLogDir");
config.get_logdir_option().set(installroot / temp_logdir.relative_path());

full_log_path = installroot / temp_logdir.relative_path() / libdnf5::FILE_LOGGER_FILENAME;
full_log_path = installroot / temp_logdir.relative_path() / FILE_LOGGER_FILENAME;
}


Expand All @@ -47,24 +48,17 @@ void FileLoggerTest::tearDown() {
}


void FileLoggerTest::test_file_logger_create() {
CPPUNIT_ASSERT(!exists(full_log_path));
auto file_logger = libdnf5::create_file_logger(base);
CPPUNIT_ASSERT(exists(full_log_path));
}


void FileLoggerTest::test_file_logger_create_name() {
CPPUNIT_ASSERT(!exists(full_log_path));
auto file_logger = libdnf5::create_file_logger(base, libdnf5::FILE_LOGGER_FILENAME);
auto file_logger = libdnf5::create_file_logger(base, FILE_LOGGER_FILENAME);
CPPUNIT_ASSERT(exists(full_log_path));
}


void FileLoggerTest::test_file_logger_add() {
auto log_router = base.get_logger();
auto loggers_count_before = log_router->get_loggers_count();
auto file_logger = libdnf5::create_file_logger(base);
auto file_logger = libdnf5::create_file_logger(base, FILE_LOGGER_FILENAME);
log_router->add_logger(std::move(file_logger));
CPPUNIT_ASSERT_EQUAL(loggers_count_before + 1, log_router->get_loggers_count());
}
3 changes: 1 addition & 2 deletions test/libdnf5/logger/test_file_logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.

class FileLoggerTest : public BaseTestCase {
CPPUNIT_TEST_SUITE(FileLoggerTest);
CPPUNIT_TEST(test_file_logger_create);
CPPUNIT_TEST(test_file_logger_add);
CPPUNIT_TEST(test_file_logger_create_name);
CPPUNIT_TEST_SUITE_END();

public:
void setUp() override;
void tearDown() override;
void test_file_logger_create();
void test_file_logger_create_name();
void test_file_logger_add();

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
18 changes: 8 additions & 10 deletions test/python3/libdnf5/logger/test_file_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,32 @@
import os
import shutil

FILE_LOGGER_FILENAME = "dnf5.log"


class TestFileLogger(base_test_case.BaseTestCase):
def setUp(self):
super().setUp()
config = self.base.get_config()
config.logdir = os.path.join(
config.installroot, "FileLoggerTestLogDir")
self.full_log_path = os.path.join(
config.logdir, libdnf5.logger.FILE_LOGGER_FILENAME)
self.full_log_path = os.path.join(config.logdir, FILE_LOGGER_FILENAME)

def tearDown(self):
super().tearDown()
shutil.rmtree(os.path.dirname(self.full_log_path), ignore_errors=True)

def test_file_logger_create(self):
self.assertFalse(os.path.exists(self.full_log_path))
_ = libdnf5.logger.create_file_logger(self.base)
self.assertTrue(os.path.exists(self.full_log_path))

def test_file_logger_create_name(self):
self.assertFalse(os.path.exists(self.full_log_path))
_ = libdnf5.logger.create_file_logger(
self.base, libdnf5.logger.FILE_LOGGER_FILENAME)
self.base, FILE_LOGGER_FILENAME)
self.assertTrue(os.path.exists(self.full_log_path))

def test_file_logger_add(self):
log_router = self.base.get_logger()
loggers_count_before = log_router.get_loggers_count()
logger = libdnf5.logger.create_file_logger(self.base)
logger = libdnf5.logger.create_file_logger(self.base,
FILE_LOGGER_FILENAME)
log_router.add_logger(logger)
self.assertEqual(loggers_count_before + 1,
log_router.get_loggers_count())
Expand All @@ -59,7 +56,8 @@ def test_with_global_logger(self):
log_router = self.base.get_logger()
global_logger = libdnf5.logger.GlobalLogger()
global_logger.set(log_router.get(), libdnf5.logger.Logger.Level_DEBUG)
logger = libdnf5.logger.create_file_logger(self.base)
logger = libdnf5.logger.create_file_logger(self.base,
FILE_LOGGER_FILENAME)
log_router.add_logger(logger)

# Run an action including librepo logging
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
Loading