From 307c79343869ad07332ef6764da1bb4b8bb5a8be Mon Sep 17 00:00:00 2001 From: yueyuankun Date: Mon, 22 Sep 2025 16:51:47 +0800 Subject: [PATCH] [backport] support .zst 1. yum.misc.decompress() to handle uncompressed files 2. fix typo --- ...tadata-cache-pattern-to-include-zstd.patch | 23 ++++ backport-fix-typo.patch | 23 ++++ ...ompress-to-handle-uncompressed-files.patch | 104 ++++++++++++++++++ dnf.spec | 13 ++- 4 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 backport-Update-repo-metadata-cache-pattern-to-include-zstd.patch create mode 100644 backport-fix-typo.patch create mode 100644 backport-yum.misc.decompress-to-handle-uncompressed-files.patch diff --git a/backport-Update-repo-metadata-cache-pattern-to-include-zstd.patch b/backport-Update-repo-metadata-cache-pattern-to-include-zstd.patch new file mode 100644 index 0000000..cabc68a --- /dev/null +++ b/backport-Update-repo-metadata-cache-pattern-to-include-zstd.patch @@ -0,0 +1,23 @@ +From 96b5df9cdec68ab383624c09f9479ce3c274aac0 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= +Date: Fri, 16 Jun 2023 05:57:28 +0200 +Subject: [PATCH] Update repo metadata cache pattern to include zstd + +Also add missing escape before `.` for zck. +--- + dnf/repo.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dnf/repo.py b/dnf/repo.py +index 86fb2bf419..2abcae27af 100644 +--- a/dnf/repo.py ++++ b/dnf/repo.py +@@ -61,7 +61,7 @@ + # particular type. The filename is expected to not contain the base cachedir + # path components. + CACHE_FILES = { +- 'metadata': r'^%s\/.*((xml|yaml)(\.gz|\.xz|\.bz2|.zck)?|asc|cachecookie|%s)$' % ++ 'metadata': r'^%s\/.*((xml|yaml)(\.gz|\.xz|\.bz2|\.zck|\.zst)?|asc|cachecookie|%s)$' % + (_CACHEDIR_RE, _MIRRORLIST_FILENAME), + 'packages': r'^%s\/%s\/.+rpm$' % (_CACHEDIR_RE, _PACKAGES_RELATIVE_DIR), + 'dbcache': r'^.+(solv|solvx)$', diff --git a/backport-fix-typo.patch b/backport-fix-typo.patch new file mode 100644 index 0000000..3b0fae5 --- /dev/null +++ b/backport-fix-typo.patch @@ -0,0 +1,23 @@ +From 64eb9e64da78e111ea0837276269b775b1ac9ea9 Mon Sep 17 00:00:00 2001 +From: lilinjie +Date: Fri, 13 Jan 2023 15:38:44 +0800 +Subject: [PATCH] fix typo + +Signed-off-by: lilinjie +--- + dnf/yum/misc.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dnf/yum/misc.py b/dnf/yum/misc.py +index aa7b0a53b1..ed48627d72 100644 +--- a/dnf/yum/misc.py ++++ b/dnf/yum/misc.py +@@ -313,7 +313,7 @@ def decompress(filename, dest=None, check_timestamps=False): + def read_in_items_from_dot_dir(thisglob, line_as_list=True): + """ Takes a glob of a dir (like /etc/foo.d/\\*.foo) returns a list of all + the lines in all the files matching that glob, ignores comments and blank +- lines, optional paramater 'line_as_list tells whether to treat each line ++ lines, optional parameter 'line_as_list tells whether to treat each line + as a space or comma-separated list, defaults to True. + """ + results = [] diff --git a/backport-yum.misc.decompress-to-handle-uncompressed-files.patch b/backport-yum.misc.decompress-to-handle-uncompressed-files.patch new file mode 100644 index 0000000..144a66f --- /dev/null +++ b/backport-yum.misc.decompress-to-handle-uncompressed-files.patch @@ -0,0 +1,104 @@ +From 01bb29796e926afc4889286513cde638dd8ef625 Mon Sep 17 00:00:00 2001 +From: Marek Blaha +Date: Wed, 9 Dec 2020 13:45:46 +0100 +Subject: [PATCH] yum.misc.decompress() to handle uncompressed files + (RhBug:1895059) + +The underlying libdnf function is capable to handle even uncompressed +files - so now uncompressed files are just copied to the destination. +Also unused fn_only parameter of the function was removed. + +This fixes issue with "reposync -m" command when the group metadata file +in the repository is a plain xml file (not compressed). + +https://bugzilla.redhat.com/show_bug.cgi?id=1895059 +--- + dnf/yum/misc.py | 60 +++++++++++++++++++++++++++---------------------- + 1 file changed, 33 insertions(+), 27 deletions(-) + +diff --git a/dnf/yum/misc.py b/dnf/yum/misc.py +index 0f922350d9..3e3905feb8 100644 +--- a/dnf/yum/misc.py ++++ b/dnf/yum/misc.py +@@ -386,34 +386,39 @@ def getloginuid(): + _cached_getloginuid = _getloginuid() + return _cached_getloginuid + +-def decompress(filename, dest=None, fn_only=False, check_timestamps=False): +- """take a filename and decompress it into the same relative location. +- if the file is not compressed just return the file""" +- +- ztype = None +- out = filename # If the file is not compressed, it returns the same file + +- dot_pos = filename.rfind('.') +- if dot_pos > 0: +- ext = filename[dot_pos:] +- if ext in ('.zck', '.xz', '.bz2', '.gz'): +- ztype = ext +- out = dest if dest else filename[:dot_pos] +- +- if ztype and not fn_only: +- if check_timestamps: +- fi = stat_f(filename) +- fo = stat_f(out) +- if fi and fo and fo.st_mtime == fi.st_mtime: +- return out ++def decompress(filename, dest=None, check_timestamps=False): ++ """take a filename and decompress it into the same relative location. ++ When the compression type is not recognized (or file is not compressed), ++ the content of the file is copied to the destination""" ++ ++ if dest: ++ out = dest ++ else: ++ out = None ++ dot_pos = filename.rfind('.') ++ if dot_pos > 0: ++ ext = filename[dot_pos:] ++ if ext in ('.zck', '.xz', '.bz2', '.gz', '.lzma', '.zst'): ++ out = filename[:dot_pos] ++ if out is None: ++ raise dnf.exceptions.MiscError("Could not determine destination filename") ++ ++ if check_timestamps: ++ fi = stat_f(filename) ++ fo = stat_f(out) ++ if fi and fo and fo.st_mtime == fi.st_mtime: ++ return out + +- try: +- libdnf.utils.decompress(filename, out, 0o644, ztype) +- except RuntimeError as e: +- raise dnf.exceptions.MiscError(str(e)) ++ try: ++ # libdnf.utils.decompress either decompress file to the destination or ++ # copy the content if the compression type is not recognized ++ libdnf.utils.decompress(filename, out, 0o644) ++ except RuntimeError as e: ++ raise dnf.exceptions.MiscError(str(e)) + +- if check_timestamps and fi: +- os.utime(out, (fi.st_mtime, fi.st_mtime)) ++ if check_timestamps and fi: ++ os.utime(out, (fi.st_mtime, fi.st_mtime)) + + return out + +@@ -424,13 +429,14 @@ def calculate_repo_gen_dest(filename, generated_name): + os.makedirs(dest, mode=0o755) + return dest + '/' + generated_name + +-def repo_gen_decompress(filename, generated_name, cached=False): ++ ++def repo_gen_decompress(filename, generated_name): + """ This is a wrapper around decompress, where we work out a cached + generated name, and use check_timestamps. filename _must_ be from + a repo. and generated_name is the type of the file. """ + + dest = calculate_repo_gen_dest(filename, generated_name) +- return decompress(filename, dest=dest, check_timestamps=True, fn_only=cached) ++ return decompress(filename, dest=dest, check_timestamps=True) + + def read_in_items_from_dot_dir(thisglob, line_as_list=True): + """ Takes a glob of a dir (like /etc/foo.d/\\*.foo) returns a list of all diff --git a/dnf.spec b/dnf.spec index e70b24e..83c3556 100644 --- a/dnf.spec +++ b/dnf.spec @@ -3,7 +3,7 @@ Name: dnf Version: 4.2.23 -Release: 11 +Release: 12 Summary: A software package manager that manages packages on Linux distributions. License: GPLv2+ and GPLv2 and GPL URL: https://github.com/rpm-software-management/dnf @@ -29,6 +29,9 @@ Patch6003: backport-set-default-value-for-variable-to-prevent-crash.p Patch6004: backport-pass-whole-url-in-relativeUrl-to-packageTarget-for-rpm-url-download.patch Patch6005: backport-ignore-processing-variable-files-with-unsupported-encoding.patch Patch6006: backport-fix-AttributeError-when-IO-busy-and-press-ctrl-c.patch +Patch6007: backport-fix-typo.patch +Patch6008: backport-Update-repo-metadata-cache-pattern-to-include-zstd.patch +Patch6009: backport-yum.misc.decompress-to-handle-uncompressed-files.patch BuildArch: noarch BuildRequires: cmake gettext systemd bash-completion python3-sphinx @@ -219,6 +222,14 @@ popd %{_mandir}/man8/%{name}-automatic.8* %changelog +* Mon Sep 22 2025 yueyuankun - 4.2.23-12 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:yum.misc.decompress() to handle uncompressed files + update repo metadata cache pattern to include zstd + fix typo + * Fri May 5 2023 xzf1244 4.2.23-11 - CVE:NA - SUG:NA -- Gitee