public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/rpm] pmatilai-v6: - If globbing of a filename fails, try use the filename without globbing.
@ 2026-11-23 9:29 Lubos Kardos
0 siblings, 0 replies; only message in thread
From: Lubos Kardos @ 2026-11-23 9:29 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/rpm
Branch : pmatilai-v6
Commit : ad8c4238ac9ad9a88a003d1ae40ff46b93f240a8
Author : Lubos Kardos <lkardos@redhat.com>
Date : 2015-08-03T17:43:23+02:00
Stats : +190/-1 in 3 file(s)
URL : https://src.fedoraproject.org/rpms/rpm/c/ad8c4238ac9ad9a88a003d1ae40ff46b93f240a8?branch=pmatilai-v6
Log:
- If globbing of a filename fails, try use the filename without globbing.
- Related: #1246743
- Modify rpmIsGlob() to be more precise and compatible with glob().
- Related: #1246743
---
diff --git a/rpm-4.12.90-modify-rpmisglob.patch b/rpm-4.12.90-modify-rpmisglob.patch
new file mode 100644
index 0000000..d609762
--- /dev/null
+++ b/rpm-4.12.90-modify-rpmisglob.patch
@@ -0,0 +1,136 @@
+From 630a0970df46df6cc96a68349cf4e08d8b4ca772 Mon Sep 17 00:00:00 2001
+From: Lubos Kardos <lkardos@redhat.com>
+Date: Mon, 3 Aug 2015 16:51:11 +0200
+Subject: [PATCH 1/2] Modify rpmIsGlob() to be more precise.
+
+Now rpmIsGlob() checks if braces expansion pattern is well formed and
+not only if it contains opening and closing brace. The checking
+procedure is same as procedure in glob() so rpmIsGlob() and glob() are
+now compatible.
+---
+ rpmio/rpmglob.c | 57 ++++++++++++++++++++++++++++++++-------------------------
+ 1 file changed, 32 insertions(+), 25 deletions(-)
+
+diff --git a/rpmio/rpmglob.c b/rpmio/rpmglob.c
+index 597ac5c..0c6b0a3 100644
+--- a/rpmio/rpmglob.c
++++ b/rpmio/rpmglob.c
+@@ -150,7 +150,7 @@ static inline const char *next_brace_sub(const char *begin)
+ return cp;
+ }
+
+-static int __glob_pattern_p(const char *pattern, int flags);
++static int __glob_pattern_p(const char *pattern, int quote);
+
+ /* Do glob searching for PATTERN, placing results in PGLOB.
+ The bits defined above may be set in FLAGS.
+@@ -419,7 +419,7 @@ glob(const char *pattern, int flags,
+ return GLOB_NOMATCH;
+ }
+
+- if (__glob_pattern_p(dirname, flags)) {
++ if (__glob_pattern_p(dirname, !(flags & GLOB_NOESCAPE))) {
+ /* The directory name contains metacharacters, so we
+ have to glob for the directory, and then glob for
+ the pattern in each directory found. */
+@@ -646,11 +646,10 @@ static int prefix_array(const char *dirname, char **array, size_t n)
+
+ /* Return nonzero if PATTERN contains any metacharacters.
+ Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
+-static int __glob_pattern_p(const char *pattern, int flags)
++static int __glob_pattern_p(const char *pattern, int quote)
+ {
+ register const char *p;
+ int openBrackets = 0;
+- int openBraces = 0;
+
+ for (p = pattern; *p != '\0'; ++p)
+ switch (*p) {
+@@ -659,7 +658,7 @@ static int __glob_pattern_p(const char *pattern, int flags)
+ return 1;
+
+ case '\\':
+- if (!(flags & GLOB_NOESCAPE) && p[1] != '\0')
++ if (quote && p[1] != '\0')
+ ++p;
+ break;
+
+@@ -671,17 +670,6 @@ static int __glob_pattern_p(const char *pattern, int flags)
+ if (openBrackets)
+ return 1;
+ break;
+-
+- case '{':
+- if (flags & GLOB_BRACE)
+- openBraces = 1;
+- break;
+-
+- case '}':
+- if (openBraces)
+- return 1;
+- break;
+-
+ }
+
+ return 0;
+@@ -706,7 +694,7 @@ glob_in_dir(const char *pattern, const char *directory, int flags,
+ int meta;
+ int save;
+
+- meta = __glob_pattern_p(pattern, flags);
++ meta = __glob_pattern_p(pattern, !(flags & GLOB_NOESCAPE));
+ if (meta == 0) {
+ if (flags & (GLOB_NOCHECK | GLOB_NOMAGIC))
+ /* We need not do any tests. The PATTERN contains no meta
+@@ -888,9 +876,7 @@ int rpmGlob(const char * patterns, int * argcPtr, ARGV_t * argvPtr)
+ int dir_only = (plen > 0 && path[plen-1] == '/');
+ glob_t gl;
+
+- if (!local || (!rpmIsGlob(av[j], GLOB_NOESCAPE | flags) &&
+- strchr(path, '~') == NULL)) {
+-
++ if (!local || (!rpmIsGlob(av[j], 0) && strchr(path, '~') == NULL)) {
+ argvAdd(&argv, av[j]);
+ continue;
+ }
+@@ -982,11 +968,32 @@ exit:
+
+ int rpmIsGlob(const char * pattern, int quote)
+ {
+- int flags = 0;
+- if (!quote) {
+- flags |= GLOB_NOESCAPE;
++ if(!__glob_pattern_p(pattern, quote)) {
++
++ const char *begin;
++ const char *next;
++ const char *rest;
++
++ begin = strchr(pattern, '{');
++ if (begin == NULL)
++ return 0;
++ /*
++ * Find the first sub-pattern and at the same time find the
++ * rest after the closing brace.
++ */
++ next = next_brace_sub(begin + 1);
++ if (next == NULL)
++ return 0;
++
++ /* Now find the end of the whole brace expression. */
++ rest = next;
++ while (*rest != '}') {
++ rest = next_brace_sub(rest + 1);
++ if (rest == NULL)
++ return 0;
++ }
++ /* Now we can be sure that brace expression is well-foermed. */
+ }
+- flags |= GLOB_BRACE;
+
+- return __glob_pattern_p(pattern, flags);
++ return 1;
+ }
+--
+1.9.3
+
diff --git a/rpm-4.12.90-try-unglobbed.patch b/rpm-4.12.90-try-unglobbed.patch
new file mode 100644
index 0000000..bcce9f4
--- /dev/null
+++ b/rpm-4.12.90-try-unglobbed.patch
@@ -0,0 +1,45 @@
+From c16c70cbd6b31cd93541d5c22d23ba98d212ad3d Mon Sep 17 00:00:00 2001
+From: Lubos Kardos <lkardos@redhat.com>
+Date: Mon, 3 Aug 2015 12:10:14 +0200
+Subject: [PATCH 2/2] If globbing of a filename fails, try use the filename
+ without globbing.
+
+Commit d14ecfe587efbe80e5534161dbd3a4f7158b4e2b enabled {} expansion
+but {} expansion caused regresion because rpm tried to expand filenames
+which weren't expanded previously and expansion failed because these
+filenames weren't supposed to be expanded. Now if expansion fails then
+rpm tries to use original filename.
+---
+ build/files.c | 15 ++++++---------
+ 1 file changed, 6 insertions(+), 9 deletions(-)
+
+diff --git a/build/files.c b/build/files.c
+index d16bb17..ea595b9 100644
+--- a/build/files.c
++++ b/build/files.c
+@@ -1584,16 +1584,13 @@ static rpmRC processBinaryFile(Package pkg, FileList fl, const char * fileName)
+ }
+ argvFree(argv);
+ } else {
+- int lvl = RPMLOG_WARNING;
+ const char *msg = (fl->cur.isDir) ?
+- _("Directory not found by glob: %s\n") :
+- _("File not found by glob: %s\n");
+- if (!(fl->cur.attrFlags & RPMFILE_EXCLUDE)) {
+- lvl = RPMLOG_ERR;
+- rc = RPMRC_FAIL;
+- }
+- rpmlog(lvl, msg, diskPath);
+- goto exit;
++ _("Directory not found by glob: %s. "
++ "Trying without globbing.\n") :
++ _("File not found by glob: %s. "
++ "Trying without globbing.\n");
++ rpmlog(RPMLOG_DEBUG, msg, diskPath);
++ rc = addFile(fl, diskPath, NULL);
+ }
+ } else {
+ rc = addFile(fl, diskPath, NULL);
+--
+1.9.3
+
diff --git a/rpm.spec b/rpm.spec
index c3a7ab2..19b97fd 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -27,7 +27,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
-Release: %{?snapver:0.%{snapver}.}4%{?dist}
+Release: %{?snapver:0.%{snapver}.}5%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/rpm-4.12.x/%{name}-%{srcver}.tar.bz2
@@ -53,6 +53,8 @@ Patch5: rpm-4.12.0-rpm2cpio-hack.patch
Patch100: rpm-4.12.90-braces-expansion.patch
Patch101: rpm-4.12.90-Fix-compressed-patches.patch
Patch102: rpm-4.12.90-fix-macro-warning.patch
+Patch103: rpm-4.12.90-modify-rpmisglob.patch
+Patch104: rpm-4.12.90-try-unglobbed.patch
# These are not yet upstream
Patch302: rpm-4.7.1-geode-i686.patch
@@ -537,6 +539,12 @@ exit 0
%doc doc/librpm/html/*
%changelog
+* Mon Aug 03 2015 Lubos Kardos <lkardos@redhat.com> - 4.12.90-5
+- If globbing of a filename fails, try use the filename without globbing.
+ (#1246743)
+- Modify rpmIsGlob() to be more precise and compatible with glob().
+ (#1246743)
+
* Thu Jul 30 2015 Lubos Kardos <lkardos@redhat.com> - 4.12.90-4
- Don't warn when an escaped macro is in a comment (#1224660)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-23 9:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 9:29 [rpms/rpm] pmatilai-v6: - If globbing of a filename fails, try use the filename without globbing Lubos Kardos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox