Files
keeporg/scripts/build-deb.sh
T
ReactorcoremeltdownandClaude Opus 5.5 ead82dc777 Turn the desktop client into a system tray application
Started without a command, keeporg now shows a padlock in the system tray
with a menu like midi-webhook's: a status line, the mirror folder, each
database with its state, Sync Now, browser sign-in and sign-out, the web
interface, the configuration, the log, Start at Login, About and Quit. The
commands are unchanged.

config.json now carries every client setting (device_label,
request_timeout_seconds, ca_file, log_file, notifications), is written in
full on first start and is reloaded by the tray when saved.

A lock in the mirror directory admits one agent at a time, since the tray,
`keeporg run` and a service unit could otherwise race each other.

The tray uses fyne.io/systray: pure Go on Linux, BSD and Windows, cgo on
macOS only. The server keeps no third-party dependencies.

Desktop versions go to 0.5.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 12:30:28 +01:00

93 lines
3.1 KiB
Bash
Executable File

#!/bin/sh
# Build one Debian package.
# build-deb.sh <client|server> <version> <arch> <output.deb>
set -eu
kind=$1
version=$2
arch=$3
out=$4
root=$(cd "$(dirname "$0")/.." && pwd)
stage=$root/build/deb-$kind-$arch
rm -rf "$stage"
case $kind in
client)
pkg=keeporg
binary=keeporg
mkdir -p "$stage/usr/bin" "$stage/usr/lib/systemd/user" \
"$stage/usr/share/applications" "$stage/usr/share/icons"
install -m 0755 "$root/build/linux-$arch/keeporg" "$stage/usr/bin/keeporg"
install -m 0644 "$root/packaging/systemd/keeporg.service" \
"$stage/usr/lib/systemd/user/keeporg.service"
# The tray application: a menu entry, and the icon it and the tray use.
install -m 0644 "$root/packaging/linux/keeporg.desktop" \
"$stage/usr/share/applications/keeporg.desktop"
cp -R "$root/build/icons/hicolor" "$stage/usr/share/icons/hicolor"
rm -f "$stage/usr/share/icons/hicolor/.stamp"
find "$stage/usr/share/icons" -type d -exec chmod 0755 {} + -o -type f -exec chmod 0644 {} +
;;
server)
pkg=keeporgd
binary=keeporgd
mkdir -p "$stage/usr/bin" "$stage/usr/lib/systemd/system" "$stage/etc/keeporg"
install -m 0755 "$root/build/linux-$arch/keeporgd" "$stage/usr/bin/keeporgd"
install -m 0644 "$root/packaging/systemd/keeporgd.service" \
"$stage/usr/lib/systemd/system/keeporgd.service"
"$root/build/linux-$arch/keeporgd" -write-config "$stage/etc/keeporg/server.json" >/dev/null
chmod 0640 "$stage/etc/keeporg/server.json"
;;
*)
echo "build-deb.sh: unknown package kind $kind" >&2
exit 2
;;
esac
mkdir -p "$stage/DEBIAN" "$stage/usr/share/doc/$pkg"
sed -e "s/@VERSION@/$version/" -e "s/@ARCH@/$arch/" \
"$root/packaging/deb/$kind/control.in" > "$stage/DEBIAN/control"
install -m 0644 "$root/packaging/deb/copyright" "$stage/usr/share/doc/$pkg/copyright"
gzip -9nc "$root/packaging/deb/$kind/changelog" > "$stage/usr/share/doc/$pkg/changelog.Debian.gz"
chmod 0644 "$stage/usr/share/doc/$pkg/changelog.Debian.gz"
if [ "$kind" = server ]; then
cat > "$stage/DEBIAN/conffiles" <<'CONF'
/etc/keeporg/server.json
CONF
cat > "$stage/DEBIAN/postinst" <<'POST'
#!/bin/sh
set -e
if [ "$1" = configure ]; then
if ! getent passwd keeporg >/dev/null; then
adduser --system --group --home /var/lib/keeporg \
--gecos "KeepOrg synchronization server" keeporg
fi
install -d -o keeporg -g keeporg -m 0700 /var/lib/keeporg
chgrp keeporg /etc/keeporg/server.json || true
chmod 0640 /etc/keeporg/server.json || true
if [ -d /run/systemd/system ]; then
systemctl daemon-reload || true
echo "keeporgd: edit /etc/keeporg/server.json, then" \
"systemctl enable --now keeporgd" >&2
echo "keeporgd: a master key will be created at /etc/keeporg/master.key;" \
"back it up separately from /var/lib/keeporg" >&2
fi
fi
exit 0
POST
cat > "$stage/DEBIAN/prerm" <<'PRERM'
#!/bin/sh
set -e
if [ "$1" = remove ] && [ -d /run/systemd/system ]; then
systemctl stop keeporgd || true
fi
exit 0
PRERM
chmod 0755 "$stage/DEBIAN/postinst" "$stage/DEBIAN/prerm"
fi
mkdir -p "$(dirname "$out")"
fakeroot dpkg-deb --root-owner-group --build "$stage" "$out" >/dev/null
printf 'built %s (%s %s %s)\n' "$out" "$binary" "$version" "$arch"