# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Kevin MacMartin <prurigro@gmail.com>
# Contributor: openfbt
# Contributor: Werecat
# Contributor: Xyne

pkgname=cjdns
pkgver=20.3
pkgrel=1
pkgdesc='Routing engine designed for security, scalability, speed and ease of use'
url='https://github.com/cjdelisle/cjdns'
arch=('x86_64')
license=('GPL3')
depends=('glibc' 'sh')
optdepends=('nodejs: optional utilities support')
makedepends=('nodejs' 'python2')
install=cjdns.install
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/cjdelisle/${pkgname}/archive/cjdns-v${pkgver}.tar.gz)
sha256sums=('e8ca2cc5d5ba71e39a702299106dd2a965005703284cec91b3e94691cdce6f65')
sha512sums=('ae38b33b47a567893e63bc925c91d07b5554f0c7147f90429cac41cfe35a429f507e3adc9463175a1714140169eaae370ab8c8255e82ddd9b2b32f09adae1cea')

build() {
  cd ${pkgname}-${pkgname}-v${pkgver}
  # Pretend to be cross compiling so -march=native is not set.
  CROSS="true" CJDNS_RELEASE_VERSION="${pkgver}" \
    node ./node_build/make.js
}

package() {
  cd ${pkgname}-${pkgname}-v${pkgver}
  install -Dm 755 cjdroute -t "${pkgdir}/usr/bin"
  install -Dm 644 contrib/systemd/{cjdns,cjdns-resume}.service \
    -t "${pkgdir}/usr/lib/systemd/system"
  install -Dm 644 doc/man/cjdroute.conf.5 -t "${pkgdir}/usr/share/man/man5"
  install -Dm 644 -t "${pkgdir}/usr/share/doc/${pkgname}" \
    README.md \
    doc/admin-api.md \
    doc/configure.md \
    doc/djc_layer_model.md \
    doc/nat-gateway.md \
    doc/network-services.md \
    doc/non-root-user.md \
    doc/security_specification.md \
    doc/shorewall_and_vpn_gateway_howto.md \
    doc/tunnel.md
  cp -a tools "${pkgdir}/usr/lib/${pkgname}"
  cp -a node_modules "${pkgdir}/usr/lib/${pkgname}/node_modules"
}

# vim: ts=2 sw=2 et:
