summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7aa8d5a76e3662b50ce5345670537184bfdbf88e (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
# Maintainer: Maki <maki@hotmilk.space>

pkgname=pony-house-bin
pkgver=1.5.0
pkgrel=1
pkgdesc="A Matrix client, focused on being a completely customizable open source superapp"
arch=("x86_64")
url="https://github.com/Pony-House/Client"
license=("AGPL-3.0-only")

depends=("electron")
makedepends=("asar")

options=("!strip")

_filename="Pony.House-$pkgver.AppImage"

source=(
	"https://github.com/Pony-House/Client/releases/download/$pkgver/$_filename"
	"https://raw.githubusercontent.com/Pony-House/Client/$pkgver/LICENSE"
)

sha256sums=(
	"c6f17d82850eec8bd0206422f118c6a83801154907415d56c1cca4737ee2b986"
	"4df3c306dddaaf4baffdff5ca820cc679ac8cd6dc263c6a74517783e42fa7a3b"
)

_install_name="pony-house"

# tried to do this similar to
# https://archlinux.org/packages/extra/x86_64/element-desktop

asar_patches() {
    sed -i -E 's| \+ appName| \+ "'$_install_name'"|g' \
        app/node_modules/auto-launch/dist/AutoLaunchLinux.js
    
    sed -i -E 's| \+ appPath| \+ "\/usr\/bin\/'$_install_name'"|g' \
        app/node_modules/auto-launch/dist/AutoLaunchLinux.js
}

package() {
    # extract AppImage
    chmod +x "$_filename"
    ./$_filename --appimage-extract &>/dev/null

    # install app.asar and app.asar.unpacked

    install -Dm644 squashfs-root/resources/app.asar \
        "$pkgdir/usr/lib/$_install_name/app.asar"

    cp -r squashfs-root/resources/app.asar.unpacked \
        "$pkgdir/usr/lib/$_install_name/"

    # no other resources need to be installed

    # patch app.asar

    cd "$pkgdir/usr/lib/$_install_name"
    asar extract app.asar app
    rm -f app.asar

    asar_patches

    asar pack app app.asar
    rm -rf app app.asar.unpacked
    cd "$srcdir"

    # create executable
    mkdir -p "$pkgdir/usr/bin/"
    cat << EOF > "$pkgdir/usr/bin/$_install_name"
#!/bin/sh
exec electron /usr/lib/$_install_name/app.asar "\$@"
EOF
    chmod +x "$pkgdir/usr/bin/$_install_name"

    # install icon
    install -Dm644 squashfs-root/usr/share/icons/hicolor/512x512/apps/pony-house-matrix.png \
        "$pkgdir/usr/share/icons/hicolor/512x512/apps/$_install_name.png"
    
    # install desktop file
    install -Dm644 squashfs-root/pony-house-matrix.desktop \
        "$pkgdir/usr/share/applications/$_install_name.desktop"

    # fix desktop file

    sed -i -E "s/Icon=pony-house-matrix/Icon="$_install_name"/i" \
        "$pkgdir/usr/share/applications/$_install_name.desktop"

    sed -i -E "s/Exec=.+$/Exec=\/usr\/bin\/"$_install_name" %U/i" \
        "$pkgdir/usr/share/applications/$_install_name.desktop"

    # install license
    install -Dm644 "LICENSE" "$pkgdir/usr/share/licenses/$_install_name/LICENSE"
}