summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 98bbf5f16b9cf51220f335f705d2234c23e057df (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
# Maintainer: Carl Smedstad <carl.smedstad at protonmail dot com>

pkgname=transqlate
pkgver=0.1
pkgrel=1
pkgdesc="Transpile SQL snippet from a dialect to another using an AST"
arch=(x86_64)
url="https://gitlab.com/dalibo/transqlate"
license=(PostgreSQL)
makedepends=(go)
depends=(glibc)
source=("$url/-/archive/v$pkgver/$pkgname-v$pkgver.tar.gz")
sha256sums=('f154b7f71ff065c242d09cc5e9aafc0e1599142b5c49db6ace62c32c5e3515c8')

_archive="$pkgname-v$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"
  # shellcheck disable=2153
  export CGO_LDFLAGS="$LDFLAGS"
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"

  local ldflags="-linkmode=external -X 'main.version=$pkgver'"
  go build -v -buildvcs=false -ldflags "$ldflags"
}

check() {
  cd "$_archive"

  go test -v ./...
}

package() {
  cd "$_archive"

  install -Dm755 transqlate "$pkgdir/usr/bin/transqlate"

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