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

Add the possibility to load filelists conditionally #1635

Merged
merged 4 commits into from
Jan 25, 2024
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
2 changes: 1 addition & 1 deletion VERSION.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set (DEFAULT_LIBDNF_MAJOR_VERSION 0)
set (DEFAULT_LIBDNF_MINOR_VERSION 72)
set (DEFAULT_LIBDNF_MINOR_VERSION 73)
set (DEFAULT_LIBDNF_MICRO_VERSION 0)

if(DEFINED LIBDNF_MAJOR_VERSION)
Expand Down
2 changes: 1 addition & 1 deletion libdnf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%global dnf_conflict 4.11.0
%global swig_version 3.0.12
%global libdnf_major_version 0
%global libdnf_minor_version 72
%global libdnf_minor_version 73
%global libdnf_micro_version 0

%define __cmake_in_source_build 1
Expand Down
4 changes: 4 additions & 0 deletions libdnf/conf/ConfigMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ class ConfigMain::Impl {
OptionBool debug_solver{false};
OptionStringList installonlypkgs{INSTALLONLYPKGS};
OptionStringList group_package_types{GROUP_PACKAGE_TYPES};
// TODO(jkolarik): Change to empty list when dropping the filelists for Fedora 40
OptionStringList optional_metadata_types{std::vector<std::string>{"filelists"}};

OptionNumber<std::uint32_t> installonly_limit{3, 0,
[](const std::string & value)->std::uint32_t{
Expand Down Expand Up @@ -399,6 +401,7 @@ ConfigMain::Impl::Impl(Config & owner)
);

owner.optBinds().add("group_package_types", group_package_types);
owner.optBinds().add("optional_metadata_types", optional_metadata_types);
owner.optBinds().add("installonly_limit", installonly_limit);

owner.optBinds().add("tsflags", tsflags,
Expand Down Expand Up @@ -564,6 +567,7 @@ OptionStringList & ConfigMain::reposdir() { return pImpl->reposdir; }
OptionBool & ConfigMain::debug_solver() { return pImpl->debug_solver; }
OptionStringList & ConfigMain::installonlypkgs() { return pImpl->installonlypkgs; }
OptionStringList & ConfigMain::group_package_types() { return pImpl->group_package_types; }
OptionStringList & ConfigMain::optional_metadata_types() { return pImpl->optional_metadata_types; }
OptionNumber<std::uint32_t> & ConfigMain::installonly_limit() { return pImpl->installonly_limit; }
OptionStringList & ConfigMain::tsflags() { return pImpl->tsflags; }
OptionBool & ConfigMain::assumeyes() { return pImpl->assumeyes; }
Expand Down
1 change: 1 addition & 0 deletions libdnf/conf/ConfigMain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class ConfigMain : public Config {
OptionBool & debug_solver();
OptionStringList & installonlypkgs();
OptionStringList & group_package_types();
OptionStringList & optional_metadata_types();

/* NOTE: If you set this to 2, then because it keeps the current
kernel it means if you ever install an "old" kernel it'll get rid
Expand Down
21 changes: 16 additions & 5 deletions libdnf/dnf-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ typedef struct
gboolean check_disk_space;
gboolean check_transaction;
gboolean only_trusted;
gboolean enable_filelists;
gboolean *enable_filelists;
gboolean enrollment_valid;
gboolean write_history;
DnfLock *lock;
Expand Down Expand Up @@ -252,6 +252,7 @@ dnf_context_finalize(GObject *object)
g_free(priv->http_proxy);
g_free(priv->user_agent);
g_free(priv->arch);
g_free(priv->enable_filelists);
g_strfreev(priv->native_arches);
g_object_unref(priv->lock);
g_object_unref(priv->state);
Expand Down Expand Up @@ -364,7 +365,6 @@ dnf_context_init(DnfContext *context)
priv->install_root = g_strdup("/");
priv->check_disk_space = TRUE;
priv->check_transaction = TRUE;
priv->enable_filelists = TRUE;
priv->write_history = TRUE;
priv->state = dnf_state_new();
priv->lock = dnf_lock_new();
Expand Down Expand Up @@ -1086,7 +1086,15 @@ gboolean
dnf_context_get_enable_filelists (DnfContext *context)
{
DnfContextPrivate *priv = GET_PRIVATE(context);
return priv->enable_filelists;
if (priv->enable_filelists == NULL) {
priv->enable_filelists = g_new(gboolean, 1);

auto & optional_metadata_types = libdnf::getGlobalMainConfig(false).optional_metadata_types().getValue();
*priv->enable_filelists = std::find(optional_metadata_types.begin(),
optional_metadata_types.end(),
"filelists") != optional_metadata_types.end();
}
return *priv->enable_filelists;
}

/**
Expand Down Expand Up @@ -1567,7 +1575,10 @@ dnf_context_set_enable_filelists (DnfContext *context,
gboolean enable_filelists)
{
DnfContextPrivate *priv = GET_PRIVATE(context);
priv->enable_filelists = enable_filelists;
if (priv->enable_filelists == NULL) {
priv->enable_filelists = g_new(gboolean, 1);
}
jan-kolarik marked this conversation as resolved.
Show resolved Hide resolved
*priv->enable_filelists = enable_filelists;
}

/**
Expand Down Expand Up @@ -1824,7 +1835,7 @@ dnf_context_setup_sack_with_flags(DnfContext *context,
DnfSackAddFlags add_flags = DNF_SACK_ADD_FLAG_NONE;
if ((flags & DNF_CONTEXT_SETUP_SACK_FLAG_LOAD_UPDATEINFO) > 0)
add_flags = static_cast<DnfSackAddFlags>(add_flags | DNF_SACK_ADD_FLAG_UPDATEINFO);
if (priv->enable_filelists && !((flags & DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS) > 0))
if (dnf_context_get_enable_filelists(context) && !((flags & DNF_CONTEXT_SETUP_SACK_FLAG_SKIP_FILELISTS) > 0))
add_flags = static_cast<DnfSackAddFlags>(add_flags | DNF_SACK_ADD_FLAG_FILELISTS);

/* add remote */
Expand Down
10 changes: 8 additions & 2 deletions libdnf/repo/Repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,18 @@ std::string Repo::getMetadataContent(const std::string &metadataType)
std::unique_ptr<LrHandle> Repo::Impl::lrHandleInitBase()
{
std::unique_ptr<LrHandle> h(lr_handle_init());
std::vector<const char *> dlist = {MD_TYPE_PRIMARY, MD_TYPE_FILELISTS, MD_TYPE_PRESTODELTA,
MD_TYPE_GROUP_GZ, MD_TYPE_UPDATEINFO};
std::vector<const char *> dlist = {MD_TYPE_PRIMARY, MD_TYPE_PRESTODELTA, MD_TYPE_GROUP_GZ, MD_TYPE_UPDATEINFO};

auto & optionalMetadataTypes = conf->getMainConfig().optional_metadata_types().getValue();
auto loadFilelists = std::find(optionalMetadataTypes.begin(), optionalMetadataTypes.end(), "filelists") !=
optionalMetadataTypes.end();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great idea


#ifdef MODULEMD
dlist.push_back(MD_TYPE_MODULES);
#endif
if (loadFilelists) {
dlist.push_back(MD_TYPE_FILELISTS);
}
if (loadMetadataOther) {
dlist.push_back(MD_TYPE_OTHER);
}
Expand Down
Loading