diff options
| author | Adam Malczewski <[email protected]> | 2026-05-27 23:17:18 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-05-27 23:17:18 +0900 |
| commit | 60f56367dfc1e3c5095d034bed4fb4f572e32b55 (patch) | |
| tree | aa4bc7be095e7030ce0b1a67e33b1abe4cc8c36a /packaging | |
| parent | 4f0ed4ed9456e30344228f0106f6bb104417da3d (diff) | |
| download | dispatch-60f56367dfc1e3c5095d034bed4fb4f572e32b55.tar.gz dispatch-60f56367dfc1e3c5095d034bed4fb4f572e32b55.zip | |
refactor(packaging): split into dispatch/dispatch-systemd/dispatch-s6, separate dispatch-electron, add bun-based frontend serve
PKGBUILD is now a split package producing three .pkg.tar.zst files in one
makepkg run:
- dispatch base application files (/opt/dispatch), CLI wrappers
(dispatch-api, dispatch-frontend), env configs
(/etc/dispatch/dispatch-api.conf,
/etc/dispatch/dispatch-frontend.conf)
- dispatch-systemd systemd user units for dispatch-api + dispatch-frontend
(conflicts with dispatch-s6)
- dispatch-s6 s6-rc service pipelines (-srv + -log) for both services
(conflicts with dispatch-systemd)
The Electron desktop wrapper moved to its own self-contained PKGBUILD at
packaging/electron/, producing dispatch-electron. It bundles its own copy of
the frontend dist + electron entry points under /opt/dispatch-electron and
does not depend on the base dispatch package, so users can install it
standalone and point VITE_API_URL at any backend at build time.
Files under packaging/ are now read directly from ${_projectdir}/packaging/
rather than via source=(); the two s6 service dirs share basenames (run,
type) which would collide inside ${srcdir}.
New frontend static server: packages/frontend/serve.ts uses Bun's built-in
HTTP server (no extra runtime deps) with SPA fallback to index.html and
path-traversal protection. PORT/HOST/DIST_DIR overridable via env. Exposed
as 'bun run --cwd packages/frontend serve' and via /usr/bin/dispatch-frontend.
Build scripts:
- bin/build-pkg now prints the freshest built packages
- bin/install-pkg installs dispatch + dispatch-systemd by default;
accepts package names or --all; searches both
packaging/ and packaging/electron/
- bin/build-pkg-electron new, builds the electron split
- bin/build-pkg-windows replaces bin/windows-pkg; drops the hard-coded
WSL copy step, just prints the win-unpacked path
.gitignore extended to cover packaging/*.tar.zst and packaging/electron/{src,pkg,*.pkg.tar.zst,*.tar.zst}.
Diffstat (limited to 'packaging')
28 files changed, 490 insertions, 62 deletions
diff --git a/packaging/PKGBUILD b/packaging/PKGBUILD index de49d4e..4ac87a8 100644 --- a/packaging/PKGBUILD +++ b/packaging/PKGBUILD @@ -1,30 +1,36 @@ # Maintainer: dispatch -pkgname=dispatch +# +# Split package: builds the base application once and produces three packages: +# dispatch — application files + CLI wrappers + env configs +# dispatch-systemd — systemd user units for dispatch-api / dispatch-frontend +# dispatch-s6 — s6 service definitions for dispatch-api / dispatch-frontend +# +# The Electron desktop wrapper lives in a separate PKGBUILD at packaging/electron/. +# +# Build with: +# bin/build-pkg # makepkg -fd in packaging/ + +pkgbase=dispatch +pkgname=('dispatch' 'dispatch-systemd' 'dispatch-s6') pkgver=0.0.1 pkgrel=1 -pkgdesc='AI Agent Dispatch Interface' arch=('x86_64') url='https://github.com/anomalyco/dispatch' license=('MIT') -depends=('electron' 'bun') -makedepends=() -install=dispatch.install -backup=('etc/dispatch/dispatch-api.conf') -source=( - 'dispatch-api.service' - 'dispatch-api.conf' - 'dispatch-electron-wrapper.sh' - 'dispatch-api-wrapper.sh' - 'dispatch.desktop' - 'dispatch.svg' -) -sha256sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP') +makedepends=('bun') +# All static files are read directly from ${_projectdir}/packaging/. We don't +# use source=() because two of the s6 files share basenames (run, type), which +# would collide inside ${srcdir}. +source=() +sha256sums=() _projectdir="${startdir}/.." +_packagingdir="${_projectdir}/packaging" prepare() { mkdir -p "${srcdir}/dispatch-${pkgver}" - # Copy project files into the src build directory (use -a to preserve symlinks) + + # Copy project files into the src build directory (preserve symlinks) cp -a \ "${_projectdir}/packages" \ "${_projectdir}/package.json" \ @@ -32,7 +38,6 @@ prepare() { "${_projectdir}/tsconfig.base.json" \ "${srcdir}/dispatch-${pkgver}/" - # Copy dispatch.toml if it exists if [ -f "${_projectdir}/dispatch.toml" ]; then cp "${_projectdir}/dispatch.toml" "${srcdir}/dispatch-${pkgver}/" fi @@ -41,18 +46,30 @@ prepare() { build() { cd "${srcdir}/dispatch-${pkgver}" - # Install all deps (including devDependencies needed for vite build) + # Install all deps (including devDependencies for vite build) bun install --frozen-lockfile # Build the frontend with production API port - VITE_API_URL="http://localhost:18390" bun run --cwd packages/frontend build + VITE_API_URL="${VITE_API_URL:-http://localhost:18390}" \ + bun run --cwd packages/frontend build - # Reinstall with production only to slim down node_modules for packaging + # Slim node_modules for runtime rm -rf node_modules bun install --frozen-lockfile --production } -package() { +# ---------------------------------------------------------------------------- +# dispatch — application files, CLI wrappers, env configs +# ---------------------------------------------------------------------------- +package_dispatch() { + pkgdesc='AI Agent Dispatch — backend + frontend (application files)' + depends=('bun') + install=dispatch.install + backup=( + 'etc/dispatch/dispatch-api.conf' + 'etc/dispatch/dispatch-frontend.conf' + ) + cd "${srcdir}/dispatch-${pkgver}" local optdir="${pkgdir}/opt/dispatch" @@ -67,61 +84,112 @@ package() { install -dm755 "${optdir}/packages/core" cp -a packages/core/. "${optdir}/packages/core/" - # Frontend: built dist only + # Frontend: built dist + serve script + package.json (for workspace resolution) install -dm755 "${optdir}/packages/frontend/dist" cp -a packages/frontend/dist/. "${optdir}/packages/frontend/dist/" - - # Frontend: electron launcher files - install -dm755 "${optdir}/packages/frontend/electron" - cp -a packages/frontend/electron/. "${optdir}/packages/frontend/electron/" - - # Frontend: package.json (needed for workspace resolution) + install -Dm644 packages/frontend/serve.ts "${optdir}/packages/frontend/serve.ts" install -Dm644 packages/frontend/package.json "${optdir}/packages/frontend/package.json" # Runtime node_modules (preserve symlinks for bun workspaces) install -dm755 "${optdir}/node_modules" cp -a node_modules/. "${optdir}/node_modules/" - # Root manifest and lockfile + # Root manifest + lockfile install -Dm644 package.json "${optdir}/package.json" install -Dm644 bun.lock "${optdir}/bun.lock" - # Default config (if present) + # Optional default config if [ -f dispatch.toml ]; then install -Dm644 dispatch.toml "${optdir}/dispatch.toml" fi - # --- systemd user service --- - install -Dm644 \ - "${srcdir}/dispatch-api.service" \ - "${pkgdir}/usr/lib/systemd/user/dispatch-api.service" - - # --- Environment config (preserved across upgrades via backup=()) --- + # --- Environment configs (preserved across upgrades via backup=()) --- install -Dm644 \ - "${srcdir}/dispatch-api.conf" \ + "${_packagingdir}/dispatch-api.conf" \ "${pkgdir}/etc/dispatch/dispatch-api.conf" + install -Dm644 \ + "${_packagingdir}/dispatch-frontend.conf" \ + "${pkgdir}/etc/dispatch/dispatch-frontend.conf" - # --- Wrapper scripts --- - install -Dm755 \ - "${srcdir}/dispatch-electron-wrapper.sh" \ - "${pkgdir}/usr/bin/dispatch" - + # --- CLI wrappers --- install -Dm755 \ - "${srcdir}/dispatch-api-wrapper.sh" \ + "${_packagingdir}/dispatch-api-wrapper.sh" \ "${pkgdir}/usr/bin/dispatch-api" - - # --- Desktop integration --- - install -Dm644 \ - "${srcdir}/dispatch.desktop" \ - "${pkgdir}/usr/share/applications/dispatch.desktop" - - install -Dm644 \ - "${srcdir}/dispatch.svg" \ - "${pkgdir}/usr/share/icons/hicolor/scalable/apps/dispatch.svg" + install -Dm755 \ + "${_packagingdir}/dispatch-frontend-wrapper.sh" \ + "${pkgdir}/usr/bin/dispatch-frontend" # --- License --- if [ -f "${_projectdir}/LICENSE" ]; then install -Dm644 "${_projectdir}/LICENSE" \ - "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" + "${pkgdir}/usr/share/licenses/dispatch/LICENSE" fi } + +# ---------------------------------------------------------------------------- +# dispatch-systemd — systemd user unit files +# ---------------------------------------------------------------------------- +package_dispatch-systemd() { + pkgdesc='Systemd user units for the Dispatch API and Frontend services' + depends=("dispatch=${pkgver}" 'systemd') + conflicts=('dispatch-s6') + install=dispatch-systemd.install + + install -Dm644 \ + "${_packagingdir}/dispatch-api.service" \ + "${pkgdir}/usr/lib/systemd/user/dispatch-api.service" + + install -Dm644 \ + "${_packagingdir}/dispatch-frontend.service" \ + "${pkgdir}/usr/lib/systemd/user/dispatch-frontend.service" +} + +# ---------------------------------------------------------------------------- +# dispatch-s6 — s6 service definitions (for Artix / standalone s6) +# ---------------------------------------------------------------------------- +package_dispatch-s6() { + pkgdesc='s6-rc service definitions for the Dispatch API and Frontend services' + depends=("dispatch=${pkgver}" 's6' 's6-rc') + conflicts=('dispatch-systemd') + install=dispatch-s6.install + + # s6-rc layout: each service is split into a `-srv` (the daemon) and a + # `-log` (s6-log consumer), linked by producer-for/consumer-for/pipeline-name. + # The pipeline-name lets `s6-rc -u change dispatch-api` bring both up together. + + # --- dispatch-api-srv --- + install -Dm755 "${_packagingdir}/s6/dispatch-api-srv/run" \ + "${pkgdir}/etc/s6/sv/dispatch-api-srv/run" + install -Dm644 "${_packagingdir}/s6/dispatch-api-srv/type" \ + "${pkgdir}/etc/s6/sv/dispatch-api-srv/type" + install -Dm644 "${_packagingdir}/s6/dispatch-api-srv/producer-for" \ + "${pkgdir}/etc/s6/sv/dispatch-api-srv/producer-for" + + # --- dispatch-api-log --- + install -Dm755 "${_packagingdir}/s6/dispatch-api-log/run" \ + "${pkgdir}/etc/s6/sv/dispatch-api-log/run" + install -Dm644 "${_packagingdir}/s6/dispatch-api-log/type" \ + "${pkgdir}/etc/s6/sv/dispatch-api-log/type" + install -Dm644 "${_packagingdir}/s6/dispatch-api-log/consumer-for" \ + "${pkgdir}/etc/s6/sv/dispatch-api-log/consumer-for" + install -Dm644 "${_packagingdir}/s6/dispatch-api-log/pipeline-name" \ + "${pkgdir}/etc/s6/sv/dispatch-api-log/pipeline-name" + + # --- dispatch-frontend-srv --- + install -Dm755 "${_packagingdir}/s6/dispatch-frontend-srv/run" \ + "${pkgdir}/etc/s6/sv/dispatch-frontend-srv/run" + install -Dm644 "${_packagingdir}/s6/dispatch-frontend-srv/type" \ + "${pkgdir}/etc/s6/sv/dispatch-frontend-srv/type" + install -Dm644 "${_packagingdir}/s6/dispatch-frontend-srv/producer-for" \ + "${pkgdir}/etc/s6/sv/dispatch-frontend-srv/producer-for" + + # --- dispatch-frontend-log --- + install -Dm755 "${_packagingdir}/s6/dispatch-frontend-log/run" \ + "${pkgdir}/etc/s6/sv/dispatch-frontend-log/run" + install -Dm644 "${_packagingdir}/s6/dispatch-frontend-log/type" \ + "${pkgdir}/etc/s6/sv/dispatch-frontend-log/type" + install -Dm644 "${_packagingdir}/s6/dispatch-frontend-log/consumer-for" \ + "${pkgdir}/etc/s6/sv/dispatch-frontend-log/consumer-for" + install -Dm644 "${_packagingdir}/s6/dispatch-frontend-log/pipeline-name" \ + "${pkgdir}/etc/s6/sv/dispatch-frontend-log/pipeline-name" +} diff --git a/packaging/dispatch-electron-wrapper.sh b/packaging/dispatch-electron-wrapper.sh deleted file mode 100755 index df24713..0000000 --- a/packaging/dispatch-electron-wrapper.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -exec /usr/bin/electron --name="Dispatch" /opt/dispatch/packages/frontend/electron/main.cjs "$@" diff --git a/packaging/dispatch-frontend-wrapper.sh b/packaging/dispatch-frontend-wrapper.sh new file mode 100755 index 0000000..06aa9b0 --- /dev/null +++ b/packaging/dispatch-frontend-wrapper.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# dispatch-frontend-wrapper.sh +# Wrapper script for running the Dispatch Frontend static-file server +# outside of systemd / s6. +# Install to /usr/bin/dispatch-frontend (chmod 755). +# +# Usage: +# dispatch-frontend # runs the server, inheriting the current environment +# dispatch-frontend --help # passes flags through to bun + +set -euo pipefail + +DISPATCH_CONF="/etc/dispatch/dispatch-frontend.conf" +DISPATCH_DIR="/opt/dispatch" +BUN="/usr/bin/bun" +ENTRY_POINT="packages/frontend/serve.ts" + +# Source the environment file if it exists +if [[ -f "$DISPATCH_CONF" ]]; then + set -o allexport + # shellcheck source=/etc/dispatch/dispatch-frontend.conf + source "$DISPATCH_CONF" + set +o allexport +fi + +# Change to the application directory +cd "$DISPATCH_DIR" + +# Hand off to bun — exec replaces this process so signals are forwarded correctly +exec "$BUN" "$ENTRY_POINT" "$@" diff --git a/packaging/dispatch-frontend.conf b/packaging/dispatch-frontend.conf new file mode 100644 index 0000000..37d2984 --- /dev/null +++ b/packaging/dispatch-frontend.conf @@ -0,0 +1,21 @@ +# /etc/dispatch/dispatch-frontend.conf +# Environment configuration for the Dispatch Frontend static-file server. +# Sourced by systemd (EnvironmentFile=), the s6 run script, and the +# dispatch-frontend-wrapper.sh script for manual invocation. +# +# Lines beginning with '#' are comments and are ignored. +# Syntax: KEY=value (no spaces around '=', no 'export' keyword needed for systemd) + +# --------------------------------------------------------------------------- +# Server +# --------------------------------------------------------------------------- + +# Port the static file server listens on (default: 18391). +PORT=18391 + +# Interface to bind to (default: 0.0.0.0). +# HOST=0.0.0.0 + +# Directory containing the built frontend assets. +# Defaults to /opt/dispatch/packages/frontend/dist +# DIST_DIR=/opt/dispatch/packages/frontend/dist diff --git a/packaging/dispatch-frontend.service b/packaging/dispatch-frontend.service new file mode 100644 index 0000000..4aca1a3 --- /dev/null +++ b/packaging/dispatch-frontend.service @@ -0,0 +1,16 @@ +[Unit] +Description=Dispatch Frontend (static file server) +After=dispatch-api.service + +[Service] +Type=simple +WorkingDirectory=/opt/dispatch +ExecStart=/usr/bin/bun packages/frontend/serve.ts +EnvironmentFile=-/etc/dispatch/dispatch-frontend.conf +Restart=on-failure +RestartSec=5 +StandardOutput=journal +StandardError=journal + +[Install] +WantedBy=default.target diff --git a/packaging/dispatch-s6.install b/packaging/dispatch-s6.install new file mode 100644 index 0000000..efa4c9b --- /dev/null +++ b/packaging/dispatch-s6.install @@ -0,0 +1,46 @@ +post_install() { + install -dm755 -o tradam -g tradam /var/log/dispatch-api + install -dm755 -o tradam -g tradam /var/log/dispatch-frontend + + echo "" + echo "==> Dispatch s6-rc services installed at /etc/s6/sv/" + echo " Service pipelines: dispatch-api (= dispatch-api-srv | dispatch-api-log)" + echo " dispatch-frontend (= dispatch-frontend-srv | dispatch-frontend-log)" + echo " To enable and start:" + echo " s6 repository sync" + echo " s6 set enable -I pull dispatch-api-srv dispatch-api-log" + echo " s6 set enable -I pull dispatch-frontend-srv dispatch-frontend-log" + echo " s6 set commit -f" + echo " s6 live install" + echo " s6-rc -u change dispatch-api" + echo " s6-rc -u change dispatch-frontend" + echo "" +} + +post_upgrade() { + install -dm755 -o tradam -g tradam /var/log/dispatch-api 2>/dev/null || true + install -dm755 -o tradam -g tradam /var/log/dispatch-frontend 2>/dev/null || true + + # Remove any stale legacy service dirs from the old (pre-srv/-log split) + # layout, which would otherwise confuse s6 repository sync. + for legacy in /etc/s6/sv/dispatch-api /etc/s6/sv/dispatch-frontend; do + if [ -d "$legacy" ] && [ -d "$legacy/log" ] && [ ! -e "$legacy/producer-for" ]; then + rm -rf "$legacy" + fi + done + + echo "" + echo "==> Dispatch s6 services upgraded." + echo " Restart:" + echo " s6-rc -d change dispatch-api && s6-rc -u change dispatch-api" + echo " s6-rc -d change dispatch-frontend && s6-rc -u change dispatch-frontend" + echo "" +} + +pre_remove() { + echo "" + echo "==> Stopping dispatch services..." + s6-rc -d change dispatch-api 2>/dev/null || true + s6-rc -d change dispatch-frontend 2>/dev/null || true + echo "" +} diff --git a/packaging/dispatch-systemd.install b/packaging/dispatch-systemd.install new file mode 100644 index 0000000..3bd29be --- /dev/null +++ b/packaging/dispatch-systemd.install @@ -0,0 +1,24 @@ +post_install() { + echo "" + echo "==> Dispatch systemd user units installed." + echo " Enable and start:" + echo " systemctl --user daemon-reload" + echo " systemctl --user enable --now dispatch-api dispatch-frontend" + echo "" +} + +post_upgrade() { + echo "" + echo "==> Dispatch systemd units upgraded." + echo " Reload and restart:" + echo " systemctl --user daemon-reload" + echo " systemctl --user restart dispatch-api dispatch-frontend" + echo "" +} + +pre_remove() { + echo "" + echo "==> Stop dispatch services before removal:" + echo " systemctl --user disable --now dispatch-api dispatch-frontend" + echo "" +} diff --git a/packaging/dispatch.install b/packaging/dispatch.install index 7d1439f..76837f5 100644 --- a/packaging/dispatch.install +++ b/packaging/dispatch.install @@ -1,16 +1,31 @@ post_install() { echo "" - echo "==> Dispatch has been installed." - echo " Edit /etc/dispatch/dispatch-api.conf to configure the API." - echo " Then enable and start the service:" - echo " systemctl --user enable --now dispatch-api" + echo "==> Dispatch (base) has been installed." + echo " Application files: /opt/dispatch" + echo " Config:" + echo " /etc/dispatch/dispatch-api.conf" + echo " /etc/dispatch/dispatch-frontend.conf" + echo "" + echo " Run manually:" + echo " dispatch-api # backend (port 18390 by default)" + echo " dispatch-frontend # static frontend (port 18391 by default)" + echo "" + echo " To run as a service, install one of:" + echo " pacman -S dispatch-systemd # systemd user services" + echo " pacman -S dispatch-s6 # s6 services (Artix)" + echo "" + echo " For the Electron desktop wrapper:" + echo " pacman -S dispatch-electron" echo "" } post_upgrade() { echo "" - echo "==> Dispatch has been upgraded." - echo " You may need to restart the service:" - echo " systemctl --user restart dispatch-api" + echo "==> Dispatch (base) upgraded." + echo " If you use dispatch-systemd, restart the units:" + echo " systemctl --user restart dispatch-api dispatch-frontend" + echo " If you use dispatch-s6, restart the services:" + echo " s6-svc -r /run/service/dispatch-api" + echo " s6-svc -r /run/service/dispatch-frontend" echo "" } diff --git a/packaging/electron/PKGBUILD b/packaging/electron/PKGBUILD new file mode 100644 index 0000000..a259418 --- /dev/null +++ b/packaging/electron/PKGBUILD @@ -0,0 +1,100 @@ +# Maintainer: dispatch +# +# Electron desktop wrapper for Dispatch on Linux. +# +# Self-contained: bundles its own copy of the built frontend dist + electron +# entry points under /opt/dispatch-electron/. Does NOT depend on the `dispatch` +# package — install that separately (with dispatch-systemd or dispatch-s6) if +# you want to run the backend locally, or point VITE_API_URL at a remote +# instance at build time. +# +# Build with: +# bin/build-pkg-electron # makepkg -fd in packaging/electron/ +# +# Override the backend URL the bundled frontend talks to: +# VITE_API_URL="http://your-host:18390" bin/build-pkg-electron + +pkgname=dispatch-electron +pkgver=0.0.1 +pkgrel=1 +pkgdesc='Electron desktop wrapper for Dispatch (self-contained)' +arch=('x86_64') +url='https://github.com/anomalyco/dispatch' +license=('MIT') +depends=('electron') +makedepends=('bun') +install=dispatch-electron.install +source=() +sha256sums=() + +_projectdir="${startdir}/../.." +_packagingdir="${_projectdir}/packaging" +_electrondir="${_packagingdir}/electron" + +prepare() { + mkdir -p "${srcdir}/dispatch-electron-${pkgver}" + + # Copy project files into the src build directory (preserve symlinks) + cp -a \ + "${_projectdir}/packages" \ + "${_projectdir}/package.json" \ + "${_projectdir}/bun.lock" \ + "${_projectdir}/tsconfig.base.json" \ + "${srcdir}/dispatch-electron-${pkgver}/" +} + +build() { + cd "${srcdir}/dispatch-electron-${pkgver}" + + # Install all deps (including devDependencies for vite build) + bun install --frozen-lockfile + + # Build the SPA. VITE_API_URL is baked in at build time. + VITE_API_URL="${VITE_API_URL:-http://localhost:18390}" \ + bun run --cwd packages/frontend build +} + +package() { + cd "${srcdir}/dispatch-electron-${pkgver}" + + local optdir="${pkgdir}/opt/dispatch-electron" + + # --- Bundled SPA dist --- + install -dm755 "${optdir}/dist" + cp -a packages/frontend/dist/. "${optdir}/dist/" + + # --- Electron entry points --- + # main.cjs loads ../dist/index.html — so the dist must sit alongside electron/. + install -Dm644 \ + packages/frontend/electron/main.cjs \ + "${optdir}/electron/main.cjs" + install -Dm644 \ + packages/frontend/electron/preload.cjs \ + "${optdir}/electron/preload.cjs" + + # --- /usr/bin/dispatch (electron wrapper) --- + install -Dm755 \ + "${_electrondir}/dispatch-electron-wrapper.sh" \ + "${pkgdir}/usr/bin/dispatch" + + # --- Desktop integration --- + install -Dm644 \ + "${_electrondir}/dispatch.desktop" \ + "${pkgdir}/usr/share/applications/dispatch.desktop" + + install -Dm644 \ + "${_electrondir}/dispatch.svg" \ + "${pkgdir}/usr/share/icons/hicolor/scalable/apps/dispatch.svg" + + if [ -f "${_electrondir}/dispatch.png" ]; then + install -Dm644 \ + "${_electrondir}/dispatch.png" \ + "${pkgdir}/usr/share/icons/hicolor/512x512/apps/dispatch.png" + fi + + # --- License --- + if [ -f "${_projectdir}/LICENSE" ]; then + install -Dm644 "${_projectdir}/LICENSE" \ + "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" + fi +} diff --git a/packaging/electron/dispatch-electron-wrapper.sh b/packaging/electron/dispatch-electron-wrapper.sh new file mode 100755 index 0000000..948db3b --- /dev/null +++ b/packaging/electron/dispatch-electron-wrapper.sh @@ -0,0 +1,2 @@ +#!/bin/bash +exec /usr/bin/electron --name="Dispatch" /opt/dispatch-electron/electron/main.cjs "$@" diff --git a/packaging/electron/dispatch-electron.install b/packaging/electron/dispatch-electron.install new file mode 100644 index 0000000..9eea6b1 --- /dev/null +++ b/packaging/electron/dispatch-electron.install @@ -0,0 +1,32 @@ +post_install() { + echo "" + echo "==> Dispatch Electron desktop wrapper installed (self-contained)." + echo " Launch from your menu (Dispatch) or run:" + echo " dispatch" + echo "" + echo " The bundled frontend talks to the API URL baked in at build" + echo " time (default: http://localhost:18390). To run a local backend:" + echo " pacman -S dispatch dispatch-systemd # systemd" + echo " pacman -S dispatch dispatch-s6 # s6 / Artix" + echo "" + echo " To point the wrapper at a different backend, rebuild with:" + echo " VITE_API_URL=\"http://your-host:18390\" bin/build-pkg-electron" + echo "" + + if command -v update-desktop-database >/dev/null 2>&1; then + update-desktop-database -q /usr/share/applications 2>/dev/null || true + fi + if command -v gtk-update-icon-cache >/dev/null 2>&1; then + gtk-update-icon-cache -q /usr/share/icons/hicolor 2>/dev/null || true + fi +} + +post_upgrade() { + post_install +} + +post_remove() { + if command -v update-desktop-database >/dev/null 2>&1; then + update-desktop-database -q /usr/share/applications 2>/dev/null || true + fi +} diff --git a/packaging/dispatch.desktop b/packaging/electron/dispatch.desktop index 0ed44af..0ed44af 100644 --- a/packaging/dispatch.desktop +++ b/packaging/electron/dispatch.desktop diff --git a/packaging/dispatch.png b/packaging/electron/dispatch.png Binary files differindex 84d743a..84d743a 100644 --- a/packaging/dispatch.png +++ b/packaging/electron/dispatch.png diff --git a/packaging/dispatch.svg b/packaging/electron/dispatch.svg index 2aae97f..2aae97f 100644 --- a/packaging/dispatch.svg +++ b/packaging/electron/dispatch.svg diff --git a/packaging/s6/dispatch-api-log/consumer-for b/packaging/s6/dispatch-api-log/consumer-for new file mode 100644 index 0000000..8a696f4 --- /dev/null +++ b/packaging/s6/dispatch-api-log/consumer-for @@ -0,0 +1 @@ +dispatch-api-srv diff --git a/packaging/s6/dispatch-api-log/pipeline-name b/packaging/s6/dispatch-api-log/pipeline-name new file mode 100644 index 0000000..9dab7e6 --- /dev/null +++ b/packaging/s6/dispatch-api-log/pipeline-name @@ -0,0 +1 @@ +dispatch-api diff --git a/packaging/s6/dispatch-api-log/run b/packaging/s6/dispatch-api-log/run new file mode 100644 index 0000000..5d1b821 --- /dev/null +++ b/packaging/s6/dispatch-api-log/run @@ -0,0 +1,6 @@ +#!/bin/sh +# Logger for dispatch-api. Reads stdout from dispatch-api-srv and writes to +# /var/log/dispatch-api/ using s6-log (auto-rotation, timestamping). + +exec /usr/bin/s6-setuidgid tradam \ + /usr/bin/s6-log -b -d3 -- n10 s10000000 T /var/log/dispatch-api diff --git a/packaging/s6/dispatch-api-log/type b/packaging/s6/dispatch-api-log/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/packaging/s6/dispatch-api-log/type @@ -0,0 +1 @@ +longrun diff --git a/packaging/s6/dispatch-api-srv/producer-for b/packaging/s6/dispatch-api-srv/producer-for new file mode 100644 index 0000000..88f7df2 --- /dev/null +++ b/packaging/s6/dispatch-api-srv/producer-for @@ -0,0 +1 @@ +dispatch-api-log diff --git a/packaging/s6/dispatch-api-srv/run b/packaging/s6/dispatch-api-srv/run new file mode 100644 index 0000000..5754e3d --- /dev/null +++ b/packaging/s6/dispatch-api-srv/run @@ -0,0 +1,29 @@ +#!/bin/sh +# dispatch-api service — runs the Dispatch backend API as the `tradam` user. +# stdout/stderr are piped to dispatch-api-log via the s6-rc pipeline. + +DISPATCH_CONF="/etc/dispatch/dispatch-api.conf" +DISPATCH_DIR="/opt/dispatch" + +if [ -f "$DISPATCH_CONF" ]; then + set -a + . "$DISPATCH_CONF" + set +a +fi + +cd "$DISPATCH_DIR" || exit 1 + +# Merge stderr into stdout so both get logged by the consumer. +exec 2>&1 + +# Drop privileges to tradam and run bun. +exec /usr/bin/s6-setuidgid tradam \ + /usr/bin/env \ + HOME=/home/tradam \ + USER=tradam \ + LOGNAME=tradam \ + PATH=/usr/local/bin:/usr/bin:/bin \ + NODE_ENV="${NODE_ENV:-production}" \ + PORT="${PORT:-18390}" \ + OPENCODE_API_KEY="${OPENCODE_API_KEY:-}" \ + /usr/bin/bun packages/api/src/index.ts diff --git a/packaging/s6/dispatch-api-srv/type b/packaging/s6/dispatch-api-srv/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/packaging/s6/dispatch-api-srv/type @@ -0,0 +1 @@ +longrun diff --git a/packaging/s6/dispatch-frontend-log/consumer-for b/packaging/s6/dispatch-frontend-log/consumer-for new file mode 100644 index 0000000..f941d04 --- /dev/null +++ b/packaging/s6/dispatch-frontend-log/consumer-for @@ -0,0 +1 @@ +dispatch-frontend-srv diff --git a/packaging/s6/dispatch-frontend-log/pipeline-name b/packaging/s6/dispatch-frontend-log/pipeline-name new file mode 100644 index 0000000..0ee914b --- /dev/null +++ b/packaging/s6/dispatch-frontend-log/pipeline-name @@ -0,0 +1 @@ +dispatch-frontend diff --git a/packaging/s6/dispatch-frontend-log/run b/packaging/s6/dispatch-frontend-log/run new file mode 100644 index 0000000..4dda559 --- /dev/null +++ b/packaging/s6/dispatch-frontend-log/run @@ -0,0 +1,6 @@ +#!/bin/sh +# Logger for dispatch-frontend. Reads stdout from dispatch-frontend-srv and +# writes to /var/log/dispatch-frontend/ using s6-log. + +exec /usr/bin/s6-setuidgid tradam \ + /usr/bin/s6-log -b -d3 -- n10 s10000000 T /var/log/dispatch-frontend diff --git a/packaging/s6/dispatch-frontend-log/type b/packaging/s6/dispatch-frontend-log/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/packaging/s6/dispatch-frontend-log/type @@ -0,0 +1 @@ +longrun diff --git a/packaging/s6/dispatch-frontend-srv/producer-for b/packaging/s6/dispatch-frontend-srv/producer-for new file mode 100644 index 0000000..c29eb09 --- /dev/null +++ b/packaging/s6/dispatch-frontend-srv/producer-for @@ -0,0 +1 @@ +dispatch-frontend-log diff --git a/packaging/s6/dispatch-frontend-srv/run b/packaging/s6/dispatch-frontend-srv/run new file mode 100644 index 0000000..3411476 --- /dev/null +++ b/packaging/s6/dispatch-frontend-srv/run @@ -0,0 +1,25 @@ +#!/bin/sh +# dispatch-frontend service — serves the built frontend assets as the `tradam` user. +# stdout/stderr are piped to dispatch-frontend-log via the s6-rc pipeline. + +DISPATCH_CONF="/etc/dispatch/dispatch-frontend.conf" +DISPATCH_DIR="/opt/dispatch" + +if [ -f "$DISPATCH_CONF" ]; then + set -a + . "$DISPATCH_CONF" + set +a +fi + +cd "$DISPATCH_DIR" || exit 1 + +exec 2>&1 + +exec /usr/bin/s6-setuidgid tradam \ + /usr/bin/env \ + HOME=/home/tradam \ + USER=tradam \ + LOGNAME=tradam \ + PATH=/usr/local/bin:/usr/bin:/bin \ + PORT="${PORT:-18391}" \ + /usr/bin/bun packages/frontend/serve.ts diff --git a/packaging/s6/dispatch-frontend-srv/type b/packaging/s6/dispatch-frontend-srv/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/packaging/s6/dispatch-frontend-srv/type @@ -0,0 +1 @@ +longrun |
