summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 947b2df1fed04330a129bf8ff95bdc4ec4180372 (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
# Maintainer: italoghost <eduprodive at posteo dot me>
# Contributor: Sanpi <sanpi+aur@homecomputing.fr>
pkgname=rpcs3-bin
_pkgname=rpcs3
pkgver=0.0.40.18876
pkgrel=1
pkgdesc='Open-source Sony PlayStation 3 Emulator (Latest Binary)'
arch=('x86_64')
url='https://rpcs3.net/'
license=('GPL-2.0-only')
provides=("$_pkgname")
conflicts=("$_pkgname")
options=('!strip' '!zipman')
depends=(
  'glibc'
  'gcc-libs'
  'zlib'
  'bash'
  'libx11'
  'libxcb'
  'vulkan-icd-loader'
  'libglvnd'
  'alsa-lib'
  'fontconfig'
  'freetype2'
)
makedepends=('curl')

# Source the GitHub API to trigger the build, the actual AppImage is fetched in prepare()
source=("${_pkgname}::https://api.github.com/repos/RPCS3/rpcs3-binaries-linux/releases/latest")
sha256sums=('SKIP')

pkgver() {
    # Cleanly fetch the latest tag name from GitHub API and format it
    curl -s "https://api.github.com/repos/RPCS3/rpcs3-binaries-linux/releases/latest" | \
    grep -oP '"name": "\K0[^"]+' | sed 's/-/./g'
}

prepare() {
    # Dynamically find the download URL for the AppImage asset
    _appimage_url=$(curl -s "https://api.github.com/repos/RPCS3/rpcs3-binaries-linux/releases/latest" | \
                    awk -F'"' '/browser_download_url.*rpcs3.*AppImage/ {print $4}')

    msg2 "Downloading the actual AppImage..."
    curl -L "$_appimage_url" -o "${srcdir}/rpcs3.AppImage"
    chmod +x "${srcdir}/rpcs3.AppImage"
}

build() {
    cd "${srcdir}"
    # Extracting AppImage content into squashfs-root
    ./rpcs3.AppImage --appimage-extract

    # Patch AppRun to point to the fixed installation directory in /opt
    sed -i "s|this_dir=\"\$(readlink -f \"\$(dirname \"\$0\")\")\"|this_dir=\"/opt/${_pkgname}\"|" "$srcdir/squashfs-root/AppRun"
}

package() {
    # Core directories
    install -dm755 "$pkgdir/opt/${_pkgname}"
    cp -rp "$srcdir"/squashfs-root/* "$pkgdir/opt/${_pkgname}/"

    # Symlink the launcher to /usr/bin
    install -dm755 "$pkgdir/usr/bin"
    ln -sf "/opt/${_pkgname}/AppRun" "$pkgdir/usr/bin/${_pkgname}"

    # Install Icon, Desktop and Metainfo
    install -Dm644 "$srcdir/squashfs-root/${_pkgname}.svg" "$pkgdir/usr/share/pixmaps/${_pkgname}.svg"
    install -Dm644 "$srcdir/squashfs-root/${_pkgname}.desktop" "$pkgdir/usr/share/applications/${_pkgname}.desktop"
    install -Dm644 "$srcdir/squashfs-root/usr/share/metainfo/${_pkgname}.metainfo.xml" "$pkgdir/usr/share/metainfo/${_pkgname}.metainfo.xml"

	# Permissions
	chmod -R u+rwX,go+rX,go-w "${pkgdir}/opt/${_pkgname}"
}