summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Festi <ffesti@redhat.com>2021-09-21 12:30:48 +0200
committerPanu Matilainen <pmatilai@redhat.com>2022-09-02 08:48:10 +0300
commit4d8ac28bfe20cee2f29c6fbdb1e0e3f820521aed (patch)
treecdb7466b2f9d5c74f52187b1a8ee0568b6142c58
parent2d0293f8056ec9f3d341992d8b8b50580060ba5b (diff)
downloadrpm-4d8ac28bfe20cee2f29c6fbdb1e0e3f820521aed.tar.gz
Quote %sources and %patches for shell
Add testcase with special characters Resolves: #1445 (cherry picked from commit 951f25bc8419e79593ae4fdfa3ee062dc58c60b2)
-rw-r--r--macros.in6
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/data/SPECS/hello-sources.spec30
-rw-r--r--tests/rpmbuild.at19
4 files changed, 54 insertions, 2 deletions
diff --git a/macros.in b/macros.in
index 6e4afb90f..637b2fc78 100644
--- a/macros.in
+++ b/macros.in
@@ -1032,8 +1032,10 @@ package or when debugging this package.\
install
#------------------------------------------------------------------------------
-%patches %{lua: for i, p in ipairs(patches) do print(p.." ") end}
-%sources %{lua: for i, s in ipairs(sources) do print(s.." ") end}
+%patches %{lua: for i, p in ipairs(patches) do \
+ print(macros.shescape({p}).." ") end}
+%sources %{lua: for i, s in ipairs(sources) do \
+ print(macros.shescape({s}).." ") end}
#------------------------------------------------------------------------------
# arch macro for all Intel i?86 compatible processors
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6c6bb18e7..821f001f1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -60,6 +60,7 @@ EXTRA_DIST += data/SPECS/hello2cp.spec
EXTRA_DIST += data/SPECS/hello2ln.spec
EXTRA_DIST += data/SPECS/hello2-suid.spec
EXTRA_DIST += data/SPECS/hello-g3.spec
+EXTRA_DIST += data/SPECS/hello-sources.spec
EXTRA_DIST += data/SPECS/foo.spec
EXTRA_DIST += data/SPECS/globtest.spec
EXTRA_DIST += data/SPECS/versiontest.spec
diff --git a/tests/data/SPECS/hello-sources.spec b/tests/data/SPECS/hello-sources.spec
new file mode 100644
index 000000000..53a8afb71
--- /dev/null
+++ b/tests/data/SPECS/hello-sources.spec
@@ -0,0 +1,30 @@
+Name: hello
+Version: 1.0
+Release: 1
+Group: Testing
+License: GPL
+Summary: Simple rpm demonstration.
+
+%sourcelist
+hello-1.0 %tar.gz
+hello-addon ! tar\.gz
+
+%patchlist
+hello-1.0-m<o>dernize&renew.patch
+hello-1.0-inst(a);;.patch
+
+%description
+Simple rpm demonstration.
+
+%prep
+for f in %{sources} ; do
+ echo "$f"
+done
+for f in %{patches} ; do
+ echo "$f"
+done
+
+%files
+%doc FAQ
+/usr/local/bin/hello
+
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index f90946b32..bb3bdc168 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -2113,3 +2113,22 @@ foo
],
[])
AT_CLEANUP
+
+# ------------------------------
+# Check %sources and %patches with weird file names
+AT_SETUP([%sources and %patches])
+AT_KEYWORDS([build])
+RPMDB_INIT
+AT_CHECK([
+
+runroot rpmbuild \
+ -bp /data/SPECS/hello-sources.spec | grep -v Executing
+],
+[0],
+[/build/SOURCES/hello-1.0 %tar.gz
+/build/SOURCES/hello-addon ! tar\.gz
+/build/SOURCES/hello-1.0-m<o>dernize&renew.patch
+/build/SOURCES/hello-1.0-inst(a);;.patch
+],
+[ignore])
+AT_CLEANUP