summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 930025f88e2ece06d0f95df901ff78830fa87f2c (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
# Maintainer: Bruce Zhang
pkgname=ppet
_name=PPet
pkgver=1.2.1
pkgrel=1
pkgdesc='给你的桌面添加一点趣味~'
arch=('x86_64')
url="https://github.com/zenghongtu/PPet"
license=('MIT')
depends=('electron')
makedepends=('yarn' 'jq' 'moreutils')
conflicts=("$pkgname-bin")
source=("$pkgname-$pkgver.src.tar.gz::$url/archive/v$pkgver.tar.gz")
sha256sums=('943a47c6c71a639a97e77a6251b67909794fe44e744ac8011e09e1d96e7a8dde')

prepare() {
	cd "$srcdir/$_name-$pkgver"
	local electron_dist='/usr/lib/electron'
	local electron_version=$(tail -1 "$electron_dist/version")
	local yarn_cache="$srcdir/yarn_cache"

	jq '.build.electronDist = $dist | .build.electronVersion = $version | .devDependencies.electron = $version' \
        --arg dist "$electron_dist" \
        --arg version "$electron_version" \
        package.json | sponge package.json

	jq '.electronWebpack.staticSourceDirectory = $static' \
		--arg static "static" \
		package.json | sponge package.json

	sed -i 's#CmdOrCtrl+r#CmdOrCtrl+R#' src/main/ppetTray.ts

    export YARN_CACHE_FOLDER="$yarn_cache"
    yarn
}

build() {
	cd "$srcdir/$_name-$pkgver"
	yarn dist:dir
}

package() {
	cd "$srcdir/$_name-$pkgver/dist/linux-unpacked/resources"
	install -Dm644 app.asar "$pkgdir/usr/share/ppet/app.asar"

	cd static/icons/png
	for file in *x*.png; do
		install -Dm644 "$file" "$pkgdir/usr/share/icons/hicolor/${file%.png}/apps/ppet.png"
	done

	cd "$srcdir"
	echo "#!/usr/bin/env sh
exec electron /usr/share/ppet/app.asar \$@
" > "$srcdir/ppet.sh"
	echo "[Desktop Entry]
Name=PPet
Exec=/usr/bin/ppet %U
Terminal=false
Type=Application
Icon=ppet
StartupWMClass=PPet
Comment=给你的桌面添加一点趣味~
Categories=Development;
" > "$srcdir/ppet.desktop"

	install -Dm755 "$srcdir/ppet.sh" "$pkgdir/usr/bin/ppet"
	install -Dm644 "$srcdir/ppet.desktop" "$pkgdir/usr/share/applications/ppet.desktop"
}