Skip to content

feat(linux): configure package dependencies - #213

Merged
houko merged 1 commit into
mainfrom
fix/linux-package-dependencies
Nov 16, 2026
Merged

houko merged 1 commit into
mainfrom
fix/linux-package-dependencies

Conversation

@houko

@houko houko commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #139

Linux package metadata now accepts linux.depends and linux.recommends, each with separate deb and arch lists, passed through verbatim so Debian alternatives and version constraints (a | b, foo (>= 1.2)) and Arch's name: reason optional dependencies work. The .deb appends the entries, in order, after libgtk-4-1 in Depends: and after libwebkitgtk-6.0-4 in Recommends:; the Arch .PKGINFO writes one depend = line per entry after gtk4 and one optdepend = line per entry after webkitgtk-6.0: web views. Without the keys both packages are what they were before.

Loading nsgo.yaml rejects a blank (empty or whitespace-only) entry and an entry holding a line break, with a message naming the key and the entry, such as nsgo.yaml: linux.depends.deb entry 2 is empty, so an entry cannot leave an empty item in a Debian list or inject other control fields. A YAML null entry ([~]) is dropped by the YAML decoder and never reaches the package.

docs/public/en/building.md and docs/public/zh/building.md document the keys next to linux.maintainer, and docs/architecture/tool.md now says the packages recommend WebKitGTK 6 rather than "suggest" it.

Verification

  • go build ./...; GOOS=windows and GOOS=linux vets and GOOS=android GOARCH=arm64 / GOOS=js GOARCH=wasm builds of ./cmd/nsgo
  • go tool nsgo check -target all
  • go tool nsgo test ./cmd/nsgo and go tool nsgo test -run 'Layer|Skills|Doc' .
  • TestLinuxPackages covers both formats with and without extra entries, including their order relative to NSGo's own; TestLinuxPackageDependencies loads the keys through nsgo.yaml and checks every rejection message
  • Real packages: examples/hello built with nsgo build -target linux_x64 and extra entries. dpkg-deb -f shows Depends: libgtk-4-1, gstreamer1.0-plugins-good, libsoup-3.0-0 | libsoup3 and Recommends: libwebkitgtk-6.0-4, gstreamer1.0-libav, ffmpeg (>= 7); apt-get install -s ./hello….deb on Ubuntu 24.04 resolves the package and pulls in gstreamer1.0-libav and ffmpeg as recommended; pacman -Qip in an Arch Linux container lists Depends On: gtk4 gst-plugins-good and Optional Deps: webkitgtk-6.0: web views, gst-libav: H.264 and AAC video

Screenshots

None

@github-actions github-actions Bot added enhancement New feature or request documentation Improvements or additions to documentation cli size/M conflict Conflicts with the base branch; resolve it first labels Nov 15, 2026
@houko
houko force-pushed the fix/linux-package-dependencies branch from ad249c6 to 57f9e93 Compare November 16, 2026 10:16
@github-actions github-actions Bot removed the conflict Conflicts with the base branch; resolve it first label Nov 16, 2026
@houko
houko force-pushed the fix/linux-package-dependencies branch from 57f9e93 to a6382c6 Compare November 16, 2026 10:22
@houko

houko commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

Reviewed. Rebased onto current main (67249d2) as a6382c6; the diff is unchanged and touches neither CHANGELOG.md nor anything outside the Linux package metadata, its config loading, tests and docs.

  • Code: the Debian control file keeps one Sprintf with libgtk-4-1 / libwebkitgtk-6.0-4 first and the app's entries joined after them by , ; the Arch .PKGINFO writes one depend = / optdepend = line per entry after NSGo's own. Validation runs in load() in a fixed key order and rejects blank (after trimming) entries and entries containing \r or \n, with nsgo.yaml: linux.<key> entry N ... messages.
  • Linux build host (linux/amd64): go build ./..., gofmt, GOOS=linux and GOOS=windows vets of ./cmd/nsgo, GOOS=android GOARCH=arm64 and GOOS=js GOARCH=wasm builds of ./cmd/nsgo, go tool nsgo test ./cmd/nsgo (174 passed, 0 failed, 7 skipped) and go tool nsgo test -run 'Layer|Skills|Doc' . (29 passed).
  • Tests fail without the change: with linuxDependency returning only the base, the Arch loops emptied and validateLinuxDeps returning nil, TestLinuxPackages fails on both formats' dependency lines and TestLinuxPackageDependencies fails on all five rejection cases.
  • Byte-for-byte check: examples/hello built with nsgo build -target linux_x64 from main and from this branch without the new keys gives identical Debian control files and identical .PKGINFO files apart from builddate.
  • With keys: the .deb has Depends: libgtk-4-1, gstreamer1.0-plugins-good, libsoup-3.0-0 | libsoup3 and Recommends: libwebkitgtk-6.0-4, gstreamer1.0-libav, ffmpeg (>= 6). A YAML entry containing a line break stops nsgo build with nsgo.yaml: linux.depends.deb entry 1 contains a line break.
  • Ubuntu 24.04 (GNOME VM): apt-get install -s on that .deb succeeds and pulls in ffmpeg (6.1.1, satisfying the version constraint) and gstreamer1.0-libav as recommended packages.
  • Arch Linux (archlinux container): pacman -Qip lists Depends On: gtk4 gst-plugins-good and Optional Deps: webkitgtk-6.0: web views, gst-libav: H.264 and AAC video, ffmpeg: thumbnails. A real pacman -U install was not run.
  • macOS, Windows, web, Android and iOS are unaffected, since only the Linux package metadata changes.

@houko
houko marked this pull request as ready for review November 16, 2026 10:23
@houko
houko merged commit f68039e into main Nov 16, 2026
12 checks passed
@houko
houko deleted the fix/linux-package-dependencies branch November 16, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli documentation Improvements or additions to documentation enhancement New feature or request size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux packages: let an app declare its own Depends / Recommends (core.Video needs GStreamer plug-ins the packages never pull in)

1 participant