summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Festi <ffesti@redhat.com>2021-09-16 14:13:15 +0200
committerMichal Domonkos <mdomonko@redhat.com>2022-07-01 10:52:14 +0200
commit60113f33fe1803c449d8ccfe5f563122023749bd (patch)
tree9fca19551460fb8215d2575521a62fd58dcd5a66
parent84f0308e0be42f65793e668ff7462470995b74d8 (diff)
downloadrpm-60113f33fe1803c449d8ccfe5f563122023749bd.tar.gz
%autopatch: Fix patch number parameters
Those where not converted to integers for to lookup though not converted to the actual file name. Thanks to Vít Ondruch for pointing this out, suggesting the fix and insisting on a test case! Resolves: #1766 (cherry picked from commit c495d73449cb707bf8b3a0f47a67bba115c00bcf)
-rw-r--r--macros.in2
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/data/SPECS/hello-autopatch.spec32
-rw-r--r--tests/rpmbuild.at13
4 files changed, 47 insertions, 1 deletions
diff --git a/macros.in b/macros.in
index 22f675cdb..7c458f5d8 100644
--- a/macros.in
+++ b/macros.in
@@ -1252,7 +1252,7 @@ for i, p in ipairs(patches) do
bynum[patch_nums[i]] = p
end
for i, a in ipairs(arg) do
- local p = bynum[a]
+ local p = bynum[tonumber(a)]
if p then
print(rpm.expand("%__apply_patch -m %{basename:"..p.."} "..options..p.." "..i.."\\n"))
else
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a41ce10de..b4a2e2e1c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -43,6 +43,7 @@ EXTRA_DIST += data/SPECS/buildrequires.spec
EXTRA_DIST += data/SPECS/docmiss.spec
EXTRA_DIST += data/SPECS/hello.spec
EXTRA_DIST += data/SPECS/hello-auto.spec
+EXTRA_DIST += data/SPECS/hello-autopatch.spec
EXTRA_DIST += data/SPECS/hello-r2.spec
EXTRA_DIST += data/SPECS/hello-script.spec
EXTRA_DIST += data/SPECS/hello2.spec
diff --git a/tests/data/SPECS/hello-autopatch.spec b/tests/data/SPECS/hello-autopatch.spec
new file mode 100644
index 000000000..a6319f193
--- /dev/null
+++ b/tests/data/SPECS/hello-autopatch.spec
@@ -0,0 +1,32 @@
+Name: hello
+Version: 1.0
+Release: 1
+Group: Testing
+License: GPL
+Summary: Simple rpm demonstration.
+
+%sourcelist
+hello-1.0.tar.gz
+
+%patchlist
+hello-1.0-modernize.patch
+hello-1.0-install.patch
+
+%description
+Simple rpm demonstration.
+
+%prep
+%autosetup -N
+%autopatch 1
+%autopatch -m 2
+
+%build
+%make_build CFLAGS="$RPM_OPT_FLAGS"
+
+%install
+%make_install
+
+%files
+%doc FAQ
+/usr/local/bin/hello
+
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index 730b79b3a..ebb5affcc 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -46,6 +46,19 @@ run rpmbuild \
[ignore])
AT_CLEANUP
+AT_SETUP([rpmbuild -ba autopatch])
+AT_KEYWORDS([build])
+RPMDB_INIT
+AT_CHECK([
+
+run rpmbuild \
+ -ba "${abs_srcdir}"/data/SPECS/hello-autopatch.spec
+],
+[0],
+[ignore],
+[ignore])
+AT_CLEANUP
+
# ------------------------------
# Check if rpmbuild --rebuild *.src.rpm works
AT_SETUP([rpmbuild --rebuild])