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

_pkgname=metube
pkgname="${_pkgname}-git"
pkgver=r426.d40786f
pkgrel=1
pkgdesc="Self-hosted YouTube downloader (web UI for youtube-dl / yt-dlp)"
arch=("any")
url="https://github.com/alexta69/${_pkgname}"
license=("AGPL-3.0-or-later")
provides=("${_pkgname}")
conflicts=("${_pkgname}")
depends=(aria2 ffmpeg python-aiohttp python-brotli python-mutagen python-pycryptodomex python-simple-websocket python-socketio yt-dlp)
makedepends=("git" "npm")
source=("${_pkgname}::git+${url}"
        "${_pkgname}.service"
        "${_pkgname}.sh")
sha256sums=('SKIP'
            'de07b835827462a4b7c19fe2dd73b02faed87b4a2b33c50627385d4b92bab71c'
            '2b63a9c2b307da510b6b1804a87f510d2147a45c86e133581297f4ac9c348ac1')
options=("!strip" "!debug")

prepare() {
    echo -e "## Means of environment variables see: https://github.com/alexta69/metube\n" > "${_pkgname}.env"
    find "${_pkgname}/app" -type f | xargs -I {} sed -i 's/\r$//g' {}
    sed -i 's/python3/python/' "${_pkgname}/app/main.py"
    awk '/_DEFAULTS *= *\{/,/\s\}/' "${_pkgname}/app/main.py" | sed -n 's/^[ \t]*\([^:]*\):[ \t]*\(.*\),/\1: \2/p' | sed -E -e "s|^'|#|g" -e "s|' ?: |=|" >> "${_pkgname}.env"
}

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

build() {
    cd "${_pkgname}/ui"
    npm ci
    ./node_modules/.bin/ng build --configuration production
}

package() {
    install -Dm755 "${_pkgname}.sh"       "${pkgdir}/usr/bin/${_pkgname}"
    install -Dm644 "${_pkgname}.service"  "${pkgdir}/usr/lib/systemd/user/${_pkgname}.service"
    install -Dm644 "${_pkgname}.env"      "${pkgdir}/usr/share/${_pkgname}/${_pkgname}.env.example"

    cd "${_pkgname}"
    install -Dm644 app/*.py            -t "${pkgdir}/usr/share/${_pkgname}/app"
    find "ui/dist" -type f | \
        xargs -I {} install -Dm644 {}     "${pkgdir}/usr/share/${_pkgname}/"{}
}