Skip to content

Commit

Permalink
Better warning for %autopatch without patches
Browse files Browse the repository at this point in the history
Add file and line number to the warning.

Suppress the warning when called from %autosetup and offer -q to
suppress the warning in general.

Resolves: rpm-software-management#3230
  • Loading branch information
ffesti committed Aug 5, 2024
1 parent ee35feb commit 3c47f66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions macros.in
Original file line number Diff line number Diff line change
Expand Up @@ -1276,10 +1276,11 @@ end}
# introduced in the spec, but alternatively can be used to apply indvidual
# patches in arbitrary order by passing them as arguments.
# -v Verbose
# -q Don't warn if there are no matching patches
# -p<N> Prefix strip (ie patch -p argument)
# -m<min> Apply patches with number >= min only (if no arguments)
# -M<max> Apply patches with number <= max only (if no arguments)
%autopatch(vp:m:M:) %{lua:
%autopatch(vqp:m:M:) %{lua:
if #arg == 0 then
local lo = tonumber(rpm.expand("%{-m:%{-m*}}"))
local hi = tonumber(rpm.expand("%{-M:%{-M*}}"))
Expand All @@ -1289,8 +1290,8 @@ if #arg == 0 then
end
end
end
if #arg == 0 then
macros.warn({"autopatch: no matching patches in range"})
if #arg == 0 and not opt.q then
macros.warn({rpm.expand("%{?__file_name:%{__file_name} line %{__file_lineno}}: autopatch: no matching patches in range")})
end
local options = rpm.expand("%{!-v:-q} %{-p:-p%{-p*}} ")
local bynum = {}
Expand All @@ -1317,7 +1318,7 @@ end
%setup %{-a} %{-b} %{-c} %{-C} %{-D} %{-n} %{-T} %{!-v:-q}\
%{-S:%global __scm %{-S*}}\
%{expand:%__scm_setup_%{__scm} %{!-v:-q}}\
%{!-N:%autopatch %{-v} %{-p:-p%{-p*}}}
%{!-N:%autopatch -q %{-v} %{-p:-p%{-p*}}}

# Add a sysuser user/group to a package. Takes a sysusers.d(5) line as
# arguments, eg `%add_sysuser g mygroup 515`.
Expand Down
2 changes: 1 addition & 1 deletion tests/rpmbuild.at
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ run rpmbuild \
[0],
[RPM build warnings:
],
[warning: autopatch: no matching patches in range
[warning: /data/SPECS/hello-autopatch.spec line 22: autopatch: no matching patches in range
])
RPMTEST_CLEANUP

Expand Down

0 comments on commit 3c47f66

Please sign in to comment.