summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ad6fef42312c6577413c8c9ff78390532b0e8564 (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: Henry-ZHR <henry-zhr@qq.com>
_pkgname=v2dat
pkgname=${_pkgname}-git
pkgver=r2.47b8ee5
pkgrel=1
pkgdesc="A cli tool that can unpack v2ray data packages"
arch=('x86_64' 'armv7h' 'aarch64')
url="https://github.com/urlesistiana/v2dat"
license=('GPL-3.0-only')
depends=('glibc')
makedepends=('git' 'go')
conflicts=(${_pkgname})
provides=(${_pkgname})
source=("${_pkgname}::git+${url}.git")
sha512sums=('SKIP')

pkgver() {
  cd "${_pkgname}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
}

prepare() {
  mkdir -p "${_pkgname}/build"
}

build() {
  cd "${_pkgname}/build"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  go build \
    -o "${_pkgname}" \
    -v \
    -buildmode=pie \
    -trimpath \
    -ldflags="-linkmode external -s -w" \
    -mod=readonly \
    -modcacherw \
    ../
  go run ../ completion bash >bash-completion
  go run ../ completion zsh >zsh-completion
}

package() {
  cd "${srcdir}/${_pkgname}/build"
  install -Dm755 "${_pkgname}" "${pkgdir}/usr/bin/${_pkgname}"
  install -Dm644 bash-completion "${pkgdir}/usr/share/bash-completion/completions/${_pkgname}"
  install -Dm644 zsh-completion "${pkgdir}/usr/share/zsh/site-functions/_${_pkgname}"
}