feat(system): detect Gentoo Linux and resolve emerge package manager - #1857
feat(system): detect Gentoo Linux and resolve emerge package manager#1857ardelperal wants to merge 3 commits into
Conversation
📝 WalkthroughWalkthroughGentoo Linux support is added to distro detection and platform resolution. Single-quoted ChangesGentoo platform support
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant OSRelease as /etc/os-release
participant Detect as detectLinuxDistro
participant Profile as resolvePlatformProfile
OSRelease->>Detect: Parse ID and ID_LIKE values
Detect->>Profile: Return LinuxDistroGentoo
Profile-->>Profile: Select emerge and supported=true
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/system/detect.go`:
- Around line 189-190: Update the value parsing in detect.go to strip outer
quotes only when the first and last delimiters are the same matching quote
character; otherwise preserve them. Add a regression test covering mismatched
delimiters and quote characters that belong to the value, using the existing
parser/test symbols.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 9dd0ad68-8efd-410c-be6c-c66a0226eed3
📒 Files selected for processing (4)
internal/system/detect.gointernal/system/detect_test.gointernal/system/guard.gointernal/system/guard_test.go
|
Fixed in commit
Local checks: The PR is ready for review from the contributor side. |
|
Hey @Alan-TheGentleman, this is ready for review when you have a moment. Status:
No new commits since the last CodeRabbit review. Happy to iterate if anything else surfaces. |
dnlrsls
left a comment
There was a problem hiding this comment.
Gentoo cannot be marked Supported=true yet. The platform guard accepts emerge, but the Linux install resolver still supports only apt, pacman, and dnf for dependencies, OpenCode, and GGA, so installation fails after detection succeeds. Please add a complete supported emerge resolution with an install/dry-run regression, or keep Gentoo unsupported until that path exists. Also restore the missing required Automated Checks section in the PR template.
Alan-TheGentleman
left a comment
There was a problem hiding this comment.
The detection work here is genuinely good — symmetric quote-stripping with edge-case tests, ID_LIKE handling for Funtoo/Calculate derivatives. That part is ready.
But there's a gap that makes this merge-unsafe as-is: it marks Gentoo Supported = true while nothing in internal/installcmd/resolver.go handles pm="emerge". Every component resolver switches on PackageManager with a hard-error default, so a Gentoo user now passes EnsureSupportedPlatform and then fails mid-install on the first component (unsupported platform for opencode: ... pm="emerge"). That's a worse experience than the clean rejection they get today.
The Linux flows are mostly PM-agnostic (npm/git based), so the fix is small:
- Add
"emerge"to the Linux case lists ininternal/installcmd/resolver.go(e.g.case "apt", "pacman", "dnf":→case "apt", "pacman", "dnf", "emerge":) — check everyswitch profile.PackageManagersite - Add an emerge entry to
uvInstallHint(or fall through to the generic hint) - Extend
resolver_test.goandcomponents/gga/install_test.gomatrices with a Gentoo/emerge profile, mirroring how #1946 covers zypper - Keep the detection code exactly as it is — it's solid
Once emerge reaches the resolvers, this is a merge. Thanks for the thorough test matrix on detection.
Mirrors the openSUSE/zypper pattern from PR Gentleman-Programming#1946. Without this, the detection work in 0853d11 marks Gentoo as Supported=true but every component resolver in internal/installcmd/resolver.go falls through to the 'unsupported package manager' default error, leaving the Gentoo user with a worse experience than the clean rejection they got before detection was added. Changes: - internal/installcmd/resolver.go: add 'emerge' case to uvInstallHint (sudo emerge --ask=n --quiet uv) and ResolveDependencyInstall (sudo emerge --ask=n --quiet <dep>); add 'emerge' to the combined apt/pacman/dnf case in resolveOpenCodeInstall and resolveGGAInstall (Linux flows are npm/git-based, so the PM grouping is sufficient). resolveEngramInstall is intentionally untouched (engram uses direct binary download on non-brew, same as zypper). - internal/system/install_deps.go: add 'emerge' case to installHintGit, installHintCurl, installHintNode, installHintGo, installCommandsGit, installCommandsCurl, installCommandsNode, and installCommandsGo. Portage package names match the simple unqualified form used by zypper (git, curl, nodejs, dev-lang/go) and emerge flags use --ask=n --quiet for non-interactive behavior matching zypper's --non-interactive. - internal/installcmd/resolver_test.go: add gentoo test cases for ResolveDependencyInstall, resolveOpenCodeInstall (opencode), and resolveGGAInstall (gga), mirroring the existing fedora/arch/opensuse matrix entries. - internal/components/gga/install_test.go: add gentoo test case for InstallCommand, mirroring the fedora entry with the current 6-step install flow (mkdir + git init + git fetch + git checkout + bash). Addresses review feedback from @Alan-TheGentleman on Gentleman-Programming#1857 (Gentoo cannot be marked Supported=true until install paths exist for emerge) and @dnlrsls (restore the required Automated Checks section in the PR body).
b42db0a to
4de1c00
Compare
|
Hey @Alan-TheGentleman, addressing your The gap is fixed. Force-pushed
Detection code is unchanged — your note ("Keep the detection code exactly as it is — it's solid") was respected. Emerge-specific package notes:
Scope grew from 4 → 8 files — the PR body now reflects this honestly (no more "scope is strictly the four files"). Also restored the missing Local verification (Windows, Go 1.26.1) on
Ready for re-review. |
Mirrors the openSUSE/zypper pattern from PR Gentleman-Programming#1946. Without this, the detection work in 0853d11 marks Gentoo as Supported=true but every component resolver in internal/installcmd/resolver.go falls through to the 'unsupported package manager' default error, leaving the Gentoo user with a worse experience than the clean rejection they got before detection was added. Changes: - internal/installcmd/resolver.go: add 'emerge' case to uvInstallHint (sudo emerge --ask=n --quiet uv) and ResolveDependencyInstall (sudo emerge --ask=n --quiet <dep>); add 'emerge' to the combined apt/pacman/dnf case in resolveOpenCodeInstall and resolveGGAInstall (Linux flows are npm/git-based, so the PM grouping is sufficient). resolveEngramInstall is intentionally untouched (engram uses direct binary download on non-brew, same as zypper). - internal/system/install_deps.go: add 'emerge' case to installHintGit, installHintCurl, installHintNode, installHintGo, installCommandsGit, installCommandsCurl, installCommandsNode, and installCommandsGo. Portage package names match the simple unqualified form used by zypper (git, curl, nodejs, dev-lang/go) and emerge flags use --ask=n --quiet for non-interactive behavior matching zypper's --non-interactive. - internal/installcmd/resolver_test.go: add gentoo test cases for ResolveDependencyInstall, resolveOpenCodeInstall (opencode), and resolveGGAInstall (gga), mirroring the existing fedora/arch/opensuse matrix entries. - internal/components/gga/install_test.go: add gentoo test case for InstallCommand, mirroring the fedora entry with the current 6-step install flow (mkdir + git init + git fetch + git checkout + bash). Addresses review feedback from @Alan-TheGentleman on Gentleman-Programming#1857 (Gentoo cannot be marked Supported=true until install paths exist for emerge) and @dnlrsls (restore the required Automated Checks section in the PR body).
4de1c00 to
9920b9b
Compare
|
Hey @Alan-TheGentleman, ready for re-review. Commit What changed since the last review:
Branch is rebased onto current main, CI is 14/14 green. Happy to iterate if anything else surfaces. |
dnlrsls
left a comment
There was a problem hiding this comment.
Approved. At 9920b9b, emerge now resolves through dependency installation, the uv, OpenCode, and GGA resolver paths, and bootstrap dependency commands; Gentoo regression coverage exercises the supported flow. The approved issue, single type label, 149-line scope, clean merge state, and required CI checks are satisfied.
🔗 Linked Issue
Closes #1669
🏷️ PR Type
type:bugtype:featuretype:docstype:refactortype:choretype:breaking-change📝 Summary
Adds Gentoo Linux to the supported distribution matrix in
internal/systemso Gentoo and Gentoo-family systems resolve to a supported profile withemergeas the package manager, and extends the install resolvers ininternal/installcmdandinternal/system/install_depssoemergeis wired into everyswitch profile.PackageManagersite that already supportsapt,pacman, anddnf. Without the resolver changes, Gentoo users would hitunsupported package manager "emerge"mid-install (worse than the clean rejection they got before detection was added).The same change set also fixes an
os-release(5)spec-compliance gap: the previous parser only stripped double quotes, soID='gentoo'leaked through as'gentoo'and never matched any distro constant. The new trim removes matching outer single or double quote characters, which is also correct for any distro using single-quoted values.Scope grew beyond the original four files after Alan-TheGentleman's review on 2026-07-30 (
Gentoo cannot be marked Supported=true until install paths exist for emerge). The follow-up commit4de1c002mirrors the openSUSE/zypper pattern from PR #1946 — same shape, same flags philosophy (--ask=n --quietfor non-interactive emerge, analogous to zypper's--non-interactive).📂 Changes
internal/system/detect.gointernal/system/detect_test.gointernal/system/guard.gointernal/system/guard_test.gointernal/installcmd/resolver.gointernal/installcmd/resolver_test.gointernal/system/install_deps.gointernal/components/gga/install_test.goSingle PR, no chaining, no
size:exception(117 changed lines, well below the 400-line review budget).🧪 Test Plan
All commands were run locally on Windows 11 with the change branch checked out, on the rebased branch tip (
4de1c002).go build ./...go vet ./...go test -count=1 ./internal/system/...go test -count=1 ./internal/installcmd/...go test -count=1 ./internal/components/gga/...go test -count=1 -run TestDetectLinuxDistroMatrix -v ./internal/system/...go test -count=1 -run TestResolveDependencyInstall ./internal/installcmd/...gentoo_resolves_emerge_command)go test -count=1 -run TestInstallCommandByProfile ./internal/components/gga/...gentoo_uses_git_clone_and_install.sh)go run ./internal/gofmtcheckPre-existing failure baseline: this branch was verified by checking out
origin/mainin a separate worktree and runninggo test -count=1 ./internal/installcmd/... ./internal/system/... ./internal/components/gga/.... All packages pass onorigin/mainfor these scopes; no pre-existing failures introduced by this change. Other pre-existing repo failures ininternal/components/communitytool/pi_codegraphandinternal/tui/syncclusters are outside the scope of this change.New subtests added (alongside the existing detection coverage from
0853d119):TestResolveDependencyInstall/gentoo_resolves_emerge_command—sudo emerge --ask=n --quiet <dep>argv sequenceTestResolveOpenCodeInstall/opencode_on_gentoo_system_npm_uses_sudo— npm-based, falls into the combined Linux caseTestResolveGGAInstall/gga_on_gentoo_uses_git_clone_and_install.sh— 6-step install flow (mkdir + git init + git fetch + git checkout + bash)TestInstallCommandByProfile/gentoo_uses_git_clone_and_install.sh— same flow at the gga-package level🤖 Automated Checks
The following checks run automatically on this PR:
additions + deletions) — current: 122 lines, well under budgetCloses #1669(uses Closes keyword)status:approvedstatus:approved(verified via previous successful runs)type:*Labeltype:*label must be applied —type:featureis checked below in Pending maintainer actionsgo test ./...must pass — local scope (system + installcmd + gga) verified cleango run ./internal/gofmtcheckmust pass — verified locallycd e2e && ./docker-test.shmust pass — outside local scope; CI is authoritativeb42db0a5fix✅ Contributor Checklist
status:approved.feat/system-gentoo-detectionmatches the repo regex.Closes #1669is used (notRefs).Co-Authored-Bytrailers.go build,go vet, and targetedgo test(system + installcmd + gga) pass.🤖 Automated Checkssection is present (per dnlrsls review feedback).Notes for Reviewersis honest about scope growth from 4 → 8 files after Alan's review.type:featurelabel applied to this PR — pending AlanPending maintainer actions
The following are maintainer-applied per
.github/PULL_REQUEST_TEMPLATE.mdandCONTRIBUTING.mdand are not within contributor scope:type:featurelabel applied to this PR — pending Alanaction_requiredruns) — pending Alan💬 Notes for Reviewers
4de1c002mirrors the openSUSE/zypper pattern from PR feat(system): add openSUSE/SUSE family support (zypper) #1946 — same shape, same flags philosophy (--ask=n --quietfor non-interactive emerge, analogous to zypper's--non-interactive).0853d119andb42db0a5is unchanged. Alan specifically asked: "Keep the detection code exactly as it is — it's solid." The follow-up commit touches only the install resolvers, not detection.b42db0a5): the previousstrings.Trim(..., "\"")matched only double quotes;os-release(5)allows either outer quote style. Single-quoted values such asID='gentoo'never matched any distro constant. The newstrings.Trim(..., "\"'")is a strict superset; existing double-quoted and bare values parse identically.isGentooLikeis appended afterisFedoraLiketo preserve existing family precedence. Any future reordering must be re-verified against the matrix.engramresolver is intentionally untouched. Engram usesDownloadLatestBinary()on every non-brew platform (Linux and Windows); the resolver returns an error for non-brew which is the documented behavior. Gentoo falls into this same path — no new code needed.--ask=n --quietand not--non-interactive? Portage does not have a--non-interactiveflag. The accepted non-interactive pattern is--ask=n(suppresses prompts) +--quiet(reduces output to log-level). Same end-state as zypper's--non-interactive— the resolver runs to completion without user input.dev-lang/goand not justgofor Go? Portage accepts unqualifiedgo, butdev-lang/gois the canonical qualified form used in Gentoo wiki and overlay documentation. Using the qualified form makes the dependency explicit and avoids ambiguity if a user ever installs a differentgoin a custom overlay.net-libs/nodejspackage is current LTS; NodeSource is only needed for distros with stale upstream Node packages (Debian/Ubuntu LTS, Fedora). Emerge gets current Node directly.install_deps.goIS now in scope (the previous PR body said it was intentionally out — that was the pre-Alan-review version). The change is small (8 case statements, mirroring PR feat(system): add openSUSE/SUSE family support (zypper) #1946's zypper additions) and necessary for theemergeinstall path to actually work end-to-end.Summary by CodeRabbit
emergepackage manager.emergeinto all Linux install resolvers so Gentoo users get a working install path, not a worse-than-before failure mid-flow.