diff --git a/go-1.24.yaml b/go-1.24.yaml index c1029ea6e04..96c23f63956 100644 --- a/go-1.24.yaml +++ b/go-1.24.yaml @@ -1,7 +1,7 @@ package: name: go-1.24 version: "1.24.0" - epoch: 0 + epoch: 1 description: "the Go programming language" copyright: - license: BSD-3-Clause @@ -41,6 +41,7 @@ pipeline: patches: | cmd-go-always-emit-ldflags-version-information.patch change-default-telemetry-from-local-to-off.patch + go-fix-incompatible-dirty-build-metadata-to-be-SemVe.patch - runs: | cd src @@ -67,21 +68,40 @@ pipeline: rm -rf "${{targets.destdir}}"/usr/lib/go/pkg/tool/*/go_bootstrap rm -rf "${{targets.destdir}}"/usr/lib/go/src/cmd/dist/dist - # Remove tests from /usr/lib/go/src, not needed at runtime - find "${{targets.destdir}}"/usr/lib/go/src \( -type f -a -name "*_test.go" \) \ - -exec rm -rf \{\} \+ - find "${{targets.destdir}}"/usr/lib/go/src \( -type d -a -name "testdata" \) \ - -exec rm -rf \{\} \+ - find "${{targets.destdir}}"/usr/lib/go/src \( -type f -a -name "*.rc" \) \ - -exec rm -rf \{\} \+ - find "${{targets.destdir}}"/usr/lib/go/src \( -type f -a -name "*.bat" \) \ - -exec rm -rf \{\} \+ - find "${{targets.destdir}}"/usr/lib/go/src \( -type f -a -name "*.pem" \) \ - -exec rm -rf \{\} \+ - - uses: strip subpackages: + - name: "${{package.name}}-src" + description: "go source code and tests" + dependencies: + runtime: + - ${{package.name}}=${{package.full-version}} + pipeline: + - runs: | + cd ${{targets.destdir}}/ + mkdir -p ${{targets.subpkgdir}} + find . -name '*_test.go' -exec cp -v --parents -r '{}' ${{targets.subpkgdir}} \; + find . -name 'testdata' -exec cp -v --parents -r '{}' ${{targets.subpkgdir}} \; + find . -name '*.rc' -exec cp -v --parents -r '{}' ${{targets.subpkgdir}} \; + find . -name '*.bat' -exec cp -v --parents -r '{}' ${{targets.subpkgdir}} \; + find . -name '*.pem' -exec cp -v --parents -r '{}' ${{targets.subpkgdir}} \; + + find . -name '*_test.go' -exec rm -f '{}' \; + find . -name 'testdata' -exec rm -f '{}' \; + find . -name '*.rc' -exec rm -f '{}' \; + find . -name '*.bat' -exec rm -f '{}' \; + find . -name '*.pem' -exec rm -f '{}' \; + test: + environment: + contents: + packages: + - git + pipeline: + - name: Test Semver fix + runs: | + go telemetry local + go test -a -v cmd/go -run=Script/build_version_stamping_git + - name: "${{package.name}}-doc" description: "go documentation" pipeline: diff --git a/go-1.24/go-fix-incompatible-dirty-build-metadata-to-be-SemVe.patch b/go-1.24/go-fix-incompatible-dirty-build-metadata-to-be-SemVe.patch new file mode 100644 index 00000000000..6816e25337f --- /dev/null +++ b/go-1.24/go-fix-incompatible-dirty-build-metadata-to-be-SemVe.patch @@ -0,0 +1,70 @@ +From ee66f3c8fd27506c789810fff86f09880d0354ad Mon Sep 17 00:00:00 2001 +From: Dimitri John Ledkov +Date: Tue, 19 Jul 2022 11:07:00 -0400 +Subject: [PATCH] go: fix +incompatible+dirty build metadata to be SemVer + compatible + +Change "+incompatible+dirty" version to be "+incompatible.dirty" such +that it is SemVer spec compatible. + +Struggling to add test case for a locally generated module that will +create +incompatible version. + +See: +- https://github.com/golang/go/issues/71971 +- https://github.com/golang/go/issues/71969 +- https://github.com/golang/go/issues/71970 +- https://github.com/anchore/grype/issues/2482 +- https://semver.org/#spec-item-10 + +Change-Id: I714ffb3f1ad88c793656c3652367db34739a2144 +--- + src/cmd/go/internal/load/pkg.go | 7 ++++++- + .../testdata/script/build_version_stamping_git.txt | 13 +++++++++++++ + 2 files changed, 19 insertions(+), 1 deletion(-) + +diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go +index 0c4639ce82..13add8ad5b 100644 +--- a/src/cmd/go/internal/load/pkg.go ++++ b/src/cmd/go/internal/load/pkg.go +@@ -2563,7 +2563,12 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) { + vers := revInfo.Version + if vers != "" { + if st.Uncommitted { +- vers += "+dirty" ++ // SemVer build metadata is dot-separated https://semver.org/#spec-item-10 ++ if strings.HasSuffix(vers, "+incompatible") { ++ vers += ".dirty" ++ } else { ++ vers += "+dirty" ++ } + } + info.Main.Version = vers + } +diff --git a/src/cmd/go/testdata/script/build_version_stamping_git.txt b/src/cmd/go/testdata/script/build_version_stamping_git.txt +index db804b3847..e7ca8d25df 100644 +--- a/src/cmd/go/testdata/script/build_version_stamping_git.txt ++++ b/src/cmd/go/testdata/script/build_version_stamping_git.txt +@@ -108,6 +108,19 @@ go version -m example$GOEXE + stdout '\s+mod\s+example\s+v1.0.3-0.20220719150703-2e239bf29c13\s+' + rm example$GOEXE + ++# Create +incompatible module ++exec git checkout v1.0.4 ++exec git rm go.mod ++exec git commit -m 'commit 6' ++exec git tag v2.0.0 ++exec git checkout HEAD^ go.mod ++# And make the tree +dirty ++mv README4 README5 ++go build ++go version -m example$GOEXE ++stdout '\s+mod\s+example\s+v2.0.0+incompatible.dirty\s+' ++rm example$GOEXE ++ + -- $WORK/repo/go.mod -- + module example + +-- +2.43.0 + diff --git a/pipelines/strip.yaml b/pipelines/strip.yaml new file mode 100644 index 00000000000..09f137b78dc --- /dev/null +++ b/pipelines/strip.yaml @@ -0,0 +1,35 @@ +name: Strip binaries + +needs: + packages: + - binutils + - scanelf + +inputs: + opts: + description: | + The option flags to pass to the strip command. + default: -g + +pipeline: + - working-directory: ${{targets.contextdir}} + runs: | + check() { "$@" || { echo "[strip] FATAL: '$*' failed $?"; exit 1; }; } + + scanout=$(mktemp) + check scanelf --recursive --nobanner --etype "ET_DYN,ET_EXEC" --format "%I %a" -o "$scanout" . + + count=0 + while read osabi arch filename; do + # Skip foreign binaries + case "${{build.arch}}" in + x86_64) [ "$arch" = "EM_X86_64" ] || continue;; + aarch64) [ "$arch" = "EM_AARCH64" ] || continue;; + esac + [ "$osabi" != "STANDALONE" ] || continue + check strip ${{inputs.opts}} "$filename" + count=$((count+1)) + done < "$scanout" + + echo "[strip] stripped $count ${{build.arch}} binaries in $PWD" + rm -f "$scanout"