summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b08ff1cbfb5de40426df982a73bbe91e47fb6466 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Maintainer: gao <gao66 at sdf dot org>

pkgname=iptv-sources-git
_pkgname=iptv-sources
pkgver=r226.136e01a
pkgrel=1
pkgdesc="Autoupdate iptv sources"
arch=('any')
url="https://github.com/GrandDuke1106/iptv-sources"
license=('GPL-3.0')
depends=('nodejs' 'pm2')
makedepends=('git' 'npm')
optdepends=('iptv-checker-rs-git: Checking links in IPTV playlists written in Rust')
install="$pkgname.install"
source=("git+$url.git#branch=main")
sha256sums=(SKIP)
backup=("etc/pm2/conf.d/${_pkgname}.json")


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

build() {
    cd "$srcdir/$_pkgname"
    mv yarn.lock yarn.lock.bak
    npm install
    npm run build
    npm run m3u
}

package() {
    cd "$srcdir/$_pkgname"
    install -d "$pkgdir/opt/iptv-sources-git"
    cp -a ./* "$pkgdir/opt/iptv-sources-git/"

    install -Dm0644 -t "$pkgdir/usr/share/licenses/${pkgname}" LICENSE

    rm -rf "$pkgdir/opt/iptv-sources-git/.git"

    install -d "$pkgdir/etc/pm2/conf.d/"
    cat <<EOF > "$pkgdir/etc/pm2/conf.d/${_pkgname}.json"
{
    "apps": [
        {
            "name": "${_pkgname}-serve",
            "script": "/opt/iptv-sources-git/dist/serve.js",
            "cwd": "/opt/iptv-sources-git/",
            "watch": false,
            "env": {
                "NODE_ENV": "production",
                "ROLLBACK_URLS": "",
                "CLOSE_SOURCE_PROXY": "",
                "CUSTOM_GITHUB_RAW_SOURCE_PROXY_URL": "",
                "ENABLE_IPTV_CHECKER": "false",
                "IPTV_CHECKER_URL": ""
            }
        },
        {
            "name": "${_pkgname}-m3u",
            "script": "npm",
            "args": "run m3u",
            "cwd": "/opt/iptv-sources-git/",
            "watch": false,
            "cron_restart": "0 */2 * * *",
            "autorestart": false,
            "env": {
                "NODE_ENV": "production",
                "ROLLBACK_URLS": "",
                "CLOSE_SOURCE_PROXY": "",
                "CUSTOM_GITHUB_RAW_SOURCE_PROXY_URL": "",
                "ENABLE_IPTV_CHECKER": "false",
                "IPTV_CHECKER_URL": ""
            }
        }
    ]
}
EOF
}