This commit is contained in:
BestCodes
2026-05-29 09:31:44 -05:00
parent f79615a48b
commit dc58534dd6
5 changed files with 84 additions and 14 deletions
+44 -6
View File
@@ -10,6 +10,7 @@ Files in this workflow:
- `flatpak/goose-desktop.sh`: launcher wrapper used inside the sandbox
- `flatpak/cargo-sources.json`: offline Cargo dependency sources generated from `Cargo.lock`
- `flatpak/generated-sources.json`: offline pnpm dependency sources generated from `ui/pnpm-lock.yaml`
- `flatpak/forge-post-package.js`: local hook used during `electron-forge package` to copy the packaged app into `/app/lib/goose`
## Important distinction
@@ -28,10 +29,14 @@ Instead it:
1. Builds `goose-server` from source inside the Flatpak SDK.
2. Copies the resulting `goosed` binary into `ui/desktop/src/bin/goosed`.
3. Installs the `ui/` pnpm workspace offline from `flatpak/generated-sources.json`.
4. Runs `electron-forge package --platform=linux` inside the Flatpak build sandbox.
5. Copies the packaged app into `/app/lib/goose`.
6. Installs the desktop file, metainfo, icons, and wrapper script.
3. Bootstraps a pinned `pnpm@10.30.3` from `pnpm-10.30.3.tgz` and exposes real `pnpm` and `pnpx` shims on `PATH`.
4. Installs the `ui/` pnpm workspace offline from `flatpak/generated-sources.json`.
5. Patches `ui/desktop/forge.config.ts` during the build to point Electron Forge at the staged offline Electron ZIP cache and add a `postPackage` hook.
6. Runs `electron-forge package --platform=linux` inside the Flatpak build sandbox.
7. Copies the packaged app into `/app/lib/goose` from Forge's actual `outputPaths`.
8. Installs the desktop file, metainfo, icons, and wrapper script.
The manifest builds from the Goose release tarball, not from the working tree. Because that tarball does not include the repo's `flatpak/` directory, the local packaging files in `flatpak/` are added as explicit `type: file` sources in `io.github.block.Goose.yaml`.
Runtime behavior also differs from the Electron Forge `.flatpak` artifact:
@@ -53,12 +58,21 @@ Required tools:
- `appstreamcli`
- `desktop-file-validate`
You also need the Flathub remote configured:
If you build with `--user`, you need the user-scoped Flathub remote configured:
```bash
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
```
On this host, `flatpak-builder` also required disabling rofiles FUSE because `rofiles-fuse` failed with:
```text
fusermount3: failed to access mountpoint ... Permission denied
Error: Failure spawning rofiles-fuse, exit_status: 1024
```
The local workaround was `--disable-rofiles-fuse`.
Build the manifest locally:
```bash
@@ -67,6 +81,7 @@ flatpak-builder \
--install \
--install-deps-from=flathub \
--force-clean \
--disable-rofiles-fuse \
builddir \
io.github.block.Goose.yaml
```
@@ -84,6 +99,7 @@ flatpak-builder \
--user \
--install-deps-from=flathub \
--force-clean \
--disable-rofiles-fuse \
--repo=repo \
builddir \
io.github.block.Goose.yaml
@@ -127,6 +143,28 @@ Those are expected for the current packaging model:
- `--talk-name=org.freedesktop.Flatpak` is intentional because Goose needs `flatpak-spawn --host` for host-side shell execution
- `appid-url-not-reachable` currently points at the legacy app ID owner URL and should be fixed before or during Flathub review
## Proven local result
The following command was run locally and completed successfully:
```bash
flatpak-builder \
--user \
--install \
--install-deps-from=flathub \
--force-clean \
--disable-rofiles-fuse \
builddir \
io.github.block.Goose.yaml
```
That run:
- built `goose-server`
- installed the pnpm workspace fully offline
- packaged the Electron app fully offline
- exported and installed `app/io.github.block.Goose/x86_64/master`
## When to regenerate generated sources
Regenerate the dependency manifests whenever any of these change:
+12
View File
@@ -0,0 +1,12 @@
const fs = require('node:fs/promises');
module.exports = async (_forgeConfig, { outputPaths }) => {
const packageDir = outputPaths.find((outputPath) => outputPath.includes('-linux-'));
if (!packageDir) {
throw new Error(`Packaged Goose app directory not found in output paths: ${outputPaths.join(', ')}`);
}
await fs.rm('/app/lib/goose', { recursive: true, force: true });
await fs.cp(packageDir, '/app/lib/goose', { recursive: true });
};
File diff suppressed because one or more lines are too long
+26 -7
View File
@@ -39,13 +39,21 @@ modules:
- install -Dm0644 cargo/config .cargo/config.toml
- cargo --offline build --release -p goose-server
- install -Dm0755 target/release/goosed ui/desktop/src/bin/goosed
- cd ui && corepack enable && pnpm config set store-dir /run/build/goose-desktop/flatpak-node/pnpm-store && pnpm install --offline --frozen-lockfile
- cd ui/desktop && pnpm run i18n:compile && ELECTRON_SKIP_BINARY_DOWNLOAD=1 ELECTRON_OVERRIDE_DIST_PATH=/usr/lib/sdk/node24/lib/node_modules/electron/dist npx electron-forge package --platform=linux
- mkdir -p /app/lib/goose
- cp -a ui/desktop/out/Goose-linux*/. /app/lib/goose/
- install -Dm0755 flatpak/goose-desktop.sh /app/bin/goose-desktop
- install -Dm0644 flatpak/io.github.block.Goose.desktop /app/share/applications/io.github.block.Goose.desktop
- install -Dm0644 flatpak/io.github.block.Goose.metainfo.xml /app/share/metainfo/io.github.block.Goose.metainfo.xml
- mkdir -p /run/build/goose-desktop/pnpm-cli /run/build/goose-desktop/pnpm-bin && tar -xzf pnpm-10.30.3.tgz -C /run/build/goose-desktop/pnpm-cli && ln -sf /run/build/goose-desktop/pnpm-cli/package/bin/pnpm.cjs /run/build/goose-desktop/pnpm-bin/pnpm && ln -sf /run/build/goose-desktop/pnpm-cli/package/bin/pnpx.cjs /run/build/goose-desktop/pnpm-bin/pnpx
- export PATH="/run/build/goose-desktop/pnpm-bin:$PATH" && cd ui && pnpm config set store-dir /run/build/goose-desktop/flatpak-node/pnpm-store && pnpm install --offline --frozen-lockfile
- |
export PATH="/run/build/goose-desktop/pnpm-bin:$PATH" && \
cd ui/desktop && \
perl -0pi -e "s/const \{ resolve \} = require\('path'\);\n/const { resolve } = require('path');\nconst postPackage = require('..\/..\/forge-post-package');\n/" forge.config.ts && \
perl -0pi -e "s/ icon: 'src\/images\/icon',\n/ icon: 'src\/images\/icon',\n electronZipDir: process.env.ELECTRON_ZIP_DIR,\n/" forge.config.ts && \
perl -0pi -e "s/module\.exports = \{\n/module.exports = {\n hooks: { postPackage },\n/" forge.config.ts && \
pnpm run i18n:compile && \
ELECTRON_SKIP_BINARY_DOWNLOAD=1 \
ELECTRON_ZIP_DIR=/run/build/goose-desktop/flatpak-node/cache/electron \
pnpm exec electron-forge package --platform=linux
- install -Dm0755 goose-desktop.sh /app/bin/goose-desktop
- install -Dm0644 io.github.block.Goose.desktop /app/share/applications/io.github.block.Goose.desktop
- install -Dm0644 io.github.block.Goose.metainfo.xml /app/share/metainfo/io.github.block.Goose.metainfo.xml
- install -Dm0644 ui/desktop/src/images/icon.svg /app/share/icons/hicolor/scalable/apps/io.github.block.Goose.svg
- install -Dm0644 ui/desktop/src/images/icon-512.png /app/share/icons/hicolor/512x512/apps/io.github.block.Goose.png
sources:
@@ -56,5 +64,16 @@ modules:
- type: file
url: https://github.com/denoland/rusty_v8/releases/download/v145.0.0/librusty_v8_release_x86_64-unknown-linux-gnu.a.gz
sha256: 7215753c0c78d141f752d7b993794bae07e18a1dfd466dcaa84fa64e76bacac1
- type: file
url: https://registry.npmjs.org/pnpm/-/pnpm-10.30.3.tgz
sha512: c961d1e0a2d8e354ecaa5166b822516668b7f44cb5bd95122d590dd81922f606f5473b6d23ec4a5be05e7fcd18e8488d47d978bbe981872f1145d06e9a740017
- type: file
path: flatpak/forge-post-package.js
- type: file
path: flatpak/goose-desktop.sh
- type: file
path: flatpak/io.github.block.Goose.desktop
- type: file
path: flatpak/io.github.block.Goose.metainfo.xml
- flatpak/cargo-sources.json
- flatpak/generated-sources.json
+1
View File
@@ -1,5 +1,6 @@
{
"private": true,
"packageManager": "pnpm@11.4.0",
"workspaces": [
"acp",
"text",