yams/packaging/arch/PKGBUILD
trvon e389e384b1
feat(packaging): ship the daemon as a systemd user unit
The service is now user-bound: each user runs their own daemon with
their own config ($XDG_CONFIG_HOME/yams/config.toml), corpus
($XDG_DATA_HOME/yams) and socket ($XDG_RUNTIME_DIR/yams-daemon.sock),
which is exactly what the CLI already resolves. The system service, its
yams account/group, the group socket and the /etc/yams/config.toml
configuration go away.

- Unit: /usr/lib/systemd/user/yams-daemon.service runs
  `yams-daemon --foreground` with default path resolution,
  Restart=on-failure, WantedBy=default.target, and light hardening
  (NoNewPrivileges, LockPersonality, RestrictRealtime, RestrictSUIDSGID,
  native syscalls only). No ProtectHome/PrivateTmp: the daemon reads the
  files its user adds.
- Enablement: /usr/lib/systemd/user-preset/80-yams.preset plus
  `systemctl --global preset` on first install (and on upgrade from a
  release with the system unit), so the unit starts with every user's
  next session; administrators override with a user preset or
  `systemctl --global disable`, and later upgrades keep that choice.
  Package scripts never start per-user instances: they reload running
  user managers, try-restart running user daemons on upgrade and stop
  them on removal (`systemctl --user` via runuser per /run/user/<uid>),
  then `systemctl --global disable` on removal.
- Migration from 0.20.x and the system-service design: deb preinst, rpm
  %pre and Arch pre_upgrade stop and disable the old system unit while
  its file is still installed (deb also purges deb-systemd-helper
  state). /var/lib/yams, the old system corpus that the CLI never
  reached, is left alone and documented; user corpora are never
  touched.
- The sysusers entry, account creation and the deb's passwd and
  init-system-helpers dependencies are dropped; the deb purge no longer
  deletes /var/lib/yams.
- Install paths move to lib/systemd/user and lib/systemd/user-preset in
  meson, the Arch stage/PKGBUILD and the install-surface policy.
- docs/install.md: the user service, enabling it now
  (`systemctl --user enable --now`), lingering, plugins via the user's
  config, opting out, upgrade and removal behaviour, and the 0.20.3
  leftover.

Signed-off-by: trvon <me@trevon.dev>
2026-10-02 07:55:01 -06:00

133 lines
3.7 KiB
Bash

# Maintainer: YAMS Contributors <git@trevon.dev>
# Contributor: YAMS Contributors <git@trevon.dev>
#
# Build with:
# VERSION=$(git describe --tags --abbrev=7) makepkg --syncdeps --rmdeps --install
#
# CI builds pass _yams_version=... and _yams_release=... to makepkg directly.
pkgname=yams
_pkgver="${_yams_version:-0.0.0}"
pkgver="${_pkgver//-/_}" # makepkg requires version without hyphens; use underscores
pkgrel="${_yams_release:-1}"
_yams_build_dir="build/pkg-makepkg-${CARCH}"
pkgdesc="Yet Another Memory System — persistent content-addressed memory for LLMs"
arch=(x86_64 aarch64)
url="https://github.com/trvon/yams"
license=(GPL-3.0-or-later)
makedepends=(
base-devel
clang
cmake
meson
ninja
python
python-pip
ccache
git
zip
pkgconf
liburing
libarchive
taglib
sqlite
openssl
curl
protobuf
boost
lld
)
# Third-party libraries are linked statically from the Conan build; the
# installed binaries and plugins only need libstdc++/libgcc_s/libc/libm.
depends=(
gcc-libs
glibc
)
optdepends=(
'onnxruntime: use the system ONNX Runtime instead of the bundled copy'
)
install=yams.install
source=("${pkgname}-${pkgver}.tar.gz::${_yams_git_source:-git+${url}}")
sha256sums=('SKIP')
build() {
cd "${srcdir}/yams"
# Use Conan + Meson (same flow as Debian/Fedora builds)
if ! command -v conan >/dev/null 2>&1; then
python -m venv /tmp/yams-conan-venv
source /tmp/yams-conan-venv/bin/activate
pip install --upgrade 'conan<3' meson ninja
fi
export PATH="${HOME}/.local/bin:${PATH}"
# Configure Conan
conan profile detect --force 2>/dev/null || true
cp .conan/global.conf "${HOME}/.conan2/global.conf" 2>/dev/null || true
# Build using setup.sh flow
export YAMS_CONAN_HOST_PROFILE="./conan/profiles/host-linux-clang"
export YAMS_CONAN_ARCH="$(uname -m)"
export YAMS_BUILD_DIR="${_yams_build_dir}"
export YAMS_ENABLE_MOBILE_BINDINGS=false
export YAMS_EXTRA_MESON_FLAGS="-Dyams-version=${_pkgver} -Dwerror=false -Dwarning_level=2"
export YAMS_INSTALL_PREFIX="/usr"
export CC=clang
export CXX=clang++
bash ./setup.sh Release --with-onnx
# Source Conan build env for meson compile compatibility
local conan_env=""
for candidate in \
"${_yams_build_dir}/build-release/conan/conanbuild.sh" \
"${_yams_build_dir}/conan/conanbuild.sh"; do
if [ -f "$candidate" ]; then
conan_env="$candidate"
break
fi
done
if [ -n "$conan_env" ]; then
set +u
source "$conan_env"
set -u
fi
meson compile -C "${_yams_build_dir}"
}
package() {
cd "${srcdir}/yams"
# Source Conan build env
local conan_env=""
for candidate in \
"${_yams_build_dir}/build-release/conan/conanbuild.sh" \
"${_yams_build_dir}/conan/conanbuild.sh"; do
if [ -f "$candidate" ]; then
conan_env="$candidate"
break
fi
done
if [ -n "$conan_env" ]; then
set +u
source "$conan_env"
set -u
fi
# Install into pkgdir (makepkg provides $pkgdir)
meson install -C "${_yams_build_dir}" --destdir "${pkgdir}" --no-rebuild
# Strip the staged binaries (the install rules already stage only the runtime set)
bash scripts/split-debug-symbols.sh "${pkgdir}/usr"
# Install the systemd user unit + user preset
install -Dm644 packaging/systemd/yams-daemon.service \
"${pkgdir}/usr/lib/systemd/user/yams-daemon.service"
install -Dm644 packaging/systemd/80-yams.preset \
"${pkgdir}/usr/lib/systemd/user-preset/80-yams.preset"
# Install license
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}