#

pkgname=planisphere-tools
pkgver=1.11.5
pkgrel=1
pkgdesc='Planisphere Report is an Open Source tool you can use for meeting the Endpoint Management policy.'
arch=(i686 x86_64 armv7h aarch64)
url="https://gitlab.oit.duke.edu/devil-ops/planisphere-tools"
license=('LGPL-2.0-or-later')
makedepends=(git go)
source=("git+https://gitlab.oit.duke.edu/devil-ops/planisphere-tools.git#tag=v${pkgver}"
        0001-trim-down.patch
        planisphere-report.service
        planisphere-report.timer
        planisphere-report.yaml)
sha256sums=('0602f91d8cc11c4e327720e9c955da6f29dffbcae64a1b3788d1c694a8ae9fb2'
            'daa04abbc1c23aad687782c765d1160f3713988faf265e379814054612a6bd2b'
            '57f126582c9cd213e496ad37334f417fe704ed30234c4f5da550cf6633c68985'
            '8d3b75a5720121b2a66a84a29d93d0207d45ad8e87f8b145ce9fe7a4172fb231'
            'a7d59f231a28e7260e6f56f0015aa99495401f350e886083b74d3a076f8397bb')
backup=(etc/planisphere-report.yaml)

pkgver() {
  cd planisphere-tools

  git describe --tags | sed -e 's/^[^0-9]*//' -e 's/-/.0./' -e 's/-/./g'
}

prepare() {
  cd planisphere-tools

  patch -Np1 < ../0001-trim-down.patch
}

build() {
  cd planisphere-tools/planisphere-report-go

  GOPATH="$srcdir" go build -o planisphere-report ./cli
}

package() {
  install -Dm 644 planisphere-report.service \
          "$pkgdir"/usr/lib/systemd/system/planisphere-report.service
  install -Dm 644 planisphere-report.timer \
          "$pkgdir"/usr/lib/systemd/system/planisphere-report.timer
  install -Dm 644 planisphere-report.yaml \
          "$pkgdir"/etc/planisphere-report.yaml

  install -Dm 755 planisphere-tools/planisphere-report-go/planisphere-report \
          "$pkgdir"/usr/bin/planisphere-report
}
