summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: fbeafe6063f13dd3bc415128b041d4ca6c5acc45 (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
# Maintainer: Sukanka <su975853527 [AT] gmail.com>
# Contributor: Luis Martinez <luis dot martinez at disroot dot org>
# Contributer: Bruce Zhang

pkgname=lx-music
pkgver=2.8.0
pkgrel=1
_electron=electron28
pkgdesc='An Electron-based music player'
arch=('x86_64' 'aarch64')
url='https://github.com/lyswhut/lx-music-desktop'
license=('Apache')
depends=("${_electron}")
makedepends=('asar' 'npm' 'git' 'node-gyp'
	'jq' 'moreutils'
)
source=("$pkgname-$pkgver.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz"
	"$pkgname.sh"
	"$pkgname.desktop"
	'dev-app-update.yml'
)
sha256sums=('51eb3b9ef54c02d2f517371d4dd987defccd5d9025dc41ee3cd0fba3768a2843'
            '1171a3688a136b75aa0493d5737cfb1e8c386a48030c8ca313d4cac48c0630e3'
            '732e98dfe569768c3cc90abbe8b1f6d24726dd2cb61317f57f8d5fe77fdefe2f'
            'ffdd88036d10eb9780c0a26987894708720c2f486247bb3854f05fb5dd607423')

prepare() {
	cd "$srcdir/$pkgname-desktop-$pkgver"

	local electronDist="/usr/lib/${_electron}"
	local electronVersion="$(<$electronDist/version)"
	jq ".devDependencies.electron = \"$electronVersion\"" package.json | sponge package.json
	jq ".build.electronDist = \"$electronDist\"" package.json | sponge package.json
	jq ".build.electronVersion = \"$electronVersion\"" package.json | sponge package.json

	sed -i "s|__ELECTRON__|${_electron}|g" "${srcdir}/${pkgname}.sh"
	# disable autoupdater
	sed -i "/common.tryAutoUpdate/s/true/false/" src/common/defaultSetting.ts
}

build() {
	cd "$srcdir/$pkgname-desktop-$pkgver"
	export HOME=${srcdir}
	export ELECTRON_SKIP_BINARY_DOWNLOAD=1
	npm install
	npm run pack:dir
}

package() {
	install -Dm644 'dev-app-update.yml' -t "$pkgdir/usr/lib/lx-music/"
	install -Dm755 lx-music.sh "$pkgdir/usr/bin/lx-music"
	install -Dm644 lx-music.desktop -t "$pkgdir/usr/share/applications/"

	# Install app
	cd "$srcdir/$pkgname-desktop-$pkgver/"
	asar e build/linux-unpacked/resources/app.asar "$pkgdir/usr/lib/lx-music/"

	# Install icons
	install -Dm644 resources/icons/512x512.png "$pkgdir/usr/share/icons/hicolor/512x512/apps/lx-music.png"

	# Install license
	install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/lx-music/"
	cp -a --no-preserve=ownership licenses "$pkgdir/usr/share/licenses/lx-music/"

	# clean other platform.
	for native in {bufferutil,utf-8-validate}; do
		cd ${pkgdir}/usr/lib/lx-music/node_modules/$native/prebuilds
		rm -rf darwin-* win32-*
	done
}