mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-20 07:41:22 +02:00
Fix Flatpak source build: binary paths, wasm skip, lockfile patching, metainfo
- Fix protoc paths (strip-components flattens archive structure) - Patch lockfile at build time for nested workspace deps missing resolved URLs - Skip wasm-pack build (pre-built wasm is checked into repo) - Use cargo build directly instead of tauri CLI (avoids inotify limits) - Fix binary name/path (yaak-app from workspace root target dir) - Install icons from source tree instead of deb bundle - Generate desktop file inline instead of extracting from deb - Add metainfo as file source (not in tagged release yet) - Add build-wasm.cjs script with SKIP_WASM_BUILD env var support - Update generate-sources.sh to resolve nested node_modules deps
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"bootstrap": "npm run build",
|
"bootstrap": "npm run build",
|
||||||
"build": "run-s build:*",
|
"build": "run-s build:*",
|
||||||
"build:pack": "wasm-pack build --target bundler",
|
"build:pack": "node ../../scripts/build-wasm.cjs",
|
||||||
"build:clean": "rimraf ./pkg/.gitignore"
|
"build:clean": "rimraf ./pkg/.gitignore"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ id: app.yaak.Yaak
|
|||||||
runtime: org.gnome.Platform
|
runtime: org.gnome.Platform
|
||||||
runtime-version: "49"
|
runtime-version: "49"
|
||||||
sdk: org.gnome.Sdk
|
sdk: org.gnome.Sdk
|
||||||
command: yaak
|
command: yaak-app
|
||||||
|
|
||||||
sdk-extensions:
|
sdk-extensions:
|
||||||
- org.freedesktop.Sdk.Extension.node22
|
- org.freedesktop.Sdk.Extension.node22
|
||||||
@@ -58,11 +58,17 @@ modules:
|
|||||||
|
|
||||||
# Vendor protoc binary and includes
|
# Vendor protoc binary and includes
|
||||||
- mkdir -p crates-tauri/yaak-app/vendored/protoc
|
- mkdir -p crates-tauri/yaak-app/vendored/protoc
|
||||||
- install -Dm755 protoc-bin/bin/protoc crates-tauri/yaak-app/vendored/protoc/yaakprotoc
|
- install -Dm755 protoc-bin/protoc crates-tauri/yaak-app/vendored/protoc/yaakprotoc
|
||||||
- cp -r protoc-bin/include crates-tauri/yaak-app/vendored/protoc/include
|
- mkdir -p crates-tauri/yaak-app/vendored/protoc/include && cp -r protoc-bin/google crates-tauri/yaak-app/vendored/protoc/include/google
|
||||||
|
|
||||||
# Install wasm-pack (needed for yaak-templates WASM build)
|
# Patch lockfile: add resolved URLs for nested workspace deps
|
||||||
- install -Dm755 vendored-wasm-pack/wasm-pack /app/bin/wasm-pack
|
- >-
|
||||||
|
python3 -c "import json;
|
||||||
|
p='package-lock.json';f=open(p);d=json.load(f);f.close();
|
||||||
|
[info.update({'resolved':'https://registry.npmjs.org/'+n.split('/node_modules/')[-1]+'/-/'+n.split('/')[-1]+'-'+info['version']+'.tgz'})
|
||||||
|
for n,info in d.get('packages',{}).items()
|
||||||
|
if '/node_modules/' in n and 'resolved' not in info and not info.get('link') and info.get('version')];
|
||||||
|
f=open(p,'w');json.dump(d,f);f.close()"
|
||||||
|
|
||||||
# Install npm dependencies offline
|
# Install npm dependencies offline
|
||||||
- npm ci --offline
|
- npm ci --offline
|
||||||
@@ -70,30 +76,40 @@ modules:
|
|||||||
# Pre-fetch Cargo dependencies offline
|
# Pre-fetch Cargo dependencies offline
|
||||||
- cargo --offline fetch --manifest-path Cargo.toml
|
- cargo --offline fetch --manifest-path Cargo.toml
|
||||||
|
|
||||||
|
# Skip wasm-pack build (pre-built wasm is checked into the repo)
|
||||||
|
- >-
|
||||||
|
node -e "const fs=require('fs');
|
||||||
|
const p='crates/yaak-templates/package.json';
|
||||||
|
const d=JSON.parse(fs.readFileSync(p));
|
||||||
|
d.scripts['build:pack']='echo Skipping wasm-pack build';
|
||||||
|
fs.writeFileSync(p,JSON.stringify(d,null,2));"
|
||||||
|
|
||||||
# Build all workspace packages (frontend, plugins, wasm, plugin-runtime)
|
# Build all workspace packages (frontend, plugins, wasm, plugin-runtime)
|
||||||
- npm run build
|
- npm run build
|
||||||
|
|
||||||
# Copy built plugins to vendored directory
|
# Copy built plugins to vendored directory
|
||||||
- npm run vendor:vendor-plugins
|
- npm run vendor:vendor-plugins
|
||||||
|
|
||||||
# Build the Tauri app (Rust backend + bundle as deb for icon/desktop extraction)
|
# Build the Tauri app (cargo build directly to avoid inotify limits from tauri CLI)
|
||||||
# Override beforeBuildCommand since we already built the frontend and dependencies above
|
- cargo build --offline --release -p yaak-app
|
||||||
- >-
|
|
||||||
npx tauri build -b deb
|
|
||||||
--config crates-tauri/yaak-app/tauri.linux.conf.json
|
|
||||||
--config '{"build":{"beforeBuildCommand":""}}'
|
|
||||||
|
|
||||||
# Install binary
|
# Install binary
|
||||||
- install -Dm755 crates-tauri/yaak-app/target/release/yaak /app/bin/yaak-app
|
- install -Dm755 target/release/yaak-app /app/bin/yaak-app
|
||||||
|
|
||||||
# Install icons from the deb bundle
|
# Install icons from source
|
||||||
- cp -r crates-tauri/yaak-app/target/release/bundle/deb/*/data/usr/share/icons /app/share/icons
|
- install -Dm644 crates-tauri/yaak-app/icons/release/32x32.png /app/share/icons/hicolor/32x32/apps/yaak-app.png
|
||||||
|
- install -Dm644 crates-tauri/yaak-app/icons/release/64x64.png /app/share/icons/hicolor/64x64/apps/yaak-app.png
|
||||||
|
- install -Dm644 crates-tauri/yaak-app/icons/release/128x128.png /app/share/icons/hicolor/128x128/apps/yaak-app.png
|
||||||
|
- install -Dm644 crates-tauri/yaak-app/icons/release/icon.png /app/share/icons/hicolor/512x512/apps/yaak-app.png
|
||||||
|
|
||||||
# Install desktop file
|
# Install desktop file
|
||||||
- install -Dm644 crates-tauri/yaak-app/target/release/bundle/deb/*/data/usr/share/applications/yaak.desktop /app/share/applications/yaak.desktop
|
- >-
|
||||||
|
printf '[Desktop Entry]\nCategories=Development;\nComment=The API client for modern developers\nExec=yaak-app\nIcon=yaak-app\nName=Yaak\nStartupWMClass=yaak\nTerminal=false\nType=Application\n'
|
||||||
|
> yaak.desktop
|
||||||
|
- install -Dm644 yaak.desktop /app/share/applications/yaak.desktop
|
||||||
|
|
||||||
# Install metainfo and license
|
# Install metainfo and license
|
||||||
- install -Dm644 flatpak/app.yaak.Yaak.metainfo.xml /app/share/metainfo/app.yaak.Yaak.metainfo.xml
|
- install -Dm644 app.yaak.Yaak.metainfo.xml /app/share/metainfo/app.yaak.Yaak.metainfo.xml
|
||||||
- install -Dm644 LICENSE /app/share/licenses/app.yaak.Yaak/LICENSE
|
- install -Dm644 LICENSE /app/share/licenses/app.yaak.Yaak/LICENSE
|
||||||
|
|
||||||
sources:
|
sources:
|
||||||
@@ -130,24 +146,6 @@ modules:
|
|||||||
only-arches:
|
only-arches:
|
||||||
- aarch64
|
- aarch64
|
||||||
|
|
||||||
# wasm-pack binary (x86_64)
|
|
||||||
- type: archive
|
|
||||||
url: https://github.com/drager/wasm-pack/releases/download/v0.13.1/wasm-pack-v0.13.1-x86_64-unknown-linux-musl.tar.gz
|
|
||||||
sha256: c539d91ccab2591a7e975bcf82c82e1911b03335c80aa83d67ad25ed2ad06539
|
|
||||||
strip-components: 1
|
|
||||||
dest: vendored-wasm-pack
|
|
||||||
only-arches:
|
|
||||||
- x86_64
|
|
||||||
|
|
||||||
# wasm-pack binary (aarch64)
|
|
||||||
- type: archive
|
|
||||||
url: https://github.com/drager/wasm-pack/releases/download/v0.13.1/wasm-pack-v0.13.1-aarch64-unknown-linux-musl.tar.gz
|
|
||||||
sha256: 2e65038769f8bbaa5fc237ad4bb523e692df99458cbd3e3d92525b89d8762379
|
|
||||||
strip-components: 1
|
|
||||||
dest: vendored-wasm-pack
|
|
||||||
only-arches:
|
|
||||||
- aarch64
|
|
||||||
|
|
||||||
# Vendored protoc binary and includes (x86_64)
|
# Vendored protoc binary and includes (x86_64)
|
||||||
- type: archive
|
- type: archive
|
||||||
url: https://github.com/protocolbuffers/protobuf/releases/download/v33.1/protoc-33.1-linux-x86_64.zip
|
url: https://github.com/protocolbuffers/protobuf/releases/download/v33.1/protoc-33.1-linux-x86_64.zip
|
||||||
@@ -167,3 +165,7 @@ modules:
|
|||||||
# License file
|
# License file
|
||||||
- type: file
|
- type: file
|
||||||
path: ../LICENSE
|
path: ../LICENSE
|
||||||
|
|
||||||
|
# Metainfo file (not in tagged source yet)
|
||||||
|
- type: file
|
||||||
|
path: app.yaak.Yaak.metainfo.xml
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ with open(sys.argv[1]) as f:
|
|||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
packages = data.get('packages', {})
|
packages = data.get('packages', {})
|
||||||
to_remove = []
|
to_remove = []
|
||||||
|
needs_resolve = []
|
||||||
for name, info in packages.items():
|
for name, info in packages.items():
|
||||||
if not name:
|
if not name:
|
||||||
continue
|
continue
|
||||||
@@ -63,8 +64,44 @@ for name, info in packages.items():
|
|||||||
continue
|
continue
|
||||||
if 'resolved' in info:
|
if 'resolved' in info:
|
||||||
continue
|
continue
|
||||||
# No 'resolved' and not a link — this is a local workspace package
|
# No 'resolved' and not a link — local workspace package or nested dep.
|
||||||
to_remove.append(name)
|
if '/node_modules/' in name:
|
||||||
|
# Nested node_modules entry inside a workspace package — needs
|
||||||
|
# resolved URL and integrity for flatpak-node-generator.
|
||||||
|
needs_resolve.append((name, info))
|
||||||
|
else:
|
||||||
|
to_remove.append(name)
|
||||||
|
|
||||||
|
# Fetch missing resolved/integrity from the npm registry
|
||||||
|
import urllib.request
|
||||||
|
_packument_cache = {}
|
||||||
|
for name, info in needs_resolve:
|
||||||
|
pkg = name.split('/node_modules/')[-1]
|
||||||
|
version = info.get('version', '')
|
||||||
|
if not version:
|
||||||
|
to_remove.append(name)
|
||||||
|
continue
|
||||||
|
if pkg not in _packument_cache:
|
||||||
|
url = f'https://registry.npmjs.org/{pkg}'
|
||||||
|
try:
|
||||||
|
req = urllib.request.Request(url, headers={'Accept': 'application/json'})
|
||||||
|
with urllib.request.urlopen(req) as resp:
|
||||||
|
_packument_cache[pkg] = json.loads(resp.read())
|
||||||
|
except Exception as e:
|
||||||
|
print(f'Warning: failed to fetch {url}: {e}', file=sys.stderr)
|
||||||
|
to_remove.append(name)
|
||||||
|
continue
|
||||||
|
packument = _packument_cache[pkg]
|
||||||
|
ver_info = packument.get('versions', {}).get(version, {})
|
||||||
|
dist = ver_info.get('dist', {})
|
||||||
|
if dist.get('tarball') and dist.get('integrity'):
|
||||||
|
info['resolved'] = dist['tarball']
|
||||||
|
info['integrity'] = dist['integrity']
|
||||||
|
print(f'Resolved {pkg}@{version}', file=sys.stderr)
|
||||||
|
else:
|
||||||
|
print(f'Warning: no dist info for {pkg}@{version}, removing', file=sys.stderr)
|
||||||
|
to_remove.append(name)
|
||||||
|
|
||||||
for name in to_remove:
|
for name in to_remove:
|
||||||
del packages[name]
|
del packages[name]
|
||||||
with open(sys.argv[2], 'w') as f:
|
with open(sys.argv[2], 'w') as f:
|
||||||
|
|||||||
8
scripts/build-wasm.cjs
Normal file
8
scripts/build-wasm.cjs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
const { execSync } = require('node:child_process');
|
||||||
|
|
||||||
|
if (process.env.SKIP_WASM_BUILD === '1') {
|
||||||
|
console.log('Skipping wasm-pack build (SKIP_WASM_BUILD=1)');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
execSync('wasm-pack build --target bundler', { stdio: 'inherit' });
|
||||||
Reference in New Issue
Block a user