# Maintainer (Manjaro): artoo <artoo@manjaro.org>
# Contributor (Manjaro): williamh <williamh@gentoo.org>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Contributor: Luke Shumaker <lukeshu@parabola.nu>

# Gentoo's ebuild file:
# https://gitweb.gentoo.org/repo/gentoo.git/tree/net-misc/netifrc/netifrc-0.6.1.ebuild
pkgname=netifrc
pkgver=0.6.1
pkgrel=1
pkgdesc="Gentoo Network Interface Management Scripts"
arch=('any')
url="https://wiki.gentoo.org/wiki/Netifrc"
license=('BSD2')
groups=('base-openrc')
depends=('gentoo-functions' 'openrc>=0.15' 'udev-init-scripts')
conflicts=('udev<172' 'udev-init-scripts<27')
makedepends=('git')
backup=('etc/conf.d/net')
validpgpkeys=('A28BEDE08F1744E16037514806C4536755758000') # Jason A. Donenfeld <zx2c4@gentoo.org>
source=("git://anongit.gentoo.org/proj/${pkgname}.git?signed#tag=${pkgver}")
sha256sums=('SKIP')

_makeargs=(
  SYSCONFDIR=/etc
  PREFIX=/usr
  SBINDIR=/usr/bin
  LIBEXECDIR="/usr/lib/${pkgname}"
)

build(){
    cd "$srcdir/$pkgname"
    make "${_makeargs[@]}"
}

package() {
    cd "$srcdir/$pkgname"

    make DESTDIR="$pkgdir" "${_makeargs[@]}" install
    
    install -Dm0644 doc/net.example "$pkgdir/etc/conf.d/net"

    install -d "$pkgdir/etc/runlevels/boot"
    ln -sT "/etc/init.d/net.lo" "$pkgdir/etc/runlevels/boot/net.lo"

    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
