Skip to content

Fix Go version discovery on Ubuntu versions#785

Merged
deneb-alpha merged 1 commit into
uyuni-project:mainfrom
deneb-alpha:fix_ubuntu_go
May 18, 2026
Merged

Fix Go version discovery on Ubuntu versions#785
deneb-alpha merged 1 commit into
uyuni-project:mainfrom
deneb-alpha:fix_ubuntu_go

Conversation

@deneb-alpha

@deneb-alpha deneb-alpha commented May 7, 2026

Copy link
Copy Markdown
Contributor

What does this PR change?

follow-up of #775

The build for Ubuntu 22.04 was failing with the error undefined: fmt.Appendf. This occurred because the codebase requires Go 1.19+ (where fmt.Appendf was introduced), but the Ubuntu 22.04 build environment was defaulting to Go 1.18.

The failure was caused by two main factors:

  • Metapackage Resolution: On Ubuntu 22.04, the metapackage golang points to version 1.18. Even with a version constraint like BuildRequires: golang >= 1.22, the package manager falls back to the only available package named golang (1.18) if a higher version isn't found under that exact name.
  • Naming Conventions: Newer Go versions on Ubuntu 22.04 are provided as versioned packages (e.g., golang-1.22-go). These are seen as distinct packages rather than updates to the base golang package.

Changes done:

  • Uses the versioned Go package dependency on Ubuntu 22.04.
  • Add build-time discovery of the newest available Go binary across versioned and system paths.
  • Fails the build if no suitable Go compiler is found.

Codespace

Check if you already have a running container clicking on Running CodeSpace

Create CodeSpace About billing for Github Codespaces CodeSpace Billing Summary CodeSpace Limit

Test coverage

Links

Issue(s): #775

  • DONE

Changelogs

Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository

If you don't need a changelog check, please mark this checkbox:

  • No changelog needed

If you uncheck the checkbox after the PR is created, you will need to re-run changelog_test (see below)

Before you merge

Check How to branch and merge properly!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the RPM spec packaging to reliably pick a sufficiently new Go toolchain on Ubuntu (notably 22.04), avoiding builds accidentally using the golang metapackage version that is too old for the codebase.

Changes:

  • On Ubuntu 22.04, require the versioned Go package (golang-%{go_version}-go) instead of relying on golang >= ....
  • In the build step on Ubuntu, discover the Go binary by selecting the highest /usr/lib/go-*/bin version instead of assuming a single fixed path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uyuni-tools.spec Outdated
Comment thread uyuni-tools.spec Outdated
@deneb-alpha
deneb-alpha force-pushed the fix_ubuntu_go branch 2 times, most recently from de24d48 to 54d0711 Compare May 7, 2026 14:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread uyuni-tools.spec Outdated
@deneb-alpha
deneb-alpha requested review from Copilot and meaksh May 7, 2026 14:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread uyuni-tools.spec
Comment thread uyuni-tools.spec Outdated
Comment thread uyuni-tools.spec Outdated
@deneb-alpha
deneb-alpha requested a review from Copilot May 7, 2026 14:38
@deneb-alpha
deneb-alpha marked this pull request as draft May 7, 2026 14:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread uyuni-tools.spec Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread uyuni-tools.spec Outdated
Comment thread uyuni-tools.spec Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread uyuni-tools.spec Outdated
Comment thread uyuni-tools.spec Outdated
Comment thread uyuni-tools.spec Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@deneb-alpha
deneb-alpha marked this pull request as ready for review May 18, 2026 12:57
@deneb-alpha
deneb-alpha marked this pull request as draft May 18, 2026 13:02

@cbosdo cbosdo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole logic added here seems like an overkill to me… do we really need all of this?

@sonarqubecloud

Copy link
Copy Markdown

@deneb-alpha
deneb-alpha requested a review from Copilot May 18, 2026 14:07
@deneb-alpha
deneb-alpha marked this pull request as ready for review May 18, 2026 14:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread uyuni-tools.spec
if test -d /usr/lib/go-%{go_version}/bin/; then
go_path=/usr/lib/go-%{go_version}/bin/
# Pinpoint the highest binary
go_path=$(find /usr/lib/go-*/bin/go 2>/dev/null | sort | tail -n 1)
Comment thread uyuni-tools.spec
Comment on lines +86 to +88
# On Ubuntu 22.04, the metapackage golang is too old (1.18) and
# we must use the versioned package name specifically for this OS version.
%if 0%{?ubuntu} == 2204
Comment thread uyuni-tools.spec
Comment on lines +346 to +348
[ -z "$max_patch" ] && max_patch=0
[ -z "$max_minor" ] && max_minor=0
if [ "$max_major" -lt "$req_major" ] || { [ "$max_major" -eq "$req_major" ] && [ "$max_minor" -lt "$req_minor" ]; }; then
@deneb-alpha

Copy link
Copy Markdown
Contributor Author

@cbosdo / @meaksh I tried to simplify the logic for the validation of the path. there are still some open points reported by Copilot but not sure if it's really worth to cover all of them

@deneb-alpha
deneb-alpha requested review from cbosdo and meaksh May 18, 2026 14:14
@deneb-alpha
deneb-alpha merged commit 06d9e88 into uyuni-project:main May 18, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants