# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgname=pacrunner
pkgver=0.18
pkgrel=1
pkgdesc="Proxy configuration daemon"
arch=(x86_64)
url="https://git.kernel.org/pub/scm/network/connman/pacrunner.git"
license=(GPL2 LGPL2.1)
depends=(glib2 dbus curl)
makedepends=(git)
_commit=364ba8d09065067b71725f851a5bc624b9eb453b  # tags/0.18^0
source=("git+https://git.kernel.org/pub/scm/network/connman/pacrunner.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd $pkgname
  ./bootstrap
}

build() {
  cd $pkgname
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib \
    --with-dbusconfdir=/usr/share \
    --enable-pie \
    --enable-duktape \
    --enable-curl
  make
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install

  install -Dm644 /dev/stdin "$pkgdir/usr/lib/systemd/system/pacrunner.service" <<END
[Unit]
Description=Proxy configuration daemon
Before=network.target
Wants=network.target

[Service]
Type=dbus
BusName=org.pacrunner
ExecStart=/usr/bin/pacrunner

[Install]
WantedBy=multi-user.target
END

  install -Dm644 /dev/stdin "$pkgdir/usr/share/dbus-1/system-services/org.pacrunner.service" <<END
[D-BUS Service]
Name=org.pacrunner
Exec=/usr/bin/pacrunner
User=root
SystemdService=pacrunner.service
END
}

# vim:set sw=2 et:
