summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4c79dab336c866d15df363d3328fa9102414131f (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
# Maintainer: S Stewart <tda@null.net>
# Maintainer: Cranky Supertoon <crankysupertoon@gmail.com>
pkgname="gdlauncher"
pkgver="1.1.29"
pkgrel=1
arch=('x86_64')
pkgdesc="GDLauncher is simple, yet powerful Minecraft custom launcher with a strong focus on the user experience"
url="https://gdevs.io"
license=('GPL3')
makedepends=('gendesk' 'nodejs' 'npm' 'rust')
depends=('libnotify' 'libxss' 'libxtst' 'libindicator-gtk3' 'libappindicator-gtk3' 'electron16' 'p7zip')
conflicts=('gdlauncher-beta' 'gdlauncher-beta-bin' 'gdlauncher-appimage' 'gdlauncher-git' 'gdlauncher-bin' 'gdlauncher-appimage')
provides=('gdlauncher')
source=("https://github.com/gorilla-devs/GDLauncher/archive/refs/tags/v${pkgver}.tar.gz"
        "use-system-7za-and-disable-updater.patch")
md5sums=('68987cd0f7d4837f29cf5bb5bdfba8fa'
         '68c75869fe0898c54699b9a5eb667d7b')

prepare() {
    # Generate .desktop
    gendesk --pkgname "GDLauncher" --pkgdesc "${pkgdesc}" --icon ${pkgname} --exec "/usr/bin/${pkgname}" --categories "Application;Game" -n -f

    cd "${srcdir}/GDLauncher-${pkgver}/"

    # Apply patches, copied from ObserverOfTime's gdlauncher-git
    sed -i package.json \
        -e '/electron-updater/d;/7zip-bin/d' \
        -e 's$public/electron.js$build/electron.js$' \
        -e '/"dependencies"/i\  "bundledDependencies": ["7zip-bin"],' \
        -e 's/0.13.1/0.13.2/g' # bump dependency version
    patch -p1 -i "${srcdir}/use-system-7za-and-disable-updater.patch"

    # Create .git folder to stop Husky from crashing
    mkdir -p .git
}

build() {
    cd "${srcdir}/GDLauncher-${pkgver}/"

    # Install required npm packages
    npm install --legacy-peer-deps --cache="${srcdir}/npm-cache"

    # Build the program
    export CI=false \
        APP_TYPE=electron \
        NODE_ENV=production \
        REACT_APP_RELEASE_TYPE=setup
    npx craco build
    npx webpack --config ./scripts/electronWebpackConfig.js
}

package() {
    # Copy runtime files
    install -d -m755 "${pkgdir}/usr/lib/gdlauncher/"
    rm "${srcdir}/GDLauncher-${pkgver}/build/installer"{.nsh,{Header,Sidebar}.bmp}  # Unecessary install files
    cp -r "${srcdir}/GDLauncher-${pkgver}/"{package.json,build} "${pkgdir}/usr/lib/gdlauncher/"

    # Create run script
    install -d -m755 "${pkgdir}/usr/bin/"
    printf '#!/bin/sh\ncd /usr/lib/gdlauncher/\nexec electron16 . "$@"' > "${pkgdir}/usr/bin/gdlauncher"
    chmod a+x "${pkgdir}/usr/bin/gdlauncher"

    # Desktop entry
    install -d -m755 "${pkgdir}/usr/share/applications/"
    install -D -m644 "${srcdir}/GDLauncher.desktop" "${pkgdir}/usr/share/applications/GDLauncher.desktop"

    # Install icons
    cd "${srcdir}/GDLauncher-${pkgver}/public/linux-icons/"
    for icon in *.png; do
        install -d -m755 "${pkgdir}/usr/share/icons/hicolor/${icon::-4}/apps/"
        cp "$icon" "${pkgdir}/usr/share/icons/hicolor/${icon::-4}/apps/${pkgname}.png"
    done
}