From 92bf05af991401da22f5a0e104562628c886e465 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Nov 03 2021 17:00:17 +0000 Subject: import go-rpm-macros-3.0.9-8.el9 --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9935ed0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/go-rpm-macros-3.0.9.tar.gz diff --git a/.go-rpm-macros.metadata b/.go-rpm-macros.metadata new file mode 100644 index 0000000..70f9341 --- /dev/null +++ b/.go-rpm-macros.metadata @@ -0,0 +1 @@ +013899032cc1bcad52bb1fd4effe383e2afb7105 SOURCES/go-rpm-macros-3.0.9.tar.gz diff --git a/SOURCES/remove-fedora-dependency-automation.patch b/SOURCES/remove-fedora-dependency-automation.patch new file mode 100644 index 0000000..be26c25 --- /dev/null +++ b/SOURCES/remove-fedora-dependency-automation.patch @@ -0,0 +1,586 @@ +diff --git a/rpm/fileattrs/go.attr b/rpm/fileattrs/go.attr +index d4d5761..a9000a7 100644 +--- a/rpm/fileattrs/go.attr ++++ b/rpm/fileattrs/go.attr +@@ -2,5 +2,3 @@ + + %__go_path ^%{gopath}/src/.+/.goipath$ + %__go_flags path +-%__go_provides go-rpm-integration provides --prefix "%{buildroot}" --go-path "%{gopath}" %{?goprovflags} +-%__go_requires go-rpm-integration requires --prefix "%{buildroot}" --go-path "%{gopath}" %{?goreqflags} +diff --git a/rpm/lua/rpm/go.lua b/rpm/lua/rpm/go.lua +index cb5f958..fb42cb7 100644 +--- a/rpm/lua/rpm/go.lua ++++ b/rpm/lua/rpm/go.lua +@@ -72,63 +72,6 @@ local function env(suffix, goipath, verbose, usermetadata) + fedora.explicitset( "currentgoldflags", ldflags, verbose) + end + +--- Create a single set of %install tasks for a known kind of Go subpackage +-local function singleinstall(kind, suffix, verbose) +- local go = require "fedora.srpm.go" +- if (kind == "devel") then +- go.develenv(suffix, verbose) +- for goipath in string.gmatch(rpm.expand("%{currentgoipaths}"), "[^%s]+") do +- env('', goipath, verbose, {}) +- local vflag = verbose and " -v" or "" +- print(rpm.expand("%__godevelinstall -i " .. goipath .. vflag .. "\n")) +- end +- print(rpm.expand("%__godevelinstalldoc\n")) +- elseif (kind == "alt") then +- local fedora = require "fedora.common" +- local ismain = (suffix == "") or (suffix == "0") +- if ismain then +- fedora.zalias({"goaltipaths","gocid","goaltcid"}, verbose) +- end +- fedora.safeset("goaltcid" .. suffix, "%{?gocid" .. suffix .. "}", verbose) +- if ismain then +- fedora.zalias({"goaltcid"}, verbose) +- end +- for rpmname, goaltipaths in pairs(go.indexedgoipaths("%{goaltipaths" .. suffix .. "}", +- "%{goaltcid" .. suffix .. "}")) do +- go.altenv(suffix, rpmname, goaltipaths, verbose) +- gocanonipath = rpm.expand("%{currentgocanonipath}") +- for _, goaltipath in ipairs(goaltipaths) do +- fedora.explicitset("currentgoaltipath", goaltipath) +- print(rpm.expand("%__goaltinstall\n")) +- goaltipath = string.gsub(goaltipath, "/?[^/]+/?$", "") +- while (not string.match(gocanonipath, "^" .. goaltipath)) do +- print(rpm.expand('echo \'%dir "%{gopath}/src/' .. goaltipath .. '"\' >> "%{goworkdir}/%{currentgoaltfilelist}"\n')) +- goaltipath = string.gsub(goaltipath, "/?[^/]+/?$", "") +- end +- end +- end +- else +- rpm.expand("%{error:Unknown kind of Go subpackage: " .. kind .. "}") +- end +-end +- +--- Create one or all %install tasks for a known kind of go subpackage +-local function install(kind, suffix, processall, verbose) +- local fedora = require "fedora.common" +- local go = require "fedora.srpm.go" +- if (kind == "devel") then +- go.develenvinit() +- end +- if processall then +- for _, suffix in pairs(fedora.getsuffixes(go.pivot[kind])) do +- singleinstall(kind, suffix, verbose) +- end +- else +- singleinstall(kind, suffix, verbose) +- end +-end +- + return { +- env = env, +- install = install, ++ env = env, + } +diff --git a/rpm/lua/srpm/go.lua b/rpm/lua/srpm/go.lua +index 457b8f1..d650b26 100644 +--- a/rpm/lua/srpm/go.lua ++++ b/rpm/lua/srpm/go.lua +@@ -232,104 +232,6 @@ local function altenv(suffix, rpmname, goaltipaths, verbose) + end + end + +--- Create a single %package section for a known kind of Go subpackage +-local function singlepkg(kind, suffix, verbose) +- local fedora = require "fedora.common" +- if (kind == "devel") then +- develenv(suffix, verbose) +- print( +- rpm.expand( +- "%package -n %{currentgodevelname}\n" .. +- "Summary: %{currentgodevelsummary}\n" .. +- "BuildRequires: go-rpm-macros\n" .. +- "BuildArch: noarch\n" .. +- "%{?currentgodevelheader}\n" .. +- "%description -n %{currentgodevelname}\n") .. +- fedora.wordwrap("%{?currentgodeveldescription}") .. +- "\n") +- elseif (kind == "alt") then +- local ismain = (suffix == "") or (suffix == "0") +- if ismain then +- fedora.zalias({"goaltipaths","gocid","goaltcid"}, verbose) +- end +- fedora.safeset("goaltcid" .. suffix, "%{?gocid" .. suffix .. "}", verbose) +- if ismain then +- fedora.zalias({"goaltcid"}, verbose) +- end +- for rpmname, goaltipaths in pairs(indexedgoipaths("%{goaltipaths" .. suffix .. "}", +- "%{goaltcid" .. suffix .. "}")) do +- altenv(suffix, rpmname, goaltipaths, verbose) +- print( +- rpm.expand( +- "%package -n %{currentgoaltname}\n" .. +- "Summary: %{currentgoaltsummary}\n" .. +- "BuildRequires: go-rpm-macros\n" .. +- "BuildArch: noarch\n" .. +- "%{?currentgoaltheader}\n" .. +- "%description -n %{currentgoaltname}\n") .. +- fedora.wordwrap("%{?currentgoaltdescription}") .. +- "\n") +- end +- else +- rpm.expand("%{error:Unknown kind of Go subpackage: " .. kind .. "}") +- end +-end +- +--- Create one or all %package sections for a known kind of go subpackage +-local function pkg(kind, suffix, processall, verbose) +- local fedora = require "fedora.common" +- if (kind == "devel") then +- develenvinit() +- end +- if processall then +- for _, suffix in pairs(fedora.getsuffixes(pivot[kind])) do +- singlepkg(kind, suffix, verbose) +- end +- else +- singlepkg(kind, suffix, verbose) +- end +-end +- +--- Create a single %files section for a known kind of Go subpackage +-local function singlefiles(kind, suffix, verbose) +- if (kind == "devel") then +- develenv(suffix, verbose) +- print(rpm.expand('%files -n %{currentgodevelname} -f "%{goworkdir}/%{currentgodevelfilelist}"\n')) +- elseif (kind == "alt") then +- local fedora = require "fedora.common" +- local ismain = (suffix == "") or (suffix == "0") +- if ismain then +- fedora.zalias({"goaltipaths","gocid","goaltcid"}, verbose) +- end +- fedora.safeset("goaltcid" .. suffix, "%{?gocid" .. suffix .. "}", verbose) +- if ismain then +- fedora.zalias({"goaltcid"}, verbose) +- end +- for rpmname, goaltipaths in pairs(indexedgoipaths("%{goaltipaths" .. suffix .. "}", +- "%{goaltcid" .. suffix .. "}")) do +- altenv(suffix, rpmname, goaltipaths, verbose) +- print(rpm.expand('%files -n %{currentgoaltname} -f "%{goworkdir}/%{currentgoaltfilelist}"\n')) +- end +- else +- rpm.expand("%{error:Unknown kind of Go subpackage: " .. kind .. "}") +- end +-end +- +--- Create one or all %files sections for a known kind of go subpackage +-local function files(kind, suffix, processall, verbose) +- local fedora = require "fedora.common" +- if (kind == "devel") then +- develenvinit() +- end +- if processall then +- for _, suffix in pairs(fedora.getsuffixes(pivot[kind])) do +- singlefiles(kind, suffix, verbose) +- end +- else +- singlefiles(kind, suffix, verbose) +- end +-end +- + return { + rpmname = rpmname, + meta = meta, +@@ -338,6 +240,5 @@ return { + develenvinit = develenvinit, + develenv = develenv, + altenv = altenv, +- pkg = pkg, +- files = files, + } ++ +diff --git a/rpm/macros.d/macros.go-compilers-golang b/rpm/macros.d/macros.go-compilers-golang +index b0ab4c4..942549f 100644 +--- a/rpm/macros.d/macros.go-compilers-golang ++++ b/rpm/macros.d/macros.go-compilers-golang +@@ -20,6 +20,8 @@ + # + # SPDX-License-Identifier: GPL-3.0-or-later + ++%gocompilerflags -buildmode pie -compiler gc ++ + # This *must* be all on one line, as it will be used in shell + # assignments. eg + # +@@ -29,22 +31,33 @@ + # + # %make GOBUILDFLAGS="%gobuildflags" + # +-%gobuildflags() %{expand:%{gocompilerflags} -tags=\\"rpm_crashtraceback \\" -ldflags \\"${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'\\" -a -v -x} ++%gobuildflags() %{expand:%{gocompilerflags} -tags=\\"rpm_crashtraceback ${BUILDTAGS:-} libtrust_openssl\\" -ldflags \\"-linkmode=external -compressdwarf=false ${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'\\" -a -v -x} ++%_gobuildflags_internal() %{expand:%{gocompilerflags} -tags="rpm_crashtraceback ${BUILDTAGS:-} libtrust_openssl" -ldflags "-linkmode=external -compressdwarf=false ${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x} + + # Turn off Go modules + %gomodulesmode GO111MODULE=off + + # Define commands for building + # BUILD_ID can be generated for golang build no matter of debuginfo ++ ++%_gobuild_cmd CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-all" go build %{_gobuildflags_internal} ++%gobuild_compat_el8(o:) %{expand:%{_gobuild_cmd} %{?**};} + %gobuild(o:) %{expand: + # https://bugzilla.redhat.com/show_bug.cgi?id=995136#c12 + %global _dwz_low_mem_die_limit 0 + %{?gobuilddir:GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} %{?gomodulesmode} \\ +- go build %{?gocompilerflags} -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-}%{?currentgoldflags} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags %{?__golang_extldflags}'" -a -v -x %{?**}; ++ %{_gobuild_cmd} %{?**}; + } + ${workroot}${GOPATH:+:${GOPATH}} + + # Define commands for testing + %gotestflags %{gocompilerflags} + %gotestextldflags %__global_ldflags %{?__golang_extldflags} +-%gotest() %{?gomodulesmode} go test %{gotestflags} -ldflags "${LDFLAGS:-}%{?currentgoldflags} -extldflags '%{gotestextldflags}'" %{?**}; ++ ++%_gotest_cmd %{?gomodulesmode} go test %{gotestflags} -ldflags "${LDFLAGS:-}%{?currentgoldflags} -extldflags '%{gotestextldflags}'" ++%gotest_compat_el8(o:) %{expand:%{_gotest_cmd} %{?**};} ++%gotest(o:) %{expand: ++ %{?gobuilddir:GOPATH="%{gobuilddir}:${GOPATH:+${GOPATH}:}%{?gopath}"} %{?gomodulesmode} \\ ++ %{_gotest_cmd} %{?**}; ++} ++ +diff --git a/rpm/macros.d/macros.go-rpm b/rpm/macros.d/macros.go-rpm +index f773f34..b82581b 100644 +--- a/rpm/macros.d/macros.go-rpm ++++ b/rpm/macros.d/macros.go-rpm +@@ -22,42 +22,6 @@ + # + # SPDX-License-Identifier: GPL-3.0-or-later + +-# Default filtering policy +-# Complete or replace the following variables in your spec file if this policy +-# does not apply to your project +-# +-# Specific example matching rule. +-# The average Go project example code is incomplete and obsolete. It will +-# fail to compile as-is, or even panic. It will poison the dependency +-# generator with bogus or legacy import path requirements. Even when it it +-# clean and up to date, it will require many third party components not needed +-# in production. Therefore: +-# – never install Go project example code in %{gopath}. Publish is as %doc. +-# — ask politely projects that publish example code in some other directory +-# than _examples to rename it. +-# – never rely on third party examples being available or working in another +-# project. This is *not* production code. Ask upstreams politely to remove +-# tests or code that import other project examples. +-%goignoreflags_examples -r '.*example.*' +- +-# Default flags to apply in all stages +-%godefaultflags %{goignoreflags_examples} +- +-# Default flags to apply in Go install (%goinstall) +-%goinstallflags %{godefaultflags} +- +-# Default flags to apply in Go checks (%gochecks) +-%gocheckflags %{godefaultflags} +- +-# Default flags to apply in Go autoprovides +-%goprovflags %{godefaultflags} +- +-# Default flags to apply in Go autorequires +-%goreqflags %{godefaultflags} +- +-# The default filelist name generated by %goinstall +-%gofilelist devel.file-list +- + # Sets environment variables suitable for a Go source archive. Optional arguments: + # -z read the zth block of definitions, for example + # %{goipath}, %{commit}… +@@ -116,6 +80,7 @@ fi + cd "%{mybuilddir}/src/%{mygoipath}" + } + ++ + # Perform usual Go source preparation steps. Optional arguments: + # -z read the zth block of definitions, for example + # %{goipath}, %{commit}… +@@ -160,207 +125,3 @@ else + process(rpm.expand("%{?-z*}")) + end + } +- +-# Computes BuildRequires for a given import path. Arguments: +-# -z read the zth block of definitions, for example +-# %{goipath}, %{commit}… +-# derived from the import path value if not specified +-# -a process all sources in one go, instead of using separate +-# -z calls +-# -i use the specified import path value instead of the one +-# found in %{goipath} +-%go_generate_buildrequires(z:ai:) %{lua: +-local fedora = require "fedora.common" +-local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") +-local forcedgoipath = rpm.expand("%{?-i}") +-local golistargs = "" +-if processall then +- for _, s in pairs(fedora.getsuffixes("goipath")) do +- golistargs = golistargs .. " --package-path %{goipath" .. s .. "}" +- end +- golistargs = string.gsub(golistargs, "^ ", "") +-elseif forcedgoipath ~= "" then +- golistargs = "--package-path " .. forcedgoipath +-else +- golistargs = "--package-path %{goipath" .. rpm.expand("%{?-z*}") .. "}" +-end +-print(rpm.expand('GOPATH="%{?gobuilddir:%{gobuilddir}:}${GOPATH:+${GOPATH}:}%{?gopath}" ' .. +- 'GO111MODULE=off ' .. +- "golist --imported " .. golistargs .. +- " --template 'golang({{.}})\\\\n'" .. +- " --with-tests --skip-self\\n")) +-} +- +-# Try to install Go package files in sensible locations, with strict directory +-# ownership and lockfile creation as required by Go autodeps. +-# +-# Simple arguments, that can not be repeated: +-# -z read the zth block of definitions, for example +-# %{goipath}, %{commit}… +-# derived from the import path value if not specified +-# -a process all sources in one go, instead of using separate +-# -z calls +-# -i use the specified import path value +-# default: %{goipath} +-# -b read binaries already produced in +-# default: %{gobuilddir}/bin +-# -s read expanded and prepared Go sources in /src +-# should be populated in %prep +-# default: %{gobuilddir} +-# -o output installed file list in +-# default: %{gofilelist} +-# -O output in +-# -l add those flags to LDFLAGS when building unit tests +-# -v be verbose +-# +-# Inclusion arguments, that can be repeated: +-# -e include files with the provided extension +-# +-# Exclusion arguments, that can be repeated, relative to the go import path root: +-# -d exclude the files contained in +-# not recursive (subdirectories are not excluded) +-# -t exclude the files contained in +-# recursive (subdirectories are excluded) +-# -r exclude files matching , +-# +-# Optional versionning metadata, that can not be repeated: +-# -V Should only be specified when creating subpackages with +-# distinct versions +-# default: %{version}.%{release} +-# -T default: %{tag} +-# -C default: %{commit} +-# -B default: %{branch} +-# +-# When invoked several times with the same import path goinstall will append to +-# the existing file list if versionning and exclusion arguments are identical to +-# previous calls, and error out otherwise. +-# When invoked several times with different file list names, it will attribute +-# directories to the first file list that makes use of them. +-%goinstall(z:ai:b:s:o:O:ve:d:t:rV:T:C:B:p:g:) %{lua: +-local fedora = require "fedora.common" +-local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") +-local myenvflags = rpm.expand('%{?-i} %{?-v} %{?-V} %{?-T} %{?-C} %{?-B}') +-local myinstallflags = rpm.expand('%{!-i:-i "%%{currentgoipath}" }' .. +- '%{!-b:-b "%%{gobuilddir}/bin" }' .. +- '%{!-s:-s "%%{gobuilddir}" }' .. +- '%{!-o:-o "%%{thisgofilelist}" }' .. +- '%{!-O:-O "%%{goworkdir}" }' .. +- '%{!-V:-V "%{version}-%{release}" }' .. +- '%{!-T:%%{?currenttag: -T "%%{?currenttag}" }}' .. +- '%{!-C:%%{?currentcommit: -C "%%{?currentcommit}" }}' .. +- '%{!-B:%%{?currentbranch: -B "%%{?currentbranch}" }}' .. +- '%{!-p:-p "%{buildroot}" }' .. +- '%{!-g:-g "%{gopath}" }' .. +- '%{?goinstallflags} %{?**}') +--- Main function +-local function process(suffix) +- local zsuffix = "" +- if (suffix ~= "") and (suffix ~= nil) then +- zsuffix = "-z " .. suffix .. " " +- end +- print(rpm.expand('%goenv ' .. zsuffix .. myenvflags .. '\\n' .. +- 'go-rpm-integration install ' .. myinstallflags .. '\\n')) +-end +--- Main loop +-if processall then +- for _,s in pairs(fedora.getsuffixes("goipath")) do +- process(s) +- end +-else +- process(rpm.expand("%{-z*}")) +-end +-} +- +-# Perform the %install tasks of every known kind of Go subpackage. Arguments: +-# -v be verbose +-%gopkginstall(av) %{expand: +-%godevelinstall -a %{-v} +-%goaltinstall -a %{-v} +-} +- +-# Perform the %install tasks of a golang-*-devel subpackage. Arguments: +-# -z read the zth block of definitions, for example +-# %{goipaths} +-# -a process all blocks in one go, instead of using separate +-# -z calls +-# -v be verbose +-%godevelinstall(z:av) %{lua: +-local go = require "fedora.rpm.go" +-local suffix = rpm.expand("%{-z*}") +-local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") +-local verbose = (rpm.expand("%{-v}") ~= "") +-go.install("devel", suffix, processall, verbose) +-} +- +-# Perform the %install tasks of a compat-golang-*-devel subpackage. Arguments: +-# -z read the zth block of definitions, for example +-# %{goaltipaths} +-# -a process all blocks in one go, instead of using separate +-# -z calls +-# -v be verbose +-%goaltinstall(z:av) %{lua: +-local go = require "fedora.rpm.go" +-local suffix = rpm.expand("%{-z*}") +-local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") +-local verbose = (rpm.expand("%{-v}") ~= "") +-go.install("alt", suffix, processall, verbose) +-} +- +-# Run go test with Fedora flags on all subdirectories except for those filtered out +-# THIS MACRO IS OPT-OUT. +-# +-# Simple arguments, that can not be repeated: +-# -z read the zth block of definitions, for example +-# %{goipath}, %{commit}… +-# derived from the import path value if not specified +-# -a process all sources in one go, instead of using separate +-# -z calls +-# -i use the specified import path value +-# default: %{goipath} +-# -b read binaries already produced in +-# default: %{gobuilddir}/bin +-# -s read expanded and prepared Go sources in /src +-# should be populated in %prep +-# default: %{gobuilddir} +-# -v be verbose +-# Exclusion arguments, that can be repeated, relative to the go import path root: +-# -d exclude the files contained in +-# not recursive (subdirectories are not excluded) +-# -t exclude the files contained in +-# recursive (subdirectories are excluded) +-# -r exclude files matching , +-%gocheck(z:ai:b:s:vd:t:rV:T:C:B:p:g:w) %{lua: +-local fedora = require "fedora.common" +-local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") +-local myenvflags = rpm.expand('%{?-i} %{?-v} %{?-V} %{?-T} %{?-C} %{?-B}') +-local mycheckflags = rpm.expand('%{!-i:-i "%%{currentgoipath}" }' .. +- '%{!-b:-b "%%{gobuilddir}/bin" }' .. +- '%{!-s:-s "%%{gobuilddir}" }' .. +- '%{!-V:-V "%{version}-%{release}" }' .. +- '%{!-T:%%{?currenttag: -T "%%{?currenttag}" }}' .. +- '%{!-C:%%{?currentcommit: -C "%%{?currentcommit}" }}' .. +- '%{!-B:%%{?currentbranch: -B "%%{?currentbranch}" }}' .. +- '%{!-p:-p "%{buildroot}" }' .. +- '%{!-g:-g "%{gopath}" }' .. +- '%{?gocheckflags} %{?**}') +--- Main function +-local function process(suffix) +- local zsuffix = "" +- if (suffix ~= "") and (suffix ~= nil) then +- zsuffix = "-z " .. suffix .. " " +- end +- print(rpm.expand('%goenv ' .. zsuffix .. myenvflags .. '\\n' .. +- '%{?currentgoldflags:LDFLAGS="${LDFLAGS} %{?currentgoldflags}" }' .. +- '%{?gotestflags:GO_TEST_FLAGS="%{gotestflags}" }' .. +- '%{?gotestextldflags:GO_TEST_EXT_LD_FLAGS="%{gotestextldflags}" }' .. +- 'go-rpm-integration check ' .. mycheckflags .. '\\n')) +-end +--- Main loop +-if processall then +- for _,s in pairs(fedora.getsuffixes("goipath")) do +- process(s) +- end +-else +- process(rpm.expand("%{-z*}")) +-end +-} +diff --git a/rpm/macros.d/macros.go-srpm b/rpm/macros.d/macros.go-srpm +index 884463f..60b62ac 100644 +--- a/rpm/macros.d/macros.go-srpm ++++ b/rpm/macros.d/macros.go-srpm +@@ -122,72 +122,3 @@ else + end + } + +-# Create %package sections for every known kind of go subpackage. Arguments: +-# -v be verbose +-%gopkg(av) %{expand: +-%godevelpkg -a %{-v} +-%goaltpkg -a %{-v} +-} +- +-# Create a %package section for a golang-*-devel subpackage. Arguments: +-# -z read the zth block of definitions, for example +-# %{goipaths} +-# -a process all blocks in one go, instead of using separate +-# -z calls +-# -v be verbose +-%godevelpkg(z:av) %{lua: +-local go = require "fedora.srpm.go" +-local suffix = rpm.expand("%{-z*}") +-local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") +-local verbose = (rpm.expand("%{-v}") ~= "") +-go.pkg("devel", suffix, processall, verbose) +-} +- +-# Create a %package section for a compat-golang-*-devel subpackage. Arguments: +-# -z read the zth block of definitions, for example +-# %{goaltipaths} +-# -a process all blocks in one go, instead of using separate +-# -z calls +-# -v be verbose +-%goaltpkg(z:av) %{lua: +-local go = require "fedora.srpm.go" +-local suffix = rpm.expand("%{-z*}") +-local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") +-local verbose = (rpm.expand("%{-v}") ~= "") +-go.pkg("alt", suffix, processall, verbose) +-} +- +-# Create %files sections for every known kind of Go subpackage. Arguments: +-# -v be verbose +-%gopkgfiles(av) %{expand: +-%godevelfiles -a %{-v} +-%goaltfiles -a %{-v} +-} +- +-# Create a %files section for a golang-*-devel subpackage. Arguments: +-# -z read the zth block of definitions, for example +-# %{goipaths} +-# -a process all blocks in one go, instead of using separate +-# -z calls +-# -v be verbose +-%godevelfiles(z:av) %{lua: +-local go = require "fedora.srpm.go" +-local suffix = rpm.expand("%{-z*}") +-local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") +-local verbose = (rpm.expand("%{-v}") ~= "") +-go.files("devel", suffix, processall, verbose) +-} +- +-# Create a %files section for a compat-golang-*-devel subpackage. Arguments: +-# -z read the zth block of definitions, for example +-# %{goaltipaths} +-# -a process all blocks in one go, instead of using separate +-# -z calls +-# -v be verbose +-%goaltfiles(z:av) %{lua: +-local go = require "fedora.srpm.go" +-local suffix = rpm.expand("%{-z*}") +-local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") +-local verbose = (rpm.expand("%{-v}") ~= "") +-go.files("alt", suffix, processall, verbose) +-} diff --git a/SPECS/go-rpm-macros.spec b/SPECS/go-rpm-macros.spec new file mode 100644 index 0000000..e8d1e14 --- /dev/null +++ b/SPECS/go-rpm-macros.spec @@ -0,0 +1,236 @@ +%global forgeurl https://pagure.io/go-rpm-macros +Version: 3.0.9 +%forgemeta + +#https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/51 +%global _spectemplatedir %{_datadir}/rpmdevtools/fedora +%global _docdir_fmt %{name} + +# Master definition that will be written to macro files +%global golang_arches %{ix86} x86_64 %{arm} aarch64 ppc64le s390x +%global gccgo_arches %{mips} +%if 0%{?rhel} >= 9 +%global golang_arches x86_64 aarch64 ppc64le s390x +%endif +# Go sources can contain arch-specific files and our macros will package the +# correct files for each architecture. Therefore, move gopath to _libdir and +# make Go devel packages archful +%global gopath %{_datadir}/gocode + +ExclusiveArch: %{golang_arches} %{gccgo_arches} + +Name: go-rpm-macros +Release: 8%{?dist} +Summary: Build-stage rpm automation for Go packages + +License: GPLv3+ +URL: %{forgeurl} +Source: %{forgesource} + +Requires: go-srpm-macros = %{version}-%{release} +Requires: go-filesystem = %{version}-%{release} + +Patch0: remove-fedora-dependency-automation.patch + +%ifarch %{golang_arches} +Requires: golang +Provides: compiler(golang) +Provides: compiler(go-compiler) = 2 +Obsoletes: go-compilers-golang-compiler < %{version}-%{release} +%endif + +%ifarch %{gccgo_arches} +Requires: gcc-go +Provides: compiler(gcc-go) +Provides: compiler(go-compiler) = 1 +Obsoletes: go-compilers-gcc-go-compiler < %{version}-%{release} +%endif + +%description +This package provides build-stage rpm automation to simplify the creation of Go +language (golang) packages. + +It does not need to be included in the default build root: go-srpm-macros will +pull it in for Go packages only. + +%package -n go-srpm-macros +Summary: Source-stage rpm automation for Go packages +BuildArch: noarch +Requires: redhat-rpm-config + +%description -n go-srpm-macros +This package provides SRPM-stage rpm automation to simplify the creation of Go +language (golang) packages. + +It limits itself to the automation subset required to create Go SRPM packages +and needs to be included in the default build root. + +The rest of the automation is provided by the go-rpm-macros package, that +go-srpm-macros will pull in for Go packages only. + +%package -n go-filesystem +Summary: Directories used by Go packages +License: Public Domain + +%description -n go-filesystem +This package contains the basic directory layout used by Go packages. + +%package -n go-rpm-templates +Summary: RPM spec templates for Go packages +License: MIT +BuildArch: noarch +Requires: go-rpm-macros = %{version}-%{release} +#https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/51 +#Requires: redhat-rpm-templates + +%description -n go-rpm-templates +This package contains documented rpm spec templates showcasing how to use the +macros provided by go-rpm-macros to create Go packages. + +%prep + +%forgesetup + +# remove fedora-specific macros and templates +%patch0 -p1 +DELETE_FILES=$( + cat << EOF + bin/go-rpm-integration + rpm/fileattrs/gobundled.attr + rpm/fileattrs/gosymlink.attr + rpm/gobundled.prov + rpm/gosymlink.deps + rpm/macros.d/macros.go-compilers-golang-nopie + rpm/macros.d/macros.go-compilers-golang-pie + rpm/macros.d/macros.go-rpm.internal + templates/rpm/spectemplate-go-0-source-minimal.spec + templates/rpm/spectemplate-go-1-source-full.spec + templates/rpm/spectemplate-go-2-alternative-import-path-minimal.spec + templates/rpm/spectemplate-go-3-alternative-import-path-full.spec + templates/rpm/spectemplate-go-4-binary-minimal.spec + templates/rpm/spectemplate-go-5-binary-full.spec + templates/rpm/spectemplate-go-6-multi.spec + templates/rpm/spectemplate-go-7-manual.spec +EOF +) +for i in $DELETE_FILES; do + rm --interactive=never $i +done +# these directories should now be empty +rmdir -p bin templates/rpm + +%writevars -f rpm/macros.d/macros.go-srpm golang_arches gccgo_arches gopath +if ls templates/rpm/*\.spec; then + for template in templates/rpm/*\.spec ; do + target=$(echo "${template}" | sed "s|^\(.*\)\.spec$|\1-bare.spec|g") + grep -v '^#' "${template}" > "${target}" + touch -r "${template}" "${target}" + done +fi + +%install +# Some of those probably do not work with gcc-go right now +# This is not intentional, but mips is not a primary Fedora architecture +# Patches and PRs are welcome + +install -m 0755 -vd %{buildroot}%{gopath}/src + +install -m 0755 -vd %{buildroot}%{_spectemplatedir} + +if ls templates/rpm/*\.spec; then + install -m 0644 -vp templates/rpm/*spec \ + %{buildroot}%{_spectemplatedir} +fi + +install -m 0755 -vd %{buildroot}%{rpmmacrodir} +install -m 0644 -vp rpm/macros.d/macros.go-* \ + %{buildroot}%{rpmmacrodir} +install -m 0755 -vd %{buildroot}%{_rpmluadir}/fedora/srpm +install -m 0644 -vp rpm/lua/srpm/*lua \ + %{buildroot}%{_rpmluadir}/fedora/srpm +install -m 0755 -vd %{buildroot}%{_rpmluadir}/fedora/rpm +install -m 0644 -vp rpm/lua/rpm/*lua \ + %{buildroot}%{_rpmluadir}/fedora/rpm +install -m 0755 -vd %{buildroot}%{_rpmconfigdir}/fileattrs +install -m 0644 -vp rpm/fileattrs/*.attr \ + %{buildroot}%{_rpmconfigdir}/fileattrs/ + +%ifarch %{golang_arches} +install -m 0644 -vp rpm/macros.d/macros.go-compilers-golang \ + %{buildroot}%{_rpmconfigdir}/macros.d/macros.go-compiler-golang +%endif + +%ifarch %{gccgo_arches} +install -m 0644 -vp rpm/macros.d/macros.go-compilers-gcc \ + %{buildroot}%{_rpmconfigdir}/macros.d/macros.go-compiler-gcc +%endif + +%files +%license LICENSE.txt +%doc README.md +%{_rpmconfigdir}/fileattrs/*.attr +%{_rpmconfigdir}/macros.d/macros.go-rpm* +%{_rpmconfigdir}/macros.d/macros.go-compiler* +%{_rpmluadir}/fedora/rpm/*.lua + +%files -n go-srpm-macros +%license LICENSE.txt +%doc README.md +%{_rpmconfigdir}/macros.d/macros.go-srpm +%{_rpmluadir}/fedora/srpm/*.lua + +%files -n go-filesystem +%dir %{gopath} +%dir %{gopath}/src + +%files -n go-rpm-templates +%license LICENSE-templates.txt +%doc README.md +# https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/51 +%dir %{dirname:%{_spectemplatedir}} +%dir %{_spectemplatedir} + +%changelog +* Mon Aug 09 2021 Mohan Boddu +- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags + Related: rhbz#1991688 + +* Wed Aug 03 2021 David Benoit 3.0.9-7 +- Escape quotation marks in gobuildflags +- Resolves: rhbz#1988717 + +* Tue Jul 27 2021 David Benoit 3.0.9-6 +- Remove arch conditional on gocompilerflags +- Related: rhbz#1982298 + +* Fri Jul 23 2021 David Benoit 3.0.9-5 +- Remove fedora-specific Go dependency automation macros +- Remove dependency on golist +- Temporarily remove incompatible template spec files +- Update gobuild flags +- Resolves: rhbz#1982298 + +* Thu Apr 15 2021 Mohan Boddu +- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 + +* Thu Feb 11 2021 Jeff Law - 3.0.9-3 +- Drop 32 bit arches in EL 9 (originally from Petr Sabata) + +* Tue Jan 26 2021 Fedora Release Engineering - 3.0.9-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Thu Aug 13 2020 Neal Gompa - 3.0.9-1 +- Update to 3.0.9 + +* Mon Jul 27 2020 Fedora Release Engineering - 3.0.8-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Tue Jan 28 2020 Fedora Release Engineering - 3.0.8-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Jul 25 2019 Fedora Release Engineering - 3.0.8-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Wed Jun 05 2019 Nicolas Mailhot +- 3.0.8-3 +- initial Fedora import, for golist 0.10.0 and redhat-rpm-config 130