You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-rpm-macros-epel/macros.zzz-go-srpm-macros-epel

99 lines
4.3 KiB

3 years ago
# Copyright © 2015-2019 Jan Chaloupka <jchaloup@redhat.com>,
# Nicolas Mailhot <nim@fedoraproject.org>
# Copyright © 2022 Maxwell G <gotmax@e.email>
#
# SPDX-License-Identifier: GPL-3.0-or-later
# %%ix86 is already excluded from %%golang_arches on RHEL, so we don't need
# to redefine it. This is here for compatibility purposes.
%golang_arches_future %{golang_arches}
# Changes from RHEL 9:
# - Backport https://pagure.io/go-rpm-macros/c/4269fce7f7cbc694a61a9f97220bacb573d98426?branch=master
# - BuildRequire go-rpm-macros-epel instead of go-rpm-macros.
# Relates: https://bugzilla.redhat.com/show_bug.cgi?id=2121796
#
# Map Go information to rpm metadata. This macro will compute default spec
# variable values.
#
# The following spec variable MUST be set before calling the macro:
#
# goipath the packaged Go project import path
#
# The following spec variables SHOULD be set before calling the macro:
#
# forgeurl the project url on the forge,
# if it can not be deduced from goipath
# 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:
#
# goname an rpm-compatible package name derived from goipath
# gosource an URL that can be used as SourceX: value
# gourl an URL that can be used as URL: value
#
# It will delegate processing to the forgemeta macro for:
#
# 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 goipath<number>, version<number>…
# and generate goname<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.
# -f Use ExclusiveArch: %%{golang_arches_future}, which excludes the package
# from %ix86. All new go packages should use this option.
%gometa(az:svif) %{lua:
if rpm.expand("%{-f}") == "" then
exclusive_arches = "%{golang_arches}"
else
exclusive_arches = "%{golang_arches_future}"
end
print( "BuildRequires: go-rpm-macros-epel\\n")
print(rpm.expand("ExclusiveArch: " .. exclusive_arches .. "\\n"))
local fedora = require "fedora.common"
local go = require "fedora.srpm.go"
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(fedora.getsuffixes("goipath")) do
go.meta(s,verbose,informative,silent)
end
else
go.meta(rpm.expand("%{-z*}"),verbose,informative,silent)
end
}