127 строки
5.5 KiB
Plaintext
127 строки
5.5 KiB
Plaintext
# Map forge information to rpm metadata. This macro will compute default spec
|
|
# variable values.
|
|
#
|
|
# The following spec variables SHOULD be set before calling the macro:
|
|
#
|
|
# forgeurl the project url on the forge, strongly recommended;
|
|
# Version if applicable, set it with Version: <version>
|
|
# tag if applicable
|
|
# commit if applicable
|
|
# date if applicable (to override the mtime of the Source archive)
|
|
#
|
|
# Use -z for multiple calls to the macro
|
|
#
|
|
# The macro will attempt to compute and set the following variables if they are
|
|
# not already set by the packager:
|
|
#
|
|
# forgesource an URL that can be used as SourceX: value
|
|
# forgesetupargs the correct arguments to pass to %setup for this source
|
|
# used by %forgesetup and %forgeautosetup
|
|
# archivename the source archive filename, without extentions
|
|
# archiveext the source archive filename extensions, without leading dot
|
|
# archiveurl the url that can be used to download the source archive,
|
|
# without renaming
|
|
# topdir the source archive top directory (can be empty)
|
|
# extractdir the source directory created inside %{_builddir} after using
|
|
# %%forgesetup, %forgeautosetup or %{forgesetupargs}
|
|
# repo the repository name
|
|
# owner the repository owner (if used by another computed variable)
|
|
# shortcommit the commit hash clamping used by the forge, if any
|
|
# scm the scm type, when packaging code snapshots: commits or tags
|
|
# distprefix the prefix that needs adding to dist to trace non-release packaging
|
|
#
|
|
# Most of the computed variables are both overridable and optional.
|
|
#
|
|
# Optional parameters:
|
|
# -a process all sources in one go, instead of using separate -z calls
|
|
# -z <number> suffix all the read and written variable names with <number>
|
|
# for example read forgeurl<number>, version<number>…
|
|
# and generate forgesetupargs<number>, archiveurl<number>…
|
|
# The macro assumes that null or nil suffix is used for the primary
|
|
# package source.
|
|
# -s Silently ignore problems in forgeurl, use it if it can be parsed,
|
|
# ignore it otherwise.
|
|
# -v Be verbose and print every spec variable the macro sets.
|
|
# -i Print some info about the state of spec variables the macro may use or
|
|
# set at the end of the processing.
|
|
%forgemeta(az:sviu:) %{lua:
|
|
local mariner = require "mariner.common"
|
|
local forge = require "mariner.srpm.forge"
|
|
local verbose = rpm.expand("%{-v}") ~= ""
|
|
local informative = rpm.expand("%{-i}") ~= ""
|
|
local silent = rpm.expand("%{-s}") ~= ""
|
|
local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "")
|
|
if processall then
|
|
for _,s in pairs(mariner.getsuffixes("forgeurl")) do
|
|
forge.meta(s,verbose,informative,silent)
|
|
end
|
|
else
|
|
forge.meta(rpm.expand("%{-z*}"),verbose,informative,silent)
|
|
end
|
|
}
|
|
|
|
# Convenience macro to relay computed arguments to %setup
|
|
# Optional parameters:
|
|
# -a process all sources in one go, instead of using separate -z calls
|
|
# -z <number> read %{?forgesetupargs<number>}
|
|
# -v be verbose
|
|
%forgesetup(az:v) %{lua:
|
|
local mariner = require "mariner.common"
|
|
if (rpm.expand("%{-z}") == "") and (rpm.expand("%{-a}") ~= "") then
|
|
for _,s in pairs(mariner.getsuffixes("forgesetupargs")) do
|
|
print(rpm.expand("%setup %{!-v:-q} %{?forgesetupargs" .. s .. "}\\n"))
|
|
end
|
|
else
|
|
print( rpm.expand("%setup %{!-v:-q} %{?forgesetupargs" .. rpm.expand("%{-z*}") .. "}\\n"))
|
|
end
|
|
}
|
|
|
|
# Convenience macro to relay computed arguments to %autosetup
|
|
# Parameters relayed to %autosetup: -v -N -S -p
|
|
# Optional parameters:
|
|
# -z <number> read %{?forgesetupargs<number>}
|
|
%forgeautosetup(z:vNS:p:q) %{lua:
|
|
print(rpm.expand("%autosetup %{-v} %{-N} %{?-S} %{?-p} %{?forgesetupargs" .. rpm.expand("%{-z*}") .. "}\\n"))
|
|
}
|
|
|
|
# List files matching inclusion globs, excluding files matching exclusion blogs
|
|
# Optional parameters:
|
|
# – -i "<globs>" inclusion globs
|
|
# – -x "<globs>" exclusion globs
|
|
# Globs are space-separated lists of shell globs. Such lists require %{quote:}
|
|
# use for safe rpm argument passing.
|
|
# Alternatively, set the following rpm variables before calling the macro:
|
|
# – “listfiles_include” inclusion globs
|
|
# — “listfiles_exclude” exclusion globs
|
|
# Arguments passed to the macro without flags will be interpreted as inclusion
|
|
# globs.
|
|
%listfiles(i:x:) %{expand:
|
|
%if %{lua: print(string.len(rpm.expand("%{?-i*}%{?listfiles_include}%*")))}
|
|
listfiles_include=$(realpath -e --relative-base=. %{?-i*} %{?listfiles_include} %* | sort -u)
|
|
%if %{lua: print(string.len(rpm.expand("%{?-x*}%{?listfiles_exclude}")))}
|
|
while IFS= read -r finc ; do
|
|
realpath -qe --relative-base=. %{?-x*} %{?listfiles_exclude} \\
|
|
| sort -u | grep -q "${finc}" || echo "${finc}"
|
|
done <<< "${listfiles_include}"
|
|
%else
|
|
echo "${listfiles_include}"
|
|
%endif
|
|
%endif
|
|
}
|
|
|
|
# https://github.com/rpm-software-management/rpm/issues/581
|
|
# Write the contents of a list of rpm variables to a macro file.
|
|
# The target file must contain the corresponding anchors.
|
|
# For example %writevars -f myfile foo bar will replace:
|
|
# @@FOO@@ with the rpm evaluation of %{foo} and
|
|
# @@BAR@@ with the rpm evaluation of %{bar}
|
|
# in myfile
|
|
%writevars(f:) %{lua:
|
|
local mariner = require "mariner.common"
|
|
local macrofile = rpm.expand("%{-f*}")
|
|
local rpmvars = {}
|
|
for i = 1, rpm.expand("%#") do
|
|
table.insert(rpmvars, rpm.expand("%" .. i))
|
|
end
|
|
mariner.writevars(macrofile,rpmvars)
|
|
} |