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 #2012

Merged
merged 5 commits into from
Jan 26, 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,4 +1,4 @@
set (DEFAULT_DNF_VERSION "4.18.2")
set (DEFAULT_DNF_VERSION "4.19.0")

if(DEFINED DNF_VERSION)
if(NOT ${DEFAULT_DNF_VERSION} STREQUAL ${DNF_VERSION})
Expand Down
4 changes: 2 additions & 2 deletions dnf.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%define __cmake_in_source_build 1

# default dependencies
%global hawkey_version 0.71.1
%global hawkey_version 0.73.0
%global libcomps_version 0.1.8
%global libmodulemd_version 2.9.3
%global rpm_version 4.14.0
Expand Down Expand Up @@ -67,7 +67,7 @@
It supports RPMs, modules and comps groups & environments.

Name: dnf
Version: 4.18.2
Version: 4.19.0
Release: 1%{?dist}
Summary: %{pkg_summary}
# For a breakdown of the licensing, see PACKAGE-LICENSING
Expand Down
10 changes: 6 additions & 4 deletions dnf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,10 @@ def _add_tempfiles(self, files):

def _add_repo_to_sack(self, repo):
repo.load()
mdload_flags = dict(load_filelists=True,
load_presto=repo.deltarpm,
mdload_flags = dict(load_presto=repo.deltarpm,
jan-kolarik marked this conversation as resolved.
Show resolved Hide resolved
load_updateinfo=True)
if 'filelists' in self.conf.optional_metadata_types:
mdload_flags["load_filelists"] = True
if repo.load_metadata_other:
mdload_flags["load_other"] = True
try:
Expand Down Expand Up @@ -467,9 +468,10 @@ def fill_sack_from_repos_in_cache(self, load_system_repo=True):
for repo in self.repos.iter_enabled():
try:
repo._repo.loadCache(throwExcept=True, ignoreMissing=True)
mdload_flags = dict(load_filelists=True,
load_presto=repo.deltarpm,
mdload_flags = dict(load_presto=repo.deltarpm,
load_updateinfo=True)
if 'filelists' in self.conf.optional_metadata_types:
mdload_flags["load_filelists"] = True
if repo.load_metadata_other:
mdload_flags["load_other"] = True

Expand Down
3 changes: 3 additions & 0 deletions dnf/cli/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def configure(self):
demands.available_repos = True
demands.fresh_metadata = False
demands.sack_activation = True
self.base.conf.optional_metadata_types += ["filelists"]

def run(self):
logger.debug(_("Searching Packages: "))
Expand Down Expand Up @@ -271,6 +272,8 @@ def configure(self):
demands.plugin_filtering_enabled = True
if self.opts.changelogs:
demands.changelogs = True
if dnf.util._is_file_pattern_present(self.opts.packages):
self.base.conf.optional_metadata_types += ["filelists"]
_checkEnabledRepo(self.base)

def run(self):
Expand Down
5 changes: 5 additions & 0 deletions dnf/cli/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import hawkey

import dnf.exceptions
import dnf.util
from dnf.cli import commands
from dnf.cli.option_parser import OptionParser
from dnf.i18n import _
Expand Down Expand Up @@ -62,6 +63,10 @@ def configure(self):
demands.available_repos = True
demands.resolving = True
demands.root_user = True

if dnf.util._is_file_pattern_present(self.opts.pkg_specs):
self.base.conf.optional_metadata_types += ["filelists"]

commands._checkGPGKey(self.base, self.cli)
if not self.opts.filenames:
commands._checkEnabledRepo(self.base)
Expand Down
3 changes: 3 additions & 0 deletions dnf/cli/commands/repoquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,9 @@ def configure(self):
if self.opts.querychangelogs:
demands.changelogs = True

if self.opts.queryfilelist or dnf.util._is_file_pattern_present(self.opts.key):
self.base.conf.optional_metadata_types += ["filelists"]

def build_format_fn(self, opts, pkg):
if opts.querychangelogs:
out = []
Expand Down
5 changes: 5 additions & 0 deletions dnf/cli/commands/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import dnf.exceptions
import dnf.base
import dnf.util
from dnf.cli import commands
from dnf.cli.option_parser import OptionParser
from dnf.i18n import _
Expand Down Expand Up @@ -56,6 +57,10 @@ def configure(self):
demands.available_repos = True
demands.resolving = True
demands.root_user = True

if dnf.util._is_file_pattern_present(self.opts.pkg_specs):
self.base.conf.optional_metadata_types += ["filelists"]

commands._checkGPGKey(self.base, self.cli)
if not self.opts.filenames:
commands._checkEnabledRepo(self.base)
Expand Down
8 changes: 8 additions & 0 deletions dnf/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,3 +631,11 @@ def _tsi_or_pkg_nevra_cmp(item1, item2):
def _name_unset_wrapper(input_name):
# returns <name-unset> for everything that evaluates to False (None, empty..)
return input_name if input_name else _("<name-unset>")


def _is_file_pattern_present(specs):
for spec in specs:
subj = dnf.subject.Subject(spec)
if subj._filename_pattern:
return True
return False
15 changes: 15 additions & 0 deletions doc/conf_ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,21 @@ configuration file by your distribution to override the DNF defaults.

Command-line option: :ref:`--obsoletes <obsoletes_option-label>`

.. _optional_metadata_types-label:

``optional_metadata_types``
:ref:`list <list-label>`

List of metadata types to be loaded in addition to ``primary``, ``modules``, ``comps``, ``updateinfo`` and ``presto``,
which are loaded always.

Note that the list can be extended by individual commands to explicitly request loading specific metadata type.

Currently only ``filelists`` value is supported. Default is ``filelists``.

..
# TODO(jkolarik): Change the default to an empty list when dropping the filelists for Fedora 40

.. _persistdir-label:

``persistdir``
Expand Down
Loading