new_package: make subpackages work when %{source_name} and Name: disagree

Remove %new_package dependency on %{source_name} when creating subpackages by
suffix. This way those subpackages still work even when the packager set
%{source_name} to a value and Name: to another.

Arguably, the packager is severily conflicted, and does not know what he wants
to achieve, but this case is easy enough to accomodate by tweaking the decision
tree. So let’s just make things work instead of blaming the packager.
This commit is contained in:
Nicolas Mailhot 2020-05-23 13:31:41 +02:00
parent a52af8dced
commit 0cb7566d95
1 changed files with 17 additions and 22 deletions

View File

@ -259,34 +259,29 @@ local function new_package(source_name, pkg_name, name_suffix, first, verbose)
return return
end end
-- New processing -- New processing
if name_suffix and not pkg_name then if not (pkg_name or name_suffix or source_name) then
pkg_name = name_suffix rpm.expand([[
if source_name then
pkg_name = source_name .. "-" .. name_suffix
end
end
if not pkg_name then
if not source_name then
rpm.expand([[
%{error:You need to set %%{source_name} or provide explicit package naming!} %{error:You need to set %%{source_name} or provide explicit package naming!}
]]) ]])
else
pkg_name = source_name
end
end end
if not source_name then if name_suffix then
source_name = pkg_name print(rpm.expand("%package " .. name_suffix))
end set("currentname", "%{source_name}-" .. name_suffix, verbose)
if (pkg_name == source_name) then
safeset("source_name", source_name, verbose)
print(rpm.expand("Name: %{source_name}"))
else else
if source_name and first then if not source_name then
srcpkg(verbose) source_name = pkg_name
end end
print(rpm.expand("%package -n " .. pkg_name)) if (pkg_name == source_name) then
safeset("source_name", source_name, verbose)
print(rpm.expand("Name: %{source_name}"))
else
if source_name and first then
srcpkg(verbose)
end
print(rpm.expand("%package -n " .. pkg_name))
end
set("currentname", pkg_name, verbose)
end end
set("currentname", pkg_name, verbose)
end end
return { return {