summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 67bc03ced07790b17a64a3852d764dfb2a0190c5 (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
# Maintainer: João Vitor S. Anjos <jvanjos at protonmail dot com>
# Contributor: George Rawlinson <grawlinson@archlinux.org>

pkgname=tern
pkgver=2.2.3
pkgrel=1
pkgdesc='A standalone migration tool for PostgreSQL'
arch=('x86_64' 'aarch64')
url='https://github.com/jackc/tern'
license=('MIT')
depends=('glibc')
makedepends=('git' 'go')
optdepends=('postgresql: for local instance of PostgreSQL')
options=('!lto')
_commit='5e38057652b28acbdaafdb2e6604b1e856f31aad'
source=("$pkgname::git+$url.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  mkdir -p build
  go mod download
}

build() {
  cd "$pkgname"

  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 -o build .
}

package() {
  cd "$pkgname"

  install -Dm755 -t "$pkgdir/usr/bin" build/tern

  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
  install -Dm644 -t "$pkgdir/usr/share/doc/$pkgname" README.markdown
}