From d821ffb8295ca621302a0b8fe7421405af16bceb Mon Sep 17 00:00:00 2001 From: dada513 Date: Tue, 28 Dec 2021 15:45:04 +0000 Subject: [PATCH] Flatpak & Debian Packaging (#4) Flatpak & Debian packages --- .gitignore | 11 +++ launcher/java/JavaUtils.cpp | 2 + packages/debian/makedeb.sh | 10 +++ .../debian/polymc/DEBIAN/control.template | 9 +++ .../usr/share/applications/polymc.desktop | 11 +++ packages/flatpak/BUILDING.md | 28 +++++++ packages/flatpak/org.polymc.PolyMC.desktop | 11 +++ packages/flatpak/org.polymc.PolyMC.yml | 74 +++++++++++++++++++ 8 files changed, 156 insertions(+) create mode 100755 packages/debian/makedeb.sh create mode 100644 packages/debian/polymc/DEBIAN/control.template create mode 100644 packages/debian/polymc/usr/share/applications/polymc.desktop create mode 100644 packages/flatpak/BUILDING.md create mode 100644 packages/flatpak/org.polymc.PolyMC.desktop create mode 100644 packages/flatpak/org.polymc.PolyMC.yml diff --git a/.gitignore b/.gitignore index d73f9f22..88163fc2 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,14 @@ secrets/ run/ .cache/ + +# Flatpak builds +.flatpak-builder +flatbuild +builddir +# Deb +packages/debian/polymc/usr/bin +packages/debian/polymc/usr/lib +packages/debian/polymc/usr/share/polymc/jars +packages/debian/polymc.deb +packages/debian/polymc/DEBIAN/control \ No newline at end of file diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index c844fb94..780b23f2 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -407,6 +407,8 @@ QList JavaUtils::FindJavaPaths() // manually installed JDKs in /opt scanJavaDir("/opt/jdk"); scanJavaDir("/opt/jdks"); + // flatpak + scanJavaDir("/app/jdk"); return javas; } #else diff --git a/packages/debian/makedeb.sh b/packages/debian/makedeb.sh new file mode 100755 index 00000000..5a8c71dd --- /dev/null +++ b/packages/debian/makedeb.sh @@ -0,0 +1,10 @@ +#!/bin/bash +mkdir builddir +cd builddir +cmake -DLauncher_LAYOUT=lin-system -DCMAKE_INSTALL_PREFIX=../polymc/usr ../../../ +make -j$(nproc) install +cd .. +VERSION_PLACEHOLDER=$(git describe --tags | sed 's/-.*//') +cp polymc/DEBIAN/control.template polymc/DEBIAN/control +sed -i "2s/.*/Version: $VERSION_PLACEHOLDER/" polymc/DEBIAN/control +dpkg-deb --build polymc diff --git a/packages/debian/polymc/DEBIAN/control.template b/packages/debian/polymc/DEBIAN/control.template new file mode 100644 index 00000000..f7c294bc --- /dev/null +++ b/packages/debian/polymc/DEBIAN/control.template @@ -0,0 +1,9 @@ +Package: polymc +Version: +Section: games +Priority: optional +Architecture: amd64 +Depends: libqt5core5a, libqt5network5, libqt5gui5 +Maintainer: PolyMC Team +Description: PolyMC + A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once diff --git a/packages/debian/polymc/usr/share/applications/polymc.desktop b/packages/debian/polymc/usr/share/applications/polymc.desktop new file mode 100644 index 00000000..7cf78e9f --- /dev/null +++ b/packages/debian/polymc/usr/share/applications/polymc.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Name=PolyMC +Comment=A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once. +Type=Application +Terminal=false +Exec=polymc +StartupNotify=true +Icon=null +Categories=Game; +Keywords=game;minecraft;launcher; diff --git a/packages/flatpak/BUILDING.md b/packages/flatpak/BUILDING.md new file mode 100644 index 00000000..c1594b8f --- /dev/null +++ b/packages/flatpak/BUILDING.md @@ -0,0 +1,28 @@ +# Building the flatpak + +### 1. Install tools + +Install `flatpak` and `flatpak-builder` from your distribution repositories. + +### 2. Install SDK + +`flatpak install org.kde.Sdk org.kde.Platform` +Pick version `5.15` + +### 3. Get the yml flatpak file + +You can download it directly from github, or clone the repo. + +### 4. Build it + +``` +flatpak-builder --ccache --force-clean flatbuild packages/flatpak/org.polymc.PolyMC.yml +``` + +If you didn't clone the repo, the path might be different. + +### 5. Install the custom build + +``` +flatpak-builder --user --install --ccache --force-clean flatbuild packages/org.polymc.PolyMC.yml +``` diff --git a/packages/flatpak/org.polymc.PolyMC.desktop b/packages/flatpak/org.polymc.PolyMC.desktop new file mode 100644 index 00000000..7cf78e9f --- /dev/null +++ b/packages/flatpak/org.polymc.PolyMC.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=1.0 +Name=PolyMC +Comment=A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once. +Type=Application +Terminal=false +Exec=polymc +StartupNotify=true +Icon=null +Categories=Game; +Keywords=game;minecraft;launcher; diff --git a/packages/flatpak/org.polymc.PolyMC.yml b/packages/flatpak/org.polymc.PolyMC.yml new file mode 100644 index 00000000..632f990b --- /dev/null +++ b/packages/flatpak/org.polymc.PolyMC.yml @@ -0,0 +1,74 @@ +app-id: org.polymc.PolyMC +runtime: org.kde.Platform +runtime-version: "5.15" +sdk: org.kde.Sdk +command: polymc +finish-args: + - --share=ipc + - --socket=x11 + - --socket=wayland + - --device=dri + - --share=network + # for Discord RPC mods + - --filesystem=xdg-run/app/com.discordapp.Discord:create + +modules: + - name: compile + buildsystem: simple + build-commands: + - mkdir build + - mkdir -p /app/bin + - cd build && JAVA_HOME=/run/build/compile/jdk PATH=$JAVA_HOME:$PATH JAVA_COMPILER=../jdk/bin/javac cmake -DLauncher_LAYOUT=lin-system -DCMAKE_INSTALL_PREFIX=/app/ .. && make -j$(nproc) install + sources: + - type: git + url: https://github.com/PolyMC/PolyMC.git + tag: 1.0.0 + - type: archive + url: https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17%2B35/OpenJDK17-jdk_x64_linux_hotspot_17_35.tar.gz + sha256: 6f1335d9a7855159f982dac557420397be9aa85f3f7bc84e111d25871c02c0c7 + archive-type: tar-gzip + dest: jdk + # old MC versions depend on Xrandr + - name: xrandr + buildsystem: simple + build-commands: + - ./configure --prefix=/app + - make + - make install + sources: + - type: archive + url: https://xorg.freedesktop.org/archive/individual/app/xrandr-1.5.1.tar.xz + sha256: 7bc76daf9d72f8aff885efad04ce06b90488a1a169d118dea8a2b661832e8762 + - name: java + buildsystem: simple + build-commands: + - mkdir -p /app/jdk + - mv ./* /app/jdk + sources: + # JDK 17 for MC 1.18 + - type: archive + url: https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.1%2B12/OpenJDK17U-jre_x64_linux_hotspot_17.0.1_12.tar.gz + sha256: 9d58cb741509a88e0ae33eb022334fb900b409b198eca6fe76246f0677b392ad + strip-components: 0 + # JDK for Minecraft 1.17 - 1.18 + - type: archive + url: https://github.com/adoptium/temurin16-binaries/releases/download/jdk-16.0.2%2B7/OpenJDK16U-jdk_x64_linux_hotspot_16.0.2_7.tar.gz + sha256: 323d6d7474a359a28eff7ddd0df8e65bd61554a8ed12ef42fd9365349e573c2c + strip-components: 0 + # JDK 11 for 1.9 - 1.15.2 + - type: archive + url: https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.13%2B8/OpenJDK11U-jre_x64_linux_hotspot_11.0.13_8.tar.gz + sha256: fb0a27e6e1f26a1ee79daa92e4cfe3ec0d676acfe114d99dd84b3414f056e8a0 + strip-components: 0 + # JDK 8 for pre1.9 + - type: archive + url: https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u312-b07/OpenJDK8U-jre_x64_linux_hotspot_8u312b07.tar.gz + sha256: 18fd13e77621f712326bfcf79c3e3cc08c880e3e4b8f63a1e5da619f3054b063 + strip-components: 0 + - name: desktopfiles + buildsystem: simple + build-commands: + - install -Dm644 org.polymc.PolyMC.desktop /app/share/applications/org.polymc.PolyMC.desktop + sources: + - type: file + path: org.polymc.PolyMC.desktop