# Maintainer    : Eric Vidal <eric@obarun.org>
# Maintainer    : Jean-Michel T.Dydak <jean-michel@obarun.org>
# Obarun PkgSrc : https://git.obarun.org/obarun-pkgbuild-extra/ntp
#----------------
# Maintainer    : Lukas Fleischer <lfleischer@archlinux.org>
# Contributor   : Gaetan Bisson <bisson@archlinux.org>
# Contributor   : kevin <kevin@archlinux.org>
# Arch PkgSrc   : https://www.archlinux.org/packages/extra/x86_64/ntp
#----------------
# Website       : http://www.ntp.org
#--------------------------------------------------------------------------------------

pkgname=ntp
pkgver=4.2.8p15
pkgrel=2
pkgdesc="Network Time Protocol reference implementation"
arch=('x86_64')
url="https://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2"
license=('CUSTOM')

source=("${url}/${pkgname}-${pkgver}.tar.gz"
    'ntp.conf'
    'ntp.sysusers.conf')

install=ntp.install

conflicts=(
    'openntpd')

backup=(
    'etc/ntp/ntp.conf')

options=(
    '!emptydirs')
    
depends=(
    'openssl'
    'libcap'
    'libedit')

#--BUILD CONTROL-----------------------------------------------------------------------

path=(
    --prefix=/usr
    --libexecdir=/usr/libexec/ntp
    --sysconfdir=/etc/ntp
)

flags=(
    --enable-linuxcaps
    --enable-ntp-signd
)

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

    ./configure "${path[@]}" "${flags[@]}"
    make
}

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

    make DESTDIR="${pkgdir}" install

    install -Dm644 ../ntp.conf "${pkgdir}"/etc/ntp/ntp.conf
    install -Dm644 ../ntp.sysusers.conf "${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"
}

#--------------------------------------------------------------------------------------
sha512sums=('afbdbb8a37b8f4040a8a6939a3a85ad0350d359c153c297b32b8a013c7b7061fd925fa3e6e103671c5901e169156e22497813c654195ba50f890a7170b2f2075'
            '308c8ba6ad7647bb5736690fb0919b158fdaea8939c1b1e3a73f510dc6680d5653e563f76bf3a4991b167716339cecd82233d494ecf9703da5601687a3d88453'
            '177b06591f809838765327fd5aa14f98d347f3bea31c5807bf3a6ec55e41013198c7595d619b78d9b9aa0592e32c0419f248c51b36b99ec121d75dc40ac9e1ee')
