From a7fd2bea6e4bd944735fc3df4d79210dcfa3d769082d3fa751201681877a9d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Mon, 11 Nov 2024 11:01:24 +0100 Subject: [PATCH] Sync from SUSE:SLFO:1.1 golang-github-prometheus-promu revision 29ce3cba700f88d42ae9d103fc507a4d --- ...er_user_host_for_reproducible_builds.patch | 74 ------------------- _service | 11 ++- _servicedata | 2 +- extldflags-no-static.patch | 13 ++++ golang-github-prometheus-promu.changes | 73 +++++++++++------- golang-github-prometheus-promu.spec | 41 +++++----- promu-0.15.0.obscpio | 3 - promu-0.16.0.obscpio | 3 + promu.obsinfo | 6 +- vendor.tar.gz | 4 +- 10 files changed, 95 insertions(+), 135 deletions(-) delete mode 100644 0001-do_not_discover_user_host_for_reproducible_builds.patch create mode 100644 extldflags-no-static.patch delete mode 100644 promu-0.15.0.obscpio create mode 100644 promu-0.16.0.obscpio diff --git a/0001-do_not_discover_user_host_for_reproducible_builds.patch b/0001-do_not_discover_user_host_for_reproducible_builds.patch deleted file mode 100644 index fb57518..0000000 --- a/0001-do_not_discover_user_host_for_reproducible_builds.patch +++ /dev/null @@ -1,74 +0,0 @@ -Index: promu-0.15.0/cmd/build.go -=================================================================== ---- promu-0.15.0.orig/cmd/build.go -+++ promu-0.15.0/cmd/build.go -@@ -32,6 +32,10 @@ import ( - "github.com/prometheus/promu/util/sh" - ) - -+const ( -+ sourceDateEpoch = "SOURCE_DATE_EPOCH" -+) -+ - var ( - buildcmd = app.Command("build", "Build a Go project") - buildCgoFlagSet bool -@@ -155,7 +159,7 @@ func getLdflags(info repository.Info) st - tmplOutput = new(bytes.Buffer) - fnMap = template.FuncMap{ - "date": buildDate.UTC().Format, -- "host": os.Hostname, -+ "host": HostFunc, - "repoPath": RepoPathFunc, - "user": UserFunc, - } -@@ -191,13 +195,13 @@ func getLdflags(info repository.Info) st - func getBuildDate() time.Time { - var buildDate time.Time - -- sourceDate := os.Getenv("SOURCE_DATE_EPOCH") -+ sourceDate := os.Getenv(sourceDateEpoch) - if sourceDate == "" { - buildDate = time.Now() - } else { - unixBuildDate, err := strconv.ParseInt(sourceDate, 10, 64) - if err != nil { -- fatal(errors.Wrap(err, "Failed to parse SOURCE_DATE_EPOCH")) -+ fatal(errors.Wrap(err, "Failed to parse "+sourceDateEpoch)) - } else { - buildDate = time.Unix(unixBuildDate, 0) - } -@@ -205,10 +209,31 @@ func getBuildDate() time.Time { - return buildDate - } - -+func HostFunc() string { -+ if isReproducibleBuild() { -+ return "reproducible" -+ } else { -+ hostname, err := os.Hostname() -+ if err != nil { -+ return "unknown-host" -+ } else { -+ return hostname -+ } -+ } -+} -+ - // UserFunc returns the current username. - func UserFunc() (interface{}, error) { -- // os/user.Current() doesn't always work without CGO -- return shellOutput("whoami"), nil -+ if isReproducibleBuild() { -+ return "reproducible", nil -+ } else { -+ // os/user.Current() doesn't always work without CGO -+ return shellOutput("whoami"), nil -+ } -+} -+ -+func isReproducibleBuild() bool { -+ return os.Getenv(sourceDateEpoch) != "" - } - - // RepoPathFunc returns the repository path. diff --git a/_service b/_service index 04c00a2..3a57ad8 100644 --- a/_service +++ b/_service @@ -1,22 +1,21 @@ - + https://github.com/prometheus/promu.git git .git @PARENT_TAG@ - v0.15.0 + v0.16.0 v(.*) - enable *.tar gz - + promu - - promu-0.15.0.obscpio + + promu-0.16.0.obscpio diff --git a/_servicedata b/_servicedata index 683f9c2..fa7045a 100644 --- a/_servicedata +++ b/_servicedata @@ -1,4 +1,4 @@ https://github.com/prometheus/promu.git - e1bab893555f728998f2bd404c4b7e66931bc760 \ No newline at end of file + 36b1874b73015223f942a3d71d534aa2ab8b6430 \ No newline at end of file diff --git a/extldflags-no-static.patch b/extldflags-no-static.patch new file mode 100644 index 0000000..a469a7b --- /dev/null +++ b/extldflags-no-static.patch @@ -0,0 +1,13 @@ +Index: promu-0.15.0/cmd/promu.go +=================================================================== +--- promu-0.15.0.orig/cmd/promu.go ++++ promu-0.15.0/cmd/promu.go +@@ -73,7 +73,7 @@ func NewConfig() *Config { + config := &Config{} + config.Build.Binaries = []Binary{{Name: projInfo.Name, Path: "."}} + config.Build.Prefix = "." +- config.Build.Static = true ++ config.Build.Static = false + config.Crossbuild.Platforms = defaultPlatforms + config.Tarball.Prefix = "." + config.Go.Version = "1.12" diff --git a/golang-github-prometheus-promu.changes b/golang-github-prometheus-promu.changes index ca05f7e..b63b5d9 100644 --- a/golang-github-prometheus-promu.changes +++ b/golang-github-prometheus-promu.changes @@ -1,5 +1,51 @@ ------------------------------------------------------------------- -Tue Aug 8 11:53:00 UTC 2023 - Witek Bedyk +Mon Sep 23 09:20:55 UTC 2024 - Witek Bedyk + +- Drop 0001-do_not_discover_user_host_for_reproducible_builds.patch +- Require Go 1.21 for building +- Packaging improvements: + * Use obscpio, run tar and recompresss services at buildtime. + * _service change disabled to manual per osc deprecation warning: + WARNING: Command 'disabledrun/dr' is obsolete, please convert + your _service to use 'manual' and then 'manualrun/mr' instead. + * Disable automatic chagelog file generation. + * Define shortname corresponding to binary name when different + from package name. Use shortname where applicable to normalize + common lines across Go app packages, similar to name macro. + * Drop BuildRequires: golang-packaging. The original macros for + file movements into GOPATH are obsolete with Go modules. Macro + go_nostrip is no longer needed with current binutils and Go. + * Drop export CGO_ENABLED="0". Use the default unless there is a + defined requirement or benefit (bsc#1230623). + * Build PIE with pattern that may become recommended procedure: + %%ifnarch ppc64 GOFLAGS="-buildmode=pie" %%endif go build + A go toolchain buildmode default config would be preferable + but none exist at this time. + * Drop mod=vendor, go1.14+ will detect vendor dir and auto-enable + * Remove ldflags -X entries for upstream import path and version. + This information is embedded in binaries with go1.18+ and + available via go version -m or runtime/debug.ReadBuildInfo(). + * Remove ldflags -s (Omit symbol table and debug info) and -w + (Omit DWARF symbol table). This information is used to produce + separate debuginfo packages and binaries are stripped for + reduced size by GNU strip during RPM build. + * Drop go build -o arg, default binary name is pkg of main() + * Add basic %check to execute binary --help +- Update to version 0.16.0: + * Do not discover user/host for reproducible builds + * Fix example/prometheus build error +- Update to version 0.15.0: + * Add linux/riscv64 to default platforms + * Use yaml.Unmarshalstrict to validate configuration files + +------------------------------------------------------------------- +Thu Dec 14 11:51:49 UTC 2023 - Andreas Schwab + +- extldflags-no-static.patch: Don't pass -extldflags -static by + default + +------------------------------------------------------------------- +Mon Aug 21 14:56:34 UTC 2023 - Witek Bedyk - Always set user and host build metadata to constant string to achieve reproducible builds (compare reproducible-builds.org) @@ -7,33 +53,10 @@ Tue Aug 8 11:53:00 UTC 2023 - Witek Bedyk - Require Go >= 1.19 for building - Require Go >= 1.18 for building Red Hat packages -------------------------------------------------------------------- -Tue Jul 04 10:41:07 UTC 2023 - kastl@b1-systems.de - -- Update to version 0.15.0: - * Release v0.15.0 - * Bump golang.org/x/oauth2 from 0.8.0 to 0.9.0 - * Update common Prometheus files - * Bump go.uber.org/atomic from 1.10.0 to 1.11.0 - * Update build - * Add linux/riscv64 to default platforms - * Bump github.com/prometheus/common from 0.39.0 to 0.42.0 - * Bump golang.org/x/oauth2 from 0.5.0 to 0.6.0 - * Bump github.com/prometheus/common from 0.37.0 to 0.39.0 - * Bump golang.org/x/oauth2 from 0.2.0 to 0.5.0 - * Bump golang.org/x/net from 0.2.0 to 0.7.0 - * Use unmarshalstrict - -------------------------------------------------------------------- -Wed Mar 22 10:28:44 UTC 2023 - Johannes Kastl - -- rework spec file to use obscpio - - run tar and recompresss services at buildtime - ------------------------------------------------------------------- Tue Jan 10 16:18:52 UTC 2023 - kastl@b1-systems.de -- Update to version 0.14.0: +- Update to version 0.14.0 (jsc#PED-3576): * Add the ability to override tags per GOOS * Remove ioutil * Update common Prometheus files (#232) (#224) diff --git a/golang-github-prometheus-promu.spec b/golang-github-prometheus-promu.spec index 5656e26..683e975 100644 --- a/golang-github-prometheus-promu.spec +++ b/golang-github-prometheus-promu.spec @@ -1,7 +1,7 @@ # # spec file for package golang-github-prometheus-promu # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,51 +16,50 @@ # +%define shortname promu + Name: golang-github-prometheus-promu -Version: 0.15.0 +Version: 0.16.0 Release: 0 Summary: Prometheus Utility Tool License: Apache-2.0 Group: System/Management URL: https://github.com/prometheus/promu -Source: promu-%{version}.tar.gz +Source: %{shortname}-%{version}.tar.gz Source1: vendor.tar.gz -# PATCH-FIX-UPSTREAM Fix setting reproducible user and host during the build -# https://github.com/prometheus/promu/pull/267 -Patch1: 0001-do_not_discover_user_host_for_reproducible_builds.patch -BuildRequires: golang-packaging +# PATCH-FIX-OPENSUSE Do not pass -static to external linker by default +Patch2: extldflags-no-static.patch ExcludeArch: s390 -%{go_provides} %if 0%{?rhel} # Fix ERROR: No build ID note found in %undefine _missing_build_ids_terminate_build -BuildRequires: golang >= 1.18 +BuildRequires: golang >= 1.21 %else -BuildRequires: golang(API) >= 1.19 +BuildRequires: golang(API) = 1.21 %endif %description The Prometheus Utility Tool is used by the Prometheus project to build other components. %prep -%autosetup -a1 -p1 -n promu-%{version} +%autosetup -a1 -p1 -n %{shortname}-%{version} %build -%{goprep} github.com/prometheus/promu -export VERSION=%{version} -export CGO_ENABLED=0 -go build \ - -mod=vendor \ - -buildmode=pie \ - -ldflags "-s -w -X main.version=$VERSION" \ - -o promu ; +%ifnarch ppc64 +export GOFLAGS="-buildmode=pie" +%endif +go build + +%check +# execute the binary as a basic check +./%{shortname} --help %install -install -D -m 0755 promu "%{buildroot}/%{_bindir}/promu" +install -D -m 0755 %{shortname} "%{buildroot}/%{_bindir}/%{shortname}" %files %doc README.md %license LICENSE -%{_bindir}/promu +%{_bindir}/%{shortname} %changelog diff --git a/promu-0.15.0.obscpio b/promu-0.15.0.obscpio deleted file mode 100644 index 0db0437..0000000 --- a/promu-0.15.0.obscpio +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f960311ec016bac6dda7501c5f944449746b36525003ffe0b88213789c4f7d26 -size 125451 diff --git a/promu-0.16.0.obscpio b/promu-0.16.0.obscpio new file mode 100644 index 0000000..9ce1618 --- /dev/null +++ b/promu-0.16.0.obscpio @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae77b9d543507c4719d8402ec817dac7bc93c481c29ed3b30b23e5f242010634 +size 125451 diff --git a/promu.obsinfo b/promu.obsinfo index 38c2c01..c7cfcb2 100644 --- a/promu.obsinfo +++ b/promu.obsinfo @@ -1,4 +1,4 @@ name: promu -version: 0.15.0 -mtime: 1688456354 -commit: e1bab893555f728998f2bd404c4b7e66931bc760 +version: 0.16.0 +mtime: 1712139406 +commit: d4dc1c56d581ecfabe17bc508978672ef44b536b diff --git a/vendor.tar.gz b/vendor.tar.gz index 183e3c1..bc34bd2 100644 --- a/vendor.tar.gz +++ b/vendor.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d01b7ba3c525d28e851655e78029a2cd3d89079995765a66ee3a3559c93fa9d4 -size 1961604 +oid sha256:6480d06ef3bb28f425ab76211b43eddee6f50b8b77183f5d79ff4a00c80e4327 +size 590964