#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=dhcpcd
pkgver=9.4.1
pkgrel=01
pkgdesc="RFC2131 compliant DHCP client daemon w/o systemd"
url="https://roy.marples.name/projects/dhcpcd/"
arch=('x86_64')
depends=('glibc' 'sh' 'libeudev')
optdepends=('openresolv: resolvconf support')
provides=('dhcp-client')
backup=('etc/dhcpcd.conf')
install='dhcpcd.install'
options=('emptydirs')  # We Need the Empty /var/lib/dhcpcd Directory
source=("https://roy.marples.name/downloads/$pkgname/$pkgname-$pkgver.tar.xz"
#        "https://roy.marples.name/downloads/$pkgname/$pkgname-$pkgver.tar.xz.distinfo"
#        "https://roy.marples.name/downloads/$pkgname/$pkgname-$pkgver.tar.xz.distinfo.asc"
        dhcpcd.install
        dhcpcd.sysusers
        dhcpcd.tmpfiles)

curl "https://roy.marples.name/downloads/$pkgname/$pkgname-$pkgver.tar.xz.distinfo.asc" "$pkgname-$pkgver.tar.xz.distinfo.asc" -o "$pkgname-$pkgver.tar.xz.asc"
curl "https://roy.marples.name/downloads/$pkgname/$pkgname-$pkgver.tar.xz.distinfo.asc" "$pkgname-$pkgver.tar.xz.distinfo" -o "$pkgname-$pkgver.tar.xz.sha256"

# prepare () {
#   cd ${pkgname}-${pkgver}
# }

build() {
  cd ${pkgname}-${pkgver}

  # configure variables
  ./configure \
      --prefix=/usr \
      --sysconfdir=/etc \
      --sbindir=/usr/bin \
      --libexecdir=/usr/lib/dhcpcd \
      --dbdir=/var/lib/dhcpcd \
      --runstatedir=/run \
      --privsepuser=dhcpcd

  # Build
  make
}

check() {
  cd ${pkgname}-${pkgver}

  make test
}

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

  # Install License
  install -Dm644 "${srcdir}/${pkgname}-${pkgver}/LICENSE" \
	  "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  # Set Options in /etc/dhcpcd.conf
  echo noipv4ll >> "${pkgdir}/etc/dhcpcd.conf" # Disable ip4vall

  # install sysuser amd tmpfiles files
  install -Dm644 "${srcdir}/dhcpcd.sysusers" "${pkgdir}/usr/lib/sysusers.d/dhcpcd.conf"
  install -Dm644 "${srcdir}/dhcpcd.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/dhcpcd.conf"
}

#---- license gpg-key sha256sums ----

license=('BSD')

validpgpkeys=('A785ED2755955D9E93EA59F6597F97EA9AD45549')  # Roy Marples (NetBSD) <roy@NetBSD.org>

sha256sums=(819357634efed1ea5cf44ec01b24d3d3f8852fec8b4249925dcc5667c54e376c # dhcpcd-9.4.1.tar.xz
	d40d51367fcf7e9596e42cd2bab59404633bedbab4d0a3183e7246b4677937b7 # dhcpcd.install
	06788ad9f5f7ccb5d2a2da6f0322ff5771f8de82cfbe8b9ad954f2c38265e21b # dhcpcd.sysusers
	55d57b958f6b7e4d4a538ee88b0fcc1a522050c2d38efb5d680139f618234b35) # dhcpcd.tmpfiles


