summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 465e61a8e3293aaf77b5cad5ff8889fb8dd24e82 (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
# Maintainer: devome <evinedeng@hotmail.com>

_pkgname=qBittorrent-ClientBlocker
pkgname="${_pkgname,,}"
pkgver=3.5
pkgrel=1
pkgdesc="A client blocker compatible with qBittorrent/Transmission (Beta)/BitComet (Beta, Partial) which is prohibited to include but not limited to clients such as Xunlei."
arch=('i686' 'pentium4' 'x86_64' 'arm' 'armv7h' 'armv6h' 'aarch64' 'riscv64')
url="https://github.com/Simple-Tracker/qBittorrent-ClientBlocker"
license=("MIT")
backup=("etc/${pkgname}/blockList.json"
        "etc/${pkgname}/config.toml"
        "etc/${pkgname}/ipBlockList.txt")
makedepends=("go")
optdepends=('qbittorrent-nox: downloader'
            'transmission-cli: downloader'
            'bitcomet: downloader')
provides=("${pkgname}")
conflicts=("${pkgname}")
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/${pkgver}.tar.gz"
        "${pkgname}.service"
        "${pkgname}.sysusers"
        "${pkgname}.tmpfiles"
        "${pkgname}.user.service")
sha256sums=('2cc22b81ca20caa2df1d778802cec27e66ad2132b5b2763850be027efee362f7'
            'c30c581577715838254ae7a5a07cd29df2fd75b9b59aefdb834906c5556f444e'
            'b419f001a0e45fa19776cd255170fd12ac19dc878683a98006ff53a6984bf417'
            '57f5a17c4a36b8fed9503e2ed1b6b60b43cd9f10fa249807a084de5744d7aed2'
            '6a136341031208f12adf1fc7a711f1f5af7519bd00635616b267c50f0a8eb843')

prepare() {
    cd "${_pkgname}-${pkgver}"
    cp -f config.toml config-user.sample.toml
    sed -e "s|logPath = \"logs\"|logPath = \"/var/log/qbittorrent-clientblocker\"|" \
        -i config.toml
    sed -e "s|logToFile = true|logToFile = false|" \
        -e "s|checkUpdate = true|checkUpdate = false|" \
        -i config.toml config-user.sample.toml
}

build() {
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    local ldflags="-s -w -linkmode external -X main.programVersion=${pkgver} -extldflags '${LDFLAGS}'"

    cd "${_pkgname}-${pkgver}"
    go build -trimpath -ldflags="${ldflags}" -o "${pkgname}" .
}

package() {
    install -Dm644 "${pkgname}.service"      "${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
    install -Dm644 "${pkgname}.sysusers"     "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
    install -Dm644 "${pkgname}.tmpfiles"     "${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf"
    install -Dm644 "${pkgname}.user.service" "${pkgdir}/usr/lib/systemd/user/${pkgname}.service"

    cd "${_pkgname}-${pkgver}"
    install -Dm755 "${pkgname}"              "${pkgdir}/usr/bin/${pkgname}"
    install -Dm644 "config.toml"             "${pkgdir}/etc/${pkgname}/config.toml"
    install -Dm644 "config-user.sample.toml" "${pkgdir}/usr/share/${pkgname}/config-user.sample.toml"
    install -Dm644 "blockList.json"          "${pkgdir}/etc/${pkgname}/blockList.json"
    install -Dm644 "blockList.json"          "${pkgdir}/usr/share/${pkgname}/blockList.json"
    install -Dm644 "ipBlockList.txt"         "${pkgdir}/etc/${pkgname}/ipBlockList.txt"
    install -Dm644 "ipBlockList.txt"         "${pkgdir}/usr/share/${pkgname}/ipBlockList.txt"
    install -Dm644 "LICENSE"                 "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    install -Dm644 README*.md             -t "${pkgdir}/usr/share/doc/${pkgname}"
}