diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..fa92fbe --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,67 @@ +# Maintainer: James Brechtel +# Contributor: James Brechtel + +pkgname=converge +_pkgver=0.1.0.0 +pkgver=${_pkgver//-/_} +pkgrel=1 +pkgdesc="Auto-sync git repositories by watching for changes, committing, pulling, and pushing" +arch=('x86_64') +url="https://github.com/jbrechtel/converge" +license=('BSD') +makedepends=('stack' 'git') +depends=('git' 'libnotify' 'gcc-libs') +optdepends=('converge-relay: realtime push notifications via SSE relay server') +backup=('etc/converge/config.example.yaml') +source=( + "converge.service" + "converge.example.yaml" +) +md5sums=( + 'SKIP' + 'SKIP' +) + +build() { + cd "$startdir" + + # Use pre-built binary if available (e.g. from scripts/build), otherwise build from source + if [[ -x build/converge ]]; then + msg "Using pre-built binary from build/converge" + install -Dm755 build/converge "$srcdir/bin/converge" + else + export STACK_ROOT="$srcdir/.stack-root" + msg "Building converge with stack (resolver: $(awk '/^resolver:/ {print $2}' stack.yaml))..." + stack build \ + --copy-bins \ + --local-bin-path "$srcdir/bin" \ + --ghc-options '-O2' + fi +} + +check() { + cd "$startdir" + export STACK_ROOT="$srcdir/.stack-root" + msg "Running tests..." + stack test +} + +package() { + cd "$startdir" + + # Binary + install -Dm755 "$srcdir/bin/converge" \ + "$pkgdir/usr/bin/converge" + + # User systemd service + install -Dm644 converge.service \ + "$pkgdir/usr/lib/systemd/user/converge.service" + + # Example config + install -Dm644 converge.example.yaml \ + "$pkgdir/etc/converge/config.example.yaml" + + # Documentation + install -Dm644 README.md \ + "$pkgdir/usr/share/doc/converge/README.md" +} diff --git a/scripts/build b/scripts/build index 2b1718e..66fc7cd 100755 --- a/scripts/build +++ b/scripts/build @@ -20,3 +20,15 @@ echo "Compressing with UPX..." ' echo "Done: $(ls -lh build/converge | awk '{print $5}')" + +# Build Arch Linux package (if makepkg is available) +if command -v makepkg &>/dev/null; then + echo "Building Arch package with makepkg..." + if makepkg -f 2>&1; then + echo "Package: $(ls -1 converge-*.pkg.tar.zst 2>/dev/null)" + else + echo "WARNING: makepkg failed (see above)" >&2 + fi +else + echo "Skipping package build (makepkg not found)" +fi diff --git a/scripts/makepkg b/scripts/makepkg new file mode 100755 index 0000000..39f20c5 --- /dev/null +++ b/scripts/makepkg @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Build an Arch Linux package for converge using makepkg. +# +# Usage: +# ./scripts/makepkg # Build the package (no install) +# ./scripts/makepkg -i # Build and install +# ./scripts/makepkg -s # Build and install missing deps +# +# The resulting .pkg.tar.zst will be placed in the project root. +set -euo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +makepkg -f "$@"