Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.gentoo.dev > #70491
| From | Arthur Zamarin <arthurzam@gentoo.org> |
|---|---|
| Newsgroups | linux.gentoo.dev |
| Subject | [gentoo-dev] [PATCH] install-qa-check.d/60go-module-eclass: Check for missing min Go version |
| Date | 2026-05-02 09:30 +0200 |
| Message-ID | <MQcXv-1YAX-9@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
Go over all go.mod files in the source and check if the minimum Go
version specified matches the minimum version specified in
BDEPEND/DEPEND. I employ a very basic heuristic to extract the minimum
Go version from the ebuild, so this might have somne edge cases where it
doesn't work, but it should be good enough for most cases and is better
than nothing.
For EAPI>=9, we make it a hard error if the ebuild doesn't specify the
correct minimum Go version, to enforce that the ebuild gets updated. All
EAPI=9 ebuilds where checked.
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
---
.../install-qa-check.d/60go-module-eclass | 40 +++++++++++++++++++
1 file changed, 40 insertions(+)
create mode 100644 metadata/install-qa-check.d/60go-module-eclass
diff --git a/metadata/install-qa-check.d/60go-module-eclass b/metadata/install-qa-check.d/60go-module-eclass
new file mode 100644
index 00000000000..eba914b3264
--- /dev/null
+++ b/metadata/install-qa-check.d/60go-module-eclass
@@ -0,0 +1,40 @@
+# Copyright 2026 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# QA check: ensure go-module based ebuilds define correct GO_MIN_VER
+# Maintainer: Arthur Zamarin <arthurzam@gentoo.org>
+
+go_ver_check() {
+ has go-module ${INHERITED} || return
+
+ # Maximum value for "go" version across go.mod files
+ local go_mod_version=$(
+ find "${WORKDIR}" -name go.mod -exec sed -n -e 's/^go\s\+\([0-9.]*\)\s*$/\1/p' {} \+ |
+ sort -V |
+ tail -n 1
+ )
+
+ # Extract go version from BDEPEND or DEPEND (>=dev-lang/go-X.Y:= format)
+ local bdepend_go_ver=$(
+ grep -oE '>=?dev-lang/go-[0-9.]*' <<< "${BDEPEND} ${DEPEND}" |
+ sed -n -e 's/^>=\?dev-lang\/go-\([0-9.]*\)$/\1/p' |
+ sort -V |
+ tail -n 1
+ )
+
+ # Check if BDEPEND/DEPEND version matches what go.mod requires
+ if [[ -n ${go_mod_version} ]] && ( [[ -z ${bdepend_go_ver} ]] || ver_test "${bdepend_go_ver}" -lt "${go_mod_version}" ); then
+ eqawarn
+ eqawarn "QA Notice: found go.mod file which specifies go ${go_mod_version}"
+ eqawarn "Update BDEPEND to have \">=dev-lang/go-${go_mod_version}\""
+ eqawarn
+
+ # For EAPI>=9, enforce the ebuild being updated
+ [[ ${EAPI} != 8 ]] && die "Update BDEPEND with >=dev-lang/go-${go_mod_version}:="
+ fi
+}
+
+go_ver_check
+: # guarantee successful exit
+
+# vim:ft=sh
--
2.54.0
Back to linux.gentoo.dev | Previous | Next — Next in thread | Find similar
[gentoo-dev] [PATCH] install-qa-check.d/60go-module-eclass: Check for missing min Go version Arthur Zamarin <arthurzam@gentoo.org> - 2026-05-02 09:30 +0200 Re: [gentoo-dev] [PATCH] install-qa-check.d/60go-module-eclass: Check for missing min Go version Ionen Wolkens <ionen@gentoo.org> - 2026-05-02 10:20 +0200
csiph-web