Skip to content

Commit

Permalink
%autopatch: Fix patch number parameters
Browse files Browse the repository at this point in the history
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: rpm-software-management#1766
(cherry picked from commit c495d73)
  • Loading branch information
ffesti authored and dmnks committed Jun 7, 2022
1 parent 703e9af commit f4f4288
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion macros.in
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/Makefile.am
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions 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

13 changes: 13 additions & 0 deletions tests/rpmbuild.at
Expand Up @@ -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])
Expand Down

0 comments on commit f4f4288

Please sign in to comment.