Skip to content

feat(packaging): install linux.share files and AppStream metadata under /usr/share - #2200

Merged
houko merged 1 commit into
nsgo-dev:mainfrom
txchen:feat/linux-share
Nov 23, 2026
Merged

houko merged 1 commit into
nsgo-dev:mainfrom
txchen:feat/linux-share

Conversation

@txchen

@txchen txchen commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Why

The .deb and Arch packages install the app under /opt/<slug>, and outside it only the desktop entry, icons and MIME types. They ship no AppStream metadata, so software centers have nothing to read. An app also has no way to install other files the system reads from /usr/share, such as shell completions, manual pages or a richer metainfo file. A file staged under resources/usr/share lands in /opt/<slug>/usr/share, where nothing looks.

What changed

  • Default metadata: the .deb and Arch packages install /usr/share/metainfo/<id>.metainfo.xml, from the same template the Flatpak uses. It names a license only when linux.license is set, has no content rating, and uses Utility as its category when linux.categories is empty, as AppStream requires one.
  • New linux.share: a directory, relative to nsgo.yaml, whose tree the packages install under /usr/share.
    • Its metainfo/<id>.metainfo.xml replaces the generated one.
    • A file at a path the package already holds, or where it needs a directory (for example a file named applications), fails the build.
  • AppImage: carries the same files in its AppDir's usr/share, plus a relative link usr/share/applications/<id>.desktop to the desktop entry at its top, which the metadata's <launchable> names. The link goes through the same collision check.
  • Flatpak output is unchanged.
linux:
  share: packaging/share   # e.g. packaging/share/bash-completion/completions/hello

Scope

  • Targets: the nsgo tool (Linux packaging) and Linux.
  • Screenshots: none; nothing visible changes.

Tradeoffs

  • Every direct Linux package now gains one metainfo file and the AppImage one link. Nothing else changes for apps that don't set linux.share.
  • Files in resources/ still stay in /opt/<slug>.
  • Flatpaks keep NSGo's own metadata and do not take linux.share.

Blast Radius

Linux .deb and Arch packages and AppImages built by NSGo: each gains a metainfo file, and the AppImage a desktop link. linux.share is opt-in. Flatpak and other targets are unaffected.

Verification

  • go tool nsgo check, go tool nsgo check -target linux, the changelog check, and the Linux, AppImage and Flatpak packaging tests in ./cmd/nsgo.
  • New tests cover:
    • full archive member paths in the .deb and Arch packages, with nothing under opt/<slug>/usr;
    • the AppDir entries and the desktop link's target;
    • the metadata defaults, with Flatpak's unchanged;
    • collisions, including a file named applications or metainfo, a resource at the link's path, and a resource named usr.
  • The extracted direct-package payload passed appstreamcli validate-tree in review.
  • Installing the packages on a real Debian or Arch system was not run.

Checklist: the title is a Conventional Commit; the docs whose facts change are updated; the change has a changelog.d/ fragment; no new third-party code, assets or dependencies.

@github-actions github-actions Bot added enhancement New feature or request size/M documentation Improvements or additions to documentation cli labels Nov 23, 2026
@houko

houko commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Reviewed. The change looks right to me. addLinuxShare checks every path against the files the package already holds, both a file where a directory is needed and a file where a file already is. The generated metadata is added only when neither linux.share nor the AppImage resources ship their own. The AppImage's usr/share/applications link resolves to the top-level desktop entry. On a local rebase, the Linux, AppImage and Flatpak packaging tests in ./cmd/nsgo pass, go vet ./... passes, and NSGO_TEST_LINUX_PACKAGES=1 go test -run TestLinuxPackagesNative ./cmd/nsgo passes too. That test installs and removes the packages, now carrying the metainfo file, in Debian 13, Ubuntu 26.04 and Arch containers.

It can't be merged yet: it now conflicts with main in docs/architecture/tool.md, because #2199 rewrote the Windows bullet next to the Linux bullet this PR edits. Keep main's Windows bullet and this PR's Linux bullet; nothing else conflicts. Once it's rebased, it's ready to merge.

…r/share

The Debian and Arch packages installed only the app's desktop entry, icon and MIME types outside /opt/<slug>, so they shipped no AppStream metadata and an app had no way to ship files the system reads from /usr/share.

The packages now install AppStream metadata at /usr/share/metainfo/<id>.metainfo.xml, written as a Flatpak's is but naming a license only from linux.license, no content rating, and Utility as its category without linux.categories; linux.share names a directory whose tree they install under /usr/share. Its metainfo/<id>.metainfo.xml replaces NSGo's, and a file at a path the package holds, or where it needs a directory, fails the build. The AppImage holds the same files in its AppDir's usr/share, with a link to its desktop entry in usr/share/applications, which the metadata's launchable names.
@txchen

txchen commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Rebased onto main: kept main's Windows bullet and this PR's Linux bullet in docs/architecture/tool.md. The Linux, AppImage and Flatpak packaging tests and the changelog check pass.

@txchen

txchen commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

The failing test and windows jobs are TestWindowConstraintsPublishMaximumAndAllowNativeResize (X11) and TestConsumedAltChordKeepsMenusClosed (Windows menus). Both fail the same way in many unrelated PR runs from the last few hours, for example run 45110847207 (fix/upstream-macos-indicator-timing) and run 45106557284 (fix/windows-clipboard-dib-headers), and the first also fails on main in runs 45037334909 and 45036918259. This PR changes only Linux packaging, so I don't think they come from it.

@houko

houko commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Reviewed. The rebase keeps main's Windows bullet and this PR's Linux bullet in docs/architecture/tool.md, and the rest of the diff is what I reviewed before. Rebased onto current main, go vet ./..., the Linux, AppImage and Flatpak packaging tests in ./cmd/nsgo and ./internal/moduletest pass on Linux.

@houko
houko merged commit 3abd9a0 into nsgo-dev:main Nov 23, 2026
23 of 25 checks passed
@txchen
txchen deleted the feat/linux-share branch November 23, 2026 06:34
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.

2 participants