summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1d0634dfcc8306117723ca5669bed8b528615f7c (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
# Contributor: taotieren <admin@taotieren.com>

pkgname=cloudflarespeedtest-git
pkgver=2.2.5.6.g176271d
pkgrel=1
pkgdesc="「自选优选 IP / 过滤假墙」测试 Cloudflare CDN 延迟和速度,获取最快 IP (IPv4+IPv6)! "
arch=(aarch64
    riscv64
    x86_64)
url="https://github.com/XIU2/CloudflareSpeedTest"
license=('GPL-3.0-only')
provides=(${pkgname%-git})
conflicts=(${pkgname%-git})
#replaces=(${pkgname})
depends=(go)
optdepends=()
makedepends=('git')
backup=()
options=()
#install=${pkgname}.install
source=("${pkgname%-git}::git+${url}.git")
sha256sums=('SKIP')

pkgver() {
    cd "${srcdir}/${pkgname%-git}"
    git describe --tags | sed 's/^v//;s/-/./g'
}

prepare() {
    cd "${srcdir}/${pkgname%-git}"
    go mod tidy
    mkdir -p build/
}

build() {
    cd "${srcdir}/${pkgname%-git}"
    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 -o build
}

package() {
    cd "${srcdir}/${pkgname%-git}"

    install -Dm0755 build/CloudflareSpeedTest "${pkgdir}"/usr/share/${pkgname%-git}/${pkgname%-git}
    install -Dm0755 script/cfst_hosts.sh "${pkgdir}"/usr/share/${pkgname%-git}/cfst-hosts
    cp -rv *.txt "${pkgdir}"/usr/share/${pkgname%-git}/
    install -Dm0644 "${srcdir}/${pkgname%-git}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname%-git}/LICENSE"
    install -Dm0755 /dev/stdin "${pkgdir}/usr/bin/CloudflareST" << EOF
#!/bin/sh

cd /usr/share/${pkgname%-git}/
./${pkgname%-git} "\$@"

EOF
    ln -sf /usr/share/${pkgname%-git}/cfst-hosts "${pkgdir}"/usr/bin/cfst-hosts
}