From 05f7a334da644615452e37c45ef6080673735525 Mon Sep 17 00:00:00 2001 From: wenyuzifangtest001 Date: Tue, 16 Sep 2025 23:56:36 +0800 Subject: [PATCH] Update code from upstream --- add-gobuild-and-gotest.patch | 34 +++++++++++++++++++++++++++++++++ go-rpm-macros.spec | 14 +++++++++++--- remove-isdefined-function.patch | 27 ++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 add-gobuild-and-gotest.patch create mode 100644 remove-isdefined-function.patch 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..f8d1e5b 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,19 @@ 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: add-gobuild-and-gotest.patch Requires: go-srpm-macros = %{version}-%{release} go-filesystem = %{version}-%{release} %if %{with golist} @@ -133,6 +138,9 @@ install -m 0644 -vp rpm/macros.d/macros.go-compilers-golang \ %doc README.md %changelog +* Tue Sep 16 2025 wenyuzifangtest001 - 3.6.0-4 +- Apply to ensure compatibility with older RPM versions and prevent build failures. +- Ensure consistent, secure Go builds by restoring missing %gobuild and %gotest macros in CentOS Stream 9. * 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