summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d83dd103114a3358a8926952f657da2fdebdcb3e (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Maintainer: Latte macchiato <contact@lattemacchiato.dev>
pkgname=plezy-git
_pkgname=plezy
pkgver=2.25.0.r55.gfa8acc3
pkgrel=1
pkgdesc='A modern Plex client for desktop and mobile'
arch=('x86_64')
url='https://github.com/edde746/plezy'
license=('GPL-3.0-or-later')
depends=(
    'gtk3'
    'mpv'
    'libepoxy'
    'libevdev'
    'libkeybinder3'
    'alsa-lib'
    'glib2'
    'xdg-user-dirs'
    'curl'
    'hicolor-icon-theme'
)
makedepends=(
    'clang'
    'cmake'
    'jdk21-openjdk'
    'ninja'
    'pkgconf'
    'git'
    'patchelf'
    'unzip'
)
provides=("$_pkgname")
conflicts=("$_pkgname")
options=('!debug')
_flutter_ver=3.47.1
source=(
    "$_pkgname::git+$url.git"
    "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${_flutter_ver}-stable.tar.xz"
    'background_downloader-guard-connectivity.patch'
)
sha256sums=('SKIP'
            'a1d8166c0309267cb7dc99f1424eecf08b86946ad3b50723c6f59945964aea45'
            '9340e113ba1b9efb2dd20ba8ffd94243cc78d2e4bd614180eedb2f2b43b5f3b8')

pkgver() {
    cd "$_pkgname"
    # Ignore diagnostic tags such as test-2883-keydiag when deriving pkgver.
    git describe --long --tags --abbrev=7 --match '[0-9]*' --match 'v[0-9]*' 2>/dev/null | sed 's/^v//;s/-/.r/;s/-/./' \
        || printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
    # Match the packaged JNI runtime and avoid discovery through a JRE-only default.
    export JAVA_HOME=/usr/lib/jvm/java-21-openjdk
    export PATH="$srcdir/flutter/bin:$PATH"
    export PUB_CACHE="$srcdir/.pub-cache"

    flutter config --no-analytics
    flutter precache --linux

    cd "$_pkgname"
    flutter pub get

    # Contain connectivity_plus DBus errors in background_downloader when
    # NetworkManager is absent (systemd-networkd/iwd). Plezy guards its own
    # calls; the pinned downloader fork does not. Skip once fixed upstream.
    local _bd
    for _bd in "$PUB_CACHE"/git/background_downloader-*/; do
        if patch -d "$_bd" -p1 -N --dry-run -s < "$srcdir/background_downloader-guard-connectivity.patch" >/dev/null; then
            patch -d "$_bd" -p1 -N < "$srcdir/background_downloader-guard-connectivity.patch"
        else
            echo "background_downloader connectivity patch not applicable to ${_bd}; skipping" >&2
        fi
    done

    # Remove -Werror from all CMakeLists.txt (fixes strict clang warnings in plugins)
    find . -name 'CMakeLists.txt' -exec sed -i 's/-Werror//g' {} +

    flutter build linux --release
}

package() {
    # The build JDK conflicts with Arch's separate headless JRE package.
    # Require the smaller JRE in the artifact, not during dependency installation.
    depends+=('jre21-openjdk-headless')
    cd "$_pkgname"

    # Install the application bundle
    install -dm755 "$pkgdir/opt/$_pkgname"
    cp -r build/linux/x64/release/bundle/* "$pkgdir/opt/$_pkgname/"

    # Replace Flutter build-time RUNPATHs with relocatable bundle-local paths.
    find "$pkgdir/opt/$_pkgname/lib" -type f -name '*.so' \
        -exec patchelf --set-rpath '$ORIGIN' {} +
    # Dart JNI links libjvm directly. Use the matching declared Java runtime,
    # not the build JDK or the user's changeable default Java symlink.
    if [[ -f "$pkgdir/opt/$_pkgname/lib/libdartjni.so" ]]; then
        patchelf --set-rpath '$ORIGIN:/usr/lib/jvm/java-21-openjdk/lib/server' \
            "$pkgdir/opt/$_pkgname/lib/libdartjni.so"
    fi
    if [[ -f "$pkgdir/opt/$_pkgname/lib/crashpad_handler" ]]; then
        patchelf --set-rpath '$ORIGIN' "$pkgdir/opt/$_pkgname/lib/crashpad_handler"
    fi

    # Create wrapper script
    install -Dm755 /dev/stdin "$pkgdir/usr/bin/$_pkgname" <<EOF
#!/bin/bash
cd /opt/$_pkgname
exec ./$_pkgname "\$@"
EOF

    # Install desktop file
    install -Dm644 linux/packaging/com.edde746.plezy.desktop \
        "$pkgdir/usr/share/applications/com.edde746.plezy.desktop"

    # Install icon
    install -Dm644 assets/plezy.png \
        "$pkgdir/usr/share/icons/hicolor/512x512/apps/$_pkgname.png"

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