summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: db6f80465bbdf87caccd695a4debd1d8ba07b43c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Maintainer: Carl Smedstad <carl.smedstad at protonmail dot com>
# Contributor: Radoslaw Mejer <radmen@radmen.info>

pkgname=jd-tool
_pkgname=jd
pkgver=1.8.1
pkgrel=1
pkgdesc="JSON diff and patch"
arch=(x86_64 aarch64)
url="https://github.com/josephburnett/jd"
license=(MIT)
depends=(glibc)
makedepends=(go)
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('40635f27543f91e656b902b94a2d6e9f4ed627b940484ad59b18fc7fe458f4a9')

_archive="$_pkgname-$pkgver"

prepare() {
  cd "$_archive"

  # Avoid downloading Go dependencies in build() by doing it here instead
  go mod download -x
}

build() {
  cd "$_archive"

  export CGO_CPPFLAGS="$CPPFLAGS"
  export CGO_CFLAGS="$CFLAGS"
  export CGO_CXXFLAGS="$CXXFLAGS"
  export CGO_LDFLAGS="$LDFLAGS"
  export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"

  go build -v -buildvcs=false
}

check() {
  cd "$_archive"

  local unit_tests=$(
    go list ./... \
      | grep -v github.com/josephburnett/jd/web/ui \
      | sort
  )
  # shellcheck disable=2086
  go test $unit_tests
}

package() {
  cd "$_archive"

  install -Dm755 -t "$pkgdir/usr/bin" jd
  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}