summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4a2ae8a3968245a290128873522d870b21406433 (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
# Maintainer: sukanka <su975853527 at gmail dot com>

pkgname=clash-meta
pkgver=1.18.5
pkgrel=3
pkgdesc="Another Clash Kernel by MetaCubeX"
arch=('x86_64' 'aarch64' 'riscv64' 'loong64')
url="https://github.com/MetaCubeX/Clash.Meta"
license=("GPL3")
depends=('glibc' 'clash-geoip')
makedepends=('go')
conflicts=(clash-meta)
backup=('etc/clash-meta/config.yaml')
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz"
        "clash-meta.service"
        "clash-meta@.service"
        "${pkgname}.sysusers"
        "${pkgname}.tmpfiles"
)
sha256sums=('498c1667c78ffab2301788a2776f4477e38a49c4c4f4661430cc10e2478dae3a'
            'b6b7ce11489a6f6322a41ce840b3f999b1ec88914f8bd6864c220269231bf759'
            'ec4de877464e595124a5f2752c3f4be157adc85ec5f7f8392c0331cb70fc906a'
            '655e8e2edcd82a6bdf2fd12430b7ab6f8e32db8dffce70e7342685a7cc65ebfb'
            '50737592c7bd743fe8f543924034718337477a203fa11ef4272cae496df3769c')

prepare(){
    cd "${srcdir}"
    mv mihomo-${pkgver} Clash.Meta-${pkgver}
    cd Clash.Meta-${pkgver}
    sed -i 's|^const.*|const Name = "clash"|g' constant/path.go
}
build(){
    cd "${srcdir}"/Clash.Meta-${pkgver}
    BUILDTIME=$(date -u)
    NAME=clash-meta
    GOOS=linux CGO_ENABLED=1 go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-linkmode external -extldflags '${LDFLAGS}' \
    -X 'github.com/metacubex/mihomo/constant.Version=${pkgver}' \
    -X 'github.com/metacubex/mihomo/constant.BuildTime=${BUILDTIME}' \
    " \
    -tags with_gvisor -o ${pkgname}-${pkgver}
}
package() {
    cd "${srcdir}"/Clash.Meta-${pkgver}
    install -Dm755 "${pkgname}-${pkgver}" "${pkgdir}/usr/bin/clash-meta"
    install -Dm644 "docs/config.yaml" -t "${pkgdir}/etc/clash-meta"
    cd $srcdir
    install -Dm644 ${pkgname}.sysusers "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
    install -Dm644 ${pkgname}.tmpfiles "${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf"
    install -Dm644 "clash-meta.service"  -t "${pkgdir}/usr/lib/systemd/system"
    install -Dm644 "clash-meta@.service" -t "${pkgdir}/usr/lib/systemd/system"
    ln -sf /etc/clash/Country.mmdb ${pkgdir}/etc/${pkgname}/Country.mmdb
    #geosite.dat from community repo does not work
    # ln -sf /usr/share/v2ray/geosite.dat ${pkgdir}/etc/${pkgname}/GeoSite.dat
}