From 6129f7d0842a11ed2538bc4c8047bf34bb505635 Mon Sep 17 00:00:00 2001 From: wenyuzifang Date: Wed, 24 Sep 2025 17:03:54 +0800 Subject: [PATCH] Update code from upstream --- ...Add-libexec-to-path-for-EPEL9-golist.patch | 52 +++++++++++++++++++ add-gobuild-and-gotest.patch | 34 ++++++++++++ go-rpm-macros.spec | 15 ++++-- remove-isdefined-function.patch | 27 ++++++++++ 4 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 0001-Add-libexec-to-path-for-EPEL9-golist.patch create mode 100644 add-gobuild-and-gotest.patch create mode 100644 remove-isdefined-function.patch diff --git a/0001-Add-libexec-to-path-for-EPEL9-golist.patch b/0001-Add-libexec-to-path-for-EPEL9-golist.patch new file mode 100644 index 0000000..6e0d7f9 --- /dev/null +++ b/0001-Add-libexec-to-path-for-EPEL9-golist.patch @@ -0,0 +1,52 @@ +From 948c86d17904abf5d9d9c42c55ab78f6b970b972 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= +Date: Tue, 5 Jul 2022 19:50:30 +0200 +Subject: [PATCH] Add libexec to path for EPEL9 golist + +--- + bin/go-rpm-integration | 2 ++ + rpm/gosymlink.deps | 2 ++ + rpm/macros.d/macros.go-rpm | 3 ++- + 3 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/bin/go-rpm-integration b/bin/go-rpm-integration +index 8a0f6b2..d460a61 100755 +--- a/bin/go-rpm-integration ++++ b/bin/go-rpm-integration +@@ -17,6 +17,8 @@ + # + # SPDX-License-Identifier: GPL-3.0-or-later + ++export PATH="${PATH}:/usr/libexec/go-rpm-macros" ++ + usage() { + cat >&2 << EOF_USAGE + Usage: $0 [ [-h] ] +diff --git a/rpm/gosymlink.deps b/rpm/gosymlink.deps +index d7f2866..a6d6538 100755 +--- a/rpm/gosymlink.deps ++++ b/rpm/gosymlink.deps +@@ -16,6 +16,8 @@ + # + # SPDX-License-Identifier: GPL-3.0-or-later + ++export PATH="${PATH}:/usr/libexec/go-rpm-macros" ++ + usage() { + cat >&2 << EOF_USAGE + Usage: $0 [ [-h] ] +diff --git a/rpm/macros.d/macros.go-rpm b/rpm/macros.d/macros.go-rpm +index f773f34..9cad4df 100644 +--- a/rpm/macros.d/macros.go-rpm ++++ b/rpm/macros.d/macros.go-rpm +@@ -186,6 +186,7 @@ else + end + print(rpm.expand('GOPATH="%{?gobuilddir:%{gobuilddir}:}${GOPATH:+${GOPATH}:}%{?gopath}" ' .. + 'GO111MODULE=off ' .. ++ 'PATH="${PATH}:%{_libexecdir}/go-rpm-macros" ' .. + "golist --imported " .. golistargs .. + " --template 'golang({{.}})\\\\n'" .. + " --with-tests --skip-self\\n")) +-- +2.36.1 + diff --git a/add-gobuild-and-gotest.patch b/add-gobuild-and-gotest.patch new file mode 100644 index 0000000..81c3fda --- /dev/null +++ b/add-gobuild-and-gotest.patch @@ -0,0 +1,34 @@ +From 1001f5a99439556c5ad3efe6045923e985a52f82 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alejandro=20S=C3=A1ez?= +Date: Wed, 22 Sep 2023 12:00:00 +0100 +Subject: [PATCH] Add %gobuild and %gotest + +Both macros are define in rpm/macros.d/macros.go-compilers-gcc. +CentOS Stream 9 go-srpm-macros discards that file and only installs rpm/macros.d/macros.go-srpm. + +This commit adds %gobuild and %gotest to rpm/macros.d/macros.go-srpm with the same options that RHEL 8 uses. + +This also sets the base ISA for x86_64 and Power. +--- + rpm/macros.d/macros.go-srpm | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/rpm/macros.d/macros.go-srpm b/rpm/macros.d/macros.go-srpm +index a46f81f..05cd6c9 100644 +--- a/rpm/macros.d/macros.go-srpm ++++ b/rpm/macros.d/macros.go-srpm +@@ -202,3 +202,11 @@ local processall = (rpm.expand("%{-a}") ~= "") and (rpm.expand("%{-z}") == "") + local verbose = (rpm.expand("%{-v}") ~= "") + go.files("alt", suffix, processall, verbose) + } ++ ++# Define commands for building ++# BUILD_ID can be generated for golang build no matter of debuginfo ++%gobuild(o:) \ ++GOPPC64=power9 GOAMD64=v2 CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-all" go build -compiler gc -buildmode pie -tags="rpm_crashtraceback libtrust_openssl ${GO_BUILDTAGS-${BUILDTAGS-}}" -ldflags "-linkmode=external -compressdwarf=false ${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags'" -a -v -x %{?**};\ ++ ++# Define commands for testing ++%gotest() go test -compiler gc -ldflags "${LDFLAGS:-}" %{?**}; +-- +2.38.1 + diff --git a/go-rpm-macros.spec b/go-rpm-macros.spec index 6c68c60..159b827 100644 --- a/go-rpm-macros.spec +++ b/go-rpm-macros.spec @@ -1,4 +1,4 @@ -%define anolis_release 3 +%define anolis_release 4 %bcond_with golist %global golang_arches x86_64 aarch64 loongarch64 riscv64 sw_64 @@ -9,14 +9,20 @@ ExclusiveArch: %{golang_arches} Name: go-rpm-macros -Version: 3.6.0 +BuildRequires: golang +Version: 3.6.0 Release: %{anolis_release}%{?dist} Summary: Build-stage rpm automation for Go packages License: GPLv3+ URL: https://pagure.io/%{name} -Source: https://pagure.io/%{name}/archive/%{version}/%{name}-%{version}.tar.gz +Source0: https://pagure.io/go-rpm-macros/archive/3.6.0/go-rpm-macros-3.6.0.tar.gz +Source1: https://pagure.io/golist/archive/v0.10.4/golist-0.10.4.tar.gz +Source2: golist-0.10.4-vendor.tar.xz Patch1: 1001-modify-for-anolis.patch +Patch2: remove-isdefined-function.patch +Patch3: 0001-Add-libexec-to-path-for-EPEL9-golist.patch +Patch4: add-gobuild-and-gotest.patch Requires: go-srpm-macros = %{version}-%{release} go-filesystem = %{version}-%{release} %if %{with golist} @@ -133,6 +139,9 @@ install -m 0644 -vp rpm/macros.d/macros.go-compilers-golang \ %doc README.md %changelog +* Wed Sep 24 2025 wenyuzifang - 3.6.0-4 +- Ensure compatibility with RHEL 9.5 by replacing unsupported rpm.isdefined with a backward-compatible macro check +- Ensure Go builds work consistently across RHEL and CentOS by restoring missing build and test macros * Thu Aug 14 2025 Yang Cheng - 3.6.0-3 - add support for sw_64 build diff --git a/remove-isdefined-function.patch b/remove-isdefined-function.patch new file mode 100644 index 0000000..b0dd80d --- /dev/null +++ b/remove-isdefined-function.patch @@ -0,0 +1,27 @@ +From 75a528c97a3960e993d378ab3bedd37be3620975 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alejandro=20S=C3=A1ez?= +Date: Tue, 30 Jul 2024 17:05:39 +0200 +Subject: [PATCH] Avoid using rpm.isdefined function + +isdefined is in rpm >= 4.17.0 but RHEL 9.5 is a little bit behind that +version so if fails. This should behave similar. +--- + rpm/lua/srpm/go.lua | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/rpm/lua/srpm/go.lua b/rpm/lua/srpm/go.lua +index 01a43a1..4f8011b 100644 +--- a/rpm/lua/srpm/go.lua ++++ b/rpm/lua/srpm/go.lua +@@ -69,7 +69,7 @@ local function rpmname(goipath, compatid) + -- numbers on top of it, keep a - prefix before version strings + result = string.gsub(result, "%-v([%.%d]+)$", "-%1") + result = string.gsub(result, "%-v([%.%d]+%-)", "-%1") +- if rpm.isdefined('go_use_new_versioning') then ++ if rpm.expand("%{?go_use_new_versioning}") ~= "" then + -- according to the guidelines, if the base package name does not end with + -- a digit, the version MUST be directly appended to the package name with + -- no intervening separator. +-- +2.45.2 + -- Gitee