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

pkgname=ntp
_pkgname=ntp #-dev
_pkgver=4.2.8p15
pkgver=${_pkgver/p/.p}
pkgrel=02
pkgdesc='Network Time Protocol reference implementation w/o ipv6 & systemd'
url='http://www.ntp.org/'
arch=('x86_64')
source=("https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/${_pkgname}-${_pkgver}.tar.gz"
        'ntp-4.2.8_p15-glibc-2.34.patch'
        'ntp.conf'
#        'ntpd.service'
#        'ntpdate.service'
        'ntp.sysusers')
options=('!emptydirs')

#depends=(openssl perl libcap libedit)
depends=(openssl libcap libedit)
conflicts=(openntpd)
backup=(etc/ntp/ntp.conf etc/ntp.conf)
install=ntp.install

prepare() {
	cd "${srcdir}/${_pkgname}-${_pkgver}"
	patch -Np1 -i ../ntp-4.2.8_p15-glibc-2.34.patch
}

build() {
	cd "${srcdir}/${_pkgname}-${_pkgver}"

	./configure  --prefix=/usr \
		 --libexecdir=/usr/lib \
		 --enable-linuxcaps \
		 --disable-systemd \
		 --disable-ipv6 \
		 --enable-ntp-signd \
		 --disable-thread-support
	make
}

package() {
	cd "${srcdir}/${_pkgname}-${_pkgver}"

	make DESTDIR="${pkgdir}" install

	install -Dm644 ../ntp.conf "${pkgdir}"/etc/ntp.conf
#	install -Dm644 ../ntpd.service "${pkgdir}"/usr/lib/systemd/system/ntpd.service
#	install -Dm644 ../ntpdate.service "${pkgdir}"/usr/lib/systemd/system/ntpdate.service
	install -Dm644 ../ntp.sysusers "${pkgdir}"/usr/lib/sysusers.d/ntp.conf
	install -Dm644 COPYRIGHT "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

	install -d -o 87 -g 87  "${pkgdir}"/var/lib/ntp
	echo > "${pkgdir}/var/lib/ntp/.placeholder"
}

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

license=('custom')

sha256sums=(f65840deab68614d5d7ceb2d0bb9304ff70dcdedd09abb79754a87536b849c19  # ntp-4.2.8p15.tar.gz
	1809cd2be7ce7d16a3321f84cc469024624db70806c7229071cfa7951e8b4770  # ntp-4.2.8_p15-glibc-2.34.patch
	abccefe0b3a65cd375d5071ce780be8d2d205439aa6d34bcd3c56de6e80ba821  # ntp.conf
	f839a3b6d8e64fcd9332274131b4d5aa0b2c272db072dc310af1735ef286746a) #  ntp.sysusers
 
 
