Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%autopatch 1 2 3 does not work #1766

Closed
voxik opened this issue Aug 30, 2021 · 3 comments · Fixed by #1776
Closed

%autopatch 1 2 3 does not work #1766

voxik opened this issue Aug 30, 2021 · 3 comments · Fixed by #1776

Comments

@voxik
Copy link
Contributor

voxik commented Aug 30, 2021

rubygem-puma is broken due to #1512. I was trying to apply this medicine:

$ git diff
diff --git a/rubygem-puma.spec b/rubygem-puma.spec
index 0a412ad..6b60e97 100644
--- a/rubygem-puma.spec
+++ b/rubygem-puma.spec
@@ -66,17 +66,12 @@ BuildArch: noarch
 Documentation for %{name}.
 
 %prep
-%setup -q -n %{gem_name}-%{version} -b 1 -b 3
+%autosetup -N -S git_am -n %{gem_name}-%{version} -b 1 -b 3
 
-%patch2 -p1
+%autopatch 2
 
 pushd %{_builddir}
-%patch3 -p1
-
-# When removed, remove also the `BR: git` above.
-%global __scm git_am
-%{expand:%__scm_setup_%{__scm}}
-%apply_patch -p1 %{PATCH4}
+%autopatch 3 4
 popd
 
 %if %{with ragel}

but it fails:

... snip ...

Start: rpmbuild rubygem-puma-4.3.6-4.fc36.src.rpm
error: no such patch 2
  2<      (%error)
error: no such patch 3
  2<      (%error)
error: no such patch 4
  2<      (%error)
Building target platforms: x86_64

... snip ...

error: Bad exit status from /var/tmp/rpm-tmp.vWraR2 (%check)


RPM build errors:
    no such patch 2
    no such patch 3
    no such patch 4
    Bad exit status from /var/tmp/rpm-tmp.vWraR2 (%check)

I think the fix could be:

$ git diff
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

It would be nice if there was test case for this use case ...

Also, it would help if the rpmbuild finished right after the %autopatch failure and if the error messages were printed right away without being repeated at the end.

@ffesti
Copy link
Contributor

ffesti commented Sep 16, 2021

Yes, this indeed seems to be the issue. No idea how this was ever working. May be the array access in lua got stricter.
If you want proper credit for the fix please create a PR from the patch or attach it here as proper git commit. Otherwise I am fine with just creating one myself.

In the mean time you can use %autopatch -m 2 -M 2 as a work around. Looking at the code that code path should be working fine.

@voxik
Copy link
Contributor Author

voxik commented Sep 16, 2021

If you want proper credit for the fix please create a PR from the patch or attach it here as proper git commit.

I think test case is more important then my credit. IOW I appreciate if you fix it.

ffesti added a commit to ffesti/rpm that referenced this issue Sep 16, 2021
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
@ffesti
Copy link
Contributor

ffesti commented Sep 16, 2021

Here you go!

ffesti added a commit to ffesti/rpm that referenced this issue Sep 16, 2021
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
pmatilai pushed a commit that referenced this issue Sep 17, 2021
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
mikhailnov pushed a commit to mikhailnov/rpm that referenced this issue Sep 30, 2021
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
dmnks pushed a commit to dmnks/rpm that referenced this issue Jun 7, 2022
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)
dmnks pushed a commit to dmnks/rpm that referenced this issue Jun 7, 2022
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)
dmnks pushed a commit to dmnks/rpm that referenced this issue Jun 7, 2022
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)
dmnks pushed a commit to dmnks/rpm that referenced this issue Jun 8, 2022
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)
dmnks pushed a commit that referenced this issue Jul 1, 2022
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 c495d73)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants