summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c12b07a40c7020fb79c391d15fcb68ab848ff021 (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Maintainer: detiam <dehe_tian [at] outlook dot com>
# Contributor: zhullyb <zhullyb [at] outlook dot com>
# Contributor: weearc <q19981121 [at] 163 dot com>
# Contributor: JimMoen <LnJimMoen [at] outlook dot com>

pkgname=motrix-electron
_pkgname=Motrix
pkgver=1.8.19
pkgrel=2
pkgdesc="A full-featured download manager (use extra/electron)"
arch=("x86_64")
url="https://github.com/detiam/Motrix"
license=('MIT')
depends=('electron') # tested work with electron 30
makedepends=('volta' 'jq' 'gendesk')
provides=("$_pkgname")
conflicts=("$_pkgname")
replaces=("$_pkgname")
commit=b18a48dab2eb4f2d630e81eaec19e43217be5565
source=("$_pkgname-$commit.tar.gz::${url}/archive/${commit}.tar.gz")
sha1sums=('b695570b75cf94da91fc0443349a260707864e6b')

_install_dir="/usr/lib/${pkgname}"

_use_srcdir() {
    # for not influence user home
    HOME="$srcdir"
    VOLTA_HOME="$HOME/.volta"
    PATH="$VOLTA_HOME/bin:$PATH"
}

prepare() {
    cd "$_pkgname-$commit"
    _use_srcdir
    volta run yarn
}

build() {
    cd "$_pkgname-$commit"
    _use_srcdir
    yarn run build:github
    mkdir app
    cp -a dist app
    jq '{
            name,
            version,
            description,
            homepage,
            author,
            copyright,
            license,
            main,
            dependencies,
            volta
         }' package.json > app/package.json
    yarn install \
        --cwd=app \
        --prod \
        --no-lockfile \
        --non-interactive
}

package() {
    cd "$_pkgname-$commit"

    # copy file
    install -dm755 "$pkgdir/$_install_dir"
    cp -a extra/linux/x64/engine/ "$pkgdir/$_install_dir"
    cp -a app "$pkgdir/$_install_dir"

    # binary wrapper
    install -Dm755 <(cat <<- SCRIPT
	#!/usr/bin/env sh
	export ELECTRON_IS_DEV=true
	export ELECTRON_FORCE_IS_PACKAGED=true
	exec electron $_install_dir/app "\$@"
	
	SCRIPT
    ) "${pkgdir}/usr/bin/${pkgname}"

    # icons
    install -dm755 "${pkgdir}/usr/share/pixmaps"
    install -dm755 "${pkgdir}"/usr/share/hicolor/{256x256,512x512}/apps
    ln -sf \
        "$_install_dir/app/dist/electron/static/512x512.png" \
        "${pkgdir}/usr/share/pixmaps/${pkgname}.png"
    ln -sf \
        "$_install_dir/app/dist/electron/static/512x512.png" \
        "${pkgdir}/usr/share/hicolor/512x512/apps/${pkgname}.png"
    install -Dm644 \
        build/256x256.png \
        "${pkgdir}/usr/share/hicolor/256x256/apps/${pkgname}.png"
    
    # desktop enrty
    _pkgdesc="$(jq -r '.description' package.json)"
    install -dm755 "${pkgdir}/usr/share/applications"
    cd "${pkgdir}/usr/share/applications"
    gendesk --pkgname="$pkgname" \
            --pkgdesc="$_pkgdesc" \
            --icon="$pkgname" \
            --exec="$pkgname" \
            --categories="Network;" \
            --custom='Comment[zh]=一款全能的下载工具' \
            --startupnotify=true -n --name="$_pkgname"
}