summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 87ed14d9d07bf6cf5231282959a46cc6c182373f (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=octosql
pkgver=0.13.0
pkgrel=1
pkgdesc='A CLI tool which lets you query a plethora of databases and file formats using SQL'
arch=('x86_64')
url='https://github.com/cube2222/octosql'
license=('MPL-2.0')
depends=('glibc')
makedepends=('git' 'go')
options=('!lto')
_commit='ca4ac3f1c9b65e5639bd9a46826ae7305d57f008'
source=("$pkgname::git+$url.git#tag=v${pkgver}")
b2sums=('800c8ec3b32ff5f9706d5362ed577d21b5a158039caf18dca34dd5d0367e5a5c7428113233d66ccbca1cca9383a3dfb3fe496f0f4fcc62619fc6a35f9ff411f8')

pkgver() {
  cd "$pkgname"

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

prepare() {
  cd "$pkgname"

  # create directory for build output
  mkdir build

  # download dependencies
  go mod download
}

build() {
  cd "$pkgname"

  # set Go flags
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"

  # binary
  go build -v \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-linkmode external -extldflags ${LDFLAGS} \
    -X github.com/cube2222/octosql/cmd.VERSION=$pkgver" \
    -o build \
    .

  # generate shell completions
  for shell in bash fish zsh; do
    ./build/octosql completion "$shell" > "build/$shell.completion"
  done
}

check() {
  cd "$pkgname"

  go test -v ./...
}

package() {
  cd "$pkgname"

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" build/octosql

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md

  # shell completions
  install -vDm644 build/bash.completion "$pkgdir/usr/share/bash-completion/completions/$pkgname"
  install -vDm644 build/fish.completion "$pkgdir/usr/share/fish/vendor_completions.d/$pkgname.fish"
  install -vDm644 build/zsh.completion "$pkgdir/usr/share/zsh/site-functions/_$pkgname"
}