#!/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=opensysusers
pkgver=0.4.8
pkgrel=06
pkgdesc='a standalone utility for handling systemd-style users and groups'
#url='https://github.com/artix-linux/opensysusers'
groups=('jobbot')
depends=('glibc' 'shadow' 'util-linux')
makedepends=('docbook-xsl')
conflicts=(obsysusers)
provides=(sysusers)
source=("${pkgname}-${pkgver}".tar.gz::https://github.com/artix-linux/"${pkgname}"/archive/"${pkgver}".tar.gz
        sysusers.hook
        sysusers-hook)

sha256sums=('SKIP'
            '7d08a26bfaff4f3c63580495a6afdc4ebf2afaf4c2e6d50a118529f035c6d115'
            '6a23fa4fbd57a14e0d9c0d4c6e93fd18de41b1429245278873dff5103651f4dd')

pkgver() {
  printf "${pkgver}"
}

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

  make PREFIX=/usr
}

package() {
  cd "${pkgname}-${pkgver}"

  make PREFIX=/usr DESTDIR="${pkgdir}" install install-man
# In case somewhere is missed and a package specifically instructs the
# use of systemd-sysusers we link to our own sysusers which functions the same
# We may have to do this for obsysusers and build it on our own as it appears it
# doesn't provide this link, which may effectively miss some sysusers configuration
  ln -s "/usr/bin/sysusers" "${pkgdir}/usr/bin/systemd-sysusers"

  install -d -m 755 "${pkgdir}"/etc/sysusers.d
  install -d -m 755 "${pkgdir}"/usr/lib/sysusers.d

  install -D -m 644 "${srcdir}"/sysusers.hook "${pkgdir}"/usr/share/libalpm/hooks/sysusers.hook
  install -D -m 755 "${srcdir}"/sysusers-hook "${pkgdir}"/usr/share/libalpm/scripts/sysusers-hook

  install -D -m 644 LICENSE "${pkgdir}"/usr/share/licenses/"${pkgname}"/LICENSE
#  This is the same document found in obsysusers with the words systemd removed and renamed sysusuers.html
  mv $pkgdir/usr/share/doc/opensysusers/systemd-sysusers.html $pkgdir/usr/share/doc/opensysusers/sysusers.html
#  rm -rf "${pkgdir}/usr/share/man/man8"
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=('BSD')

sha256sums=(4d1bf4657e8a2420d8dcf8da63f86809e3f023603a0940b86e4d10d0f42a0720 # opensysusers-0.4.8.tar.gz
	69733b608efa7a3cbd3fac0daa0e7ba2ffdf50ec535223a04127cb96def6cb57 # sysusers.hook
	d0add2ecae5619113640a454bd545e7317e3e7f72702b3f8b995322147fd2b16) # sysusers-hook

##  595ea40654478382438961198f788aebc6fba2bdfb7e7c10a68639ed5ec3321f  opensysusers-0.4.8-06-x86_64.pkg.tar.lz
