From 951f25bc8419e79593ae4fdfa3ee062dc58c60b2 Mon Sep 17 00:00:00 2001 From: Florian Festi Date: Tue, 21 Sep 2021 12:30:48 +0200 Subject: [PATCH] Quote %sources and %patches for shell Add testcase with special characters Resolves: #1445 --- macros.in | 6 ++++-- tests/Makefile.am | 1 + tests/data/SPECS/hello-sources.spec | 30 +++++++++++++++++++++++++++++ tests/rpmbuild.at | 19 ++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/data/SPECS/hello-sources.spec diff --git a/macros.in b/macros.in index cf4f77331..634d0de68 100644 --- a/macros.in +++ b/macros.in @@ -1033,8 +1033,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 2aa8dbc4f..491b5b87c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -59,6 +59,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/globesctest.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-mdernize&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 623f1dc69..fc7682ad7 100644 --- a/tests/rpmbuild.at +++ b/tests/rpmbuild.at @@ -2162,3 +2162,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-mdernize&renew.patch +/build/SOURCES/hello-1.0-inst(a);;.patch +], +[ignore]) +AT_CLEANUP