#!/usr/bin/env beesh

# BEE_VERSION unbound-1.13.1-1

# SRCURL[0]="https://www.unbound.net/downloads/unbound-${PKGVERSION}.tar.gz"
SRCURL[0]="https://beehive.molgen.mpg.de/0cd660a40d733acc6e7cce43731cac62/unbound-1.13.1.tar.gz"

# PATCHURL+=()

# build_in_sourcedir

# sourcesubdir_append src

#mee_extract() {
#    bee_extract "${@}"
#}

#mee_patch() {
#    bee_patch "${@}"
#}

mee_configure() {
    bee_configure \
        --disable-static \
        --enable-systemd \
        --with-pidfile="/run/unbound.pid" \
        --with-rootkey-file="/var/lib/unbound/root.key"
}

mee_build() {
    bee_build
    ln -sf ${S}/testdata ${B}/testdata
    start_cmd make check
}

#mee_install() {
#    bee_install
#}
## by default this may be 'make install DESTDIR="${D}"'

mee_install_post() {
    start_cmd mv ${D}/etc/unbound/unbound.conf{,.sample}
    start_cmd install -m 644 -D -t ${D}/lib/systemd/system ${B}/contrib/unbound.{service,socket}

#    start_cmd sed -i '/^ReadWritePaths=/ s,$, /var/lib/unbound,' ${B}/contrib/unbound.service
#    start_cmd install -o unbound -m 755 -d ${D}/var/lib/unbound
}