File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,8 +83,14 @@ BuildRequires: golang(API) >= 1.25
8383
8484%if 0%{?ubuntu }
8585%define go_version 1.22
86+ # On Ubuntu 22.04, the metapackage golang is too old (1.18) and
87+ # we must use the versioned package name specifically for this OS version.
88+ %if "%{?ubuntu }" == 2204
89+ BuildRequires: golang-%{go_version }-go
90+ %else
8691BuildRequires: golang >= %{go_version }
8792%endif
93+ %endif
8894# ubuntu
8995
9096%if 0%{?debian }
@@ -324,15 +330,34 @@ go_tags=""
324330
325331go_path= ""
326332%if 0%{?ubuntu }
327- if test -d /usr/lib/go-%{go_version }/bin/; then
328- go_path= /usr/lib/go-%{go_version }/bin/
329- fi
333+ max_major= 0
334+ max_minor= 0
335+
336+ for dir in /usr/lib/go-*/bin; do
337+ if [ -x "$dir/go" ]; then
338+ # Extract version string (e.g., from /usr/lib/go-1.22/bin to 1.22)
339+ v_str= "${dir%/bin}"
340+ v_str= "${v_str#/usr/lib/go-}"
341+
342+ # Split 1.22 into major (1) and minor (22)
343+ major= "${v_str%.*}"
344+ minor= "${v_str#*.}"
345+
346+ # If major is higher, or if major is equal and minor is higher, update go_path
347+ if [ "$major" -gt "$max_major" ]; then
348+ max_major= $major
349+ max_minor= $minor
350+ go_path= "$dir/"
351+ elif [ "$major" -eq "$max_major" ] && [ "$minor" -gt "$max_minor" ]; then
352+ max_minor= $minor
353+ go_path= "$dir/"
354+ fi
355+ fi
356+ done
330357%else
331358 %if "%{?_go_bin }" != ""
332359 go_path= '%{_go_bin }/'
333360 %endif
334- # "_go_bin" != ""
335-
336361%endif
337362# ubuntu
338363
You can’t perform that action at this time.
0 commit comments