summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 082c24ad3651ebae5eb0b5c2e586219865f88944 (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: zxp19821005 <zxp19821005 at 163 dot com>
# Maintainer: fow0ryl <henning.ryll at web dot de>
pkgname=zoraxy-git
pkgver=3.1.7.r3.g2769558
pkgrel=1
pkgdesc='A general purpose HTTP reverse proxy and forwarding tool.'
arch=('any')
url="https://zoraxy.aroz.org/"
_ghurl="https://github.com/tobychui/zoraxy"
license=('AGPL-3.0-only')
provides=("${pkgname%-git}=${pkgver%.r*}")
conflicts=("${pkgname%-git}")
depends=()
makedepends=(
    'git'
    'go'
)
source=(
    "${pkgname//-/.}::git+${_ghurl}.git"
    "${pkgname%-git}.service"
)

sha256sums=('SKIP'
            'e38e83de069d7f79d3172e85d4b6577457909804fecb8146aacbe59c6cbf6c57')
pkgver() {
    cd "${srcdir}/${pkgname//-/.}"
    set -o pipefail
    git describe --long --tags --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/v//g' ||
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
}
prepare() {
    export CGO_ENABLED=1
    export GO111MODULE=on
    export GOOS=linux
    export GOCACHE="${srcdir}/go-build"
    export GOMODCACHE="${srcdir}/go/pkg/mod"
    if [[ "$(curl -s ipinfo.io/country)" == *"CN"* ]]; then
        export GOPROXY=https://goproxy.cn,direct
    fi
}
build() {
    cd "${srcdir}/${pkgname//-/.}/src"
    go mod tidy
    go build
}
package() {
    install -Dm755 "${srcdir}/${pkgname//-/.}/src/${pkgname%-git}" -t "${pkgdir}/usr/lib/${pkgname%-git}"
    install -Dm755 -d "${pkgdir}/usr/bin"
    ln -sf "/usr/lib/${pkgname%-git}/${pkgname%-git}" "${pkgdir}/usr/bin/${pkgname%-git}"
    install -Dm644 "${srcdir}/${pkgname%-git}.service" -t "${pkgdir}/usr/lib/systemd/system"
}