Add xbps support to doctor command.#5238
Add xbps support to doctor command.#5238nerdyslacker wants to merge 1 commit intowailsapp:masterfrom
Conversation
📝 WalkthroughWalkthroughThe changes introduce support for the XBPS package manager (used by Void Linux) to the Wails build system. This includes updating the package manager factory to recognize "xbps-install", implementing a new Xbps backend with package discovery and installation capabilities, and adding documentation for this new supported package manager. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.11.4)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 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.
🧹 Nitpick comments (2)
v2/internal/system/packagemanager/packagemanager.go (1)
53-54: Nit: trailing whitespace on Line 54.There's trailing whitespace after
return NewXbps(osid)that will likely be flagged bygofmt/ CI formatters. Rungofmt -won the file.Proposed fix
case "xbps-install": - return NewXbps(osid) + return NewXbps(osid)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@v2/internal/system/packagemanager/packagemanager.go` around lines 53 - 54, Remove the trailing whitespace after the line "return NewXbps(osid)" in the switch case for "xbps-install" in packagemanager.go; ensure the line ends without extra spaces and then run gofmt -w on the file to apply formatting changes (this touches the switch case returning NewXbps and the surrounding function in packagemanager.go).v2/internal/system/packagemanager/xbps.go (1)
86-104: Simplify parsing and fix error handling in xbps-query output.The current parsing using
strings.LastIndex(pkgfield, "-")works for the current package names, but is fragile. SincegetPackageVersion(line 120) already usesstrings.HasPrefix(pkgfield, pkg.Name+"-"), the same approach should be used here for consistency and clarity.Additionally,
xbps-query -Rsreturns a non-zero exit when there are no matches. Currently, this error is propagated directly fromPackageAvailable, but other package managers likepacman.goexplicitly check forexec.ExitErrorand return(false, nil)to treat command failure as "package not available". The xbps implementation should follow the same pattern to avoid surfacing expected errors to callers.Suggested change
stdout, _, err := shell.RunCommand(".", "xbps-query", "-Rs", pkg.Name) available := false for _, line := range strings.Split(stdout, "\n") { // Each line is like: "[-] pkgname-version ..." or "[*] pkgname-version ..." fields := strings.Fields(line) if len(fields) < 2 { continue } - // fields[1] is "pkgname-version", strip the version to compare - pkgfield := fields[1] - dashIdx := strings.LastIndex(pkgfield, "-") - if dashIdx > 0 && strings.EqualFold(pkgfield[:dashIdx], pkg.Name) { + // fields[1] is "<pkgname>-<version>" + pkgfield := fields[1] + if strings.HasPrefix(pkgfield, pkg.Name+"-") { available = true x.getPackageVersion(pkg, pkgfield) break } } - return available, err + if available { + return true, nil + } + // Treat command not found as "not available" rather than error + if err != nil { + _, ok := err.(*exec.ExitError) + if ok { + return false, nil + } + } + return false, err🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@v2/internal/system/packagemanager/xbps.go` around lines 86 - 104, In PackageAvailable, simplify the package match by replacing the fragile LastIndex logic with the same prefix check used by getPackageVersion (i.e., use strings.HasPrefix(pkgfield, pkg.Name+"-") to detect the package and then call x.getPackageVersion(pkg, pkgfield)); also improve error handling from shell.RunCommand by treating an exec.ExitError (command returned non-zero because no matches) as a non-fatal "not available" case and return (false, nil) instead of propagating the error, while still returning other unexpected errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@v2/internal/system/packagemanager/packagemanager.go`:
- Around line 53-54: Remove the trailing whitespace after the line "return
NewXbps(osid)" in the switch case for "xbps-install" in packagemanager.go;
ensure the line ends without extra spaces and then run gofmt -w on the file to
apply formatting changes (this touches the switch case returning NewXbps and the
surrounding function in packagemanager.go).
In `@v2/internal/system/packagemanager/xbps.go`:
- Around line 86-104: In PackageAvailable, simplify the package match by
replacing the fragile LastIndex logic with the same prefix check used by
getPackageVersion (i.e., use strings.HasPrefix(pkgfield, pkg.Name+"-") to detect
the package and then call x.getPackageVersion(pkg, pkgfield)); also improve
error handling from shell.RunCommand by treating an exec.ExitError (command
returned non-zero because no matches) as a non-fatal "not available" case and
return (false, nil) instead of propagating the error, while still returning
other unexpected errors.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f3360174-2ca0-428d-93df-7726f84b444d
�� Files selected for processing (3)
v2/internal/system/packagemanager/packagemanager.gov2/internal/system/packagemanager/xbps.gowebsite/docs/guides/linux-distro-support.mdx
Triaged ✓ — labeled Ready For Testing.
|
I added support for xbps package manager since I created a request to add wails to Void Linux official repositories. Currently I maintain and use wails in my own unofficial repository for void.
Now
wails doctorworks on Void Linux:Summary by CodeRabbit