From f4e13f837bb9ba71409c947e56039441b842bec2 Mon Sep 17 00:00:00 2001 From: Uriel Date: Sat, 24 Dec 2022 21:06:28 -0300 Subject: [PATCH] Linux bundling with the jar (#413) --- .github/workflows/build-gui.yml | 21 ++++-------- .github/workflows/gradle.yaml | 59 +++++++++++++++++++++++++++++++++ gui/package.json | 1 + gui/src-tauri/src/main.rs | 22 ++++++++---- gui/src-tauri/tauri.conf.json | 5 ++- package.json | 1 + 6 files changed, 88 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-gui.yml b/.github/workflows/build-gui.yml index c95e31479..9ad9c0590 100644 --- a/.github/workflows/build-gui.yml +++ b/.github/workflows/build-gui.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-20.04, windows-latest] runs-on: ${{ matrix.os }} @@ -31,7 +31,7 @@ jobs: with: submodules: recursive - - if: matrix.os == 'ubuntu-latest' + - if: matrix.os == 'ubuntu-20.04' name: Set up Linux dependencies run: | sudo apt-get update @@ -39,6 +39,8 @@ jobs: - name: Cache cargo dependencies uses: Swatinem/rust-cache@v2 + with: + shared-key: "tauri" - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 @@ -49,7 +51,7 @@ jobs: - name: Build run: | npm ci - npm run tauri build + npm run skipbundler - if: matrix.os == 'windows-latest' name: Upload a Build Artifact @@ -65,15 +67,6 @@ jobs: uses: actions/upload-artifact@v3.1.0 with: # Artifact name - name: SlimeVR-GUI-Deb + name: SlimeVR-GUI-Linux # A file, directory or wildcard pattern that describes what to upload - path: target/release/bundle/deb/slimevr*.deb - - - if: matrix.os == 'ubuntu-latest' - name: Upload a Build Artifact - uses: actions/upload-artifact@v3.1.0 - with: - # Artifact name - name: SlimeVR-GUI-AppImage - # A file, directory or wildcard pattern that describes what to upload - path: target/release/bundle/appimage/slimevr*.AppImage + path: target/release/slimevr diff --git a/.github/workflows/gradle.yaml b/.github/workflows/gradle.yaml index 66d151942..58bdb5cb1 100644 --- a/.github/workflows/gradle.yaml +++ b/.github/workflows/gradle.yaml @@ -59,3 +59,62 @@ jobs: name: "SlimeVR-Server" # optional, default is artifact # A file, directory or wildcard pattern that describes what to upload path: server/build/libs/* + + bundle: + runs-on: ubuntu-20.04 + needs: build + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - uses: actions/download-artifact@v3 + with: + name: "SlimeVR-Server" + path: server/build/libs/ + + - name: Set up Linux dependencies + run: | + sudo apt-get update + sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf libfuse2 + + - name: Cache cargo dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: "tauri" + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version-file: '.node-version' + cache: 'npm' + + - name: Build + run: | + npm ci + npm run tauri build + + - uses: actions/upload-artifact@v3.1.0 + with: + name: SlimeVR-GUI-Deb + path: target/release/bundle/deb/slimevr*.deb + + - name: Install appimage-builder + run: | + wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" + chmod a+x appimagetool-x86_64.AppImage + sudo mv appimagetool-x86_64.AppImage /usr/local/bin/appimagetool + + - name: Modify and Build AppImage + run: | + cd target/release/bundle/appimage + chmod a+x slimevr*.AppImage + ./slimevr*.AppImage --appimage-extract + cp $( git rev-parse --show-toplevel )/server/build/libs/slimevr.jar squashfs-root/slimevr.jar + chmod 644 squashfs-root/slimevr.jar + appimagetool squashfs-root slimevr*.AppImage + + - uses: actions/upload-artifact@v3.1.0 + with: + name: SlimeVR-GUI-AppImage + path: target/release/bundle/appimage/slimevr*.AppImage diff --git a/gui/package.json b/gui/package.json index 0403a31aa..95cb2e1f2 100644 --- a/gui/package.json +++ b/gui/package.json @@ -41,6 +41,7 @@ "start": "vite --force", "build": "vite build", "dev": "tauri dev", + "skipbundler": "tauri build -b none", "tauri": "tauri", "lint": "eslint src/**/*.{js,jsx,ts,tsx,json}", "lint:fix": "eslint --fix src/**/*.{js,jsx,ts,tsx,json}", diff --git a/gui/src-tauri/src/main.rs b/gui/src-tauri/src/main.rs index c0996b590..17cebce80 100644 --- a/gui/src-tauri/src/main.rs +++ b/gui/src-tauri/src/main.rs @@ -54,10 +54,7 @@ struct Cli { } fn is_valid_path(path: &PathBuf) -> bool { - // Might need to be changed in the future, at least for linux - let server_path = path.join("slimevr.jar"); - - return server_path.exists(); + path.join("slimevr.jar").exists() } fn get_launch_path(cli: Cli) -> Option { @@ -67,16 +64,29 @@ fn get_launch_path(cli: Cli) -> Option { } } - let mut path = env::current_dir().unwrap(); + let path = env::current_dir().unwrap(); if is_valid_path(&path) { return Some(path); } - path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); if is_valid_path(&path) { return Some(path); } + let path = PathBuf::from("/usr/share/slimevr/"); + if is_valid_path(&path) { + return Some(path); + } + + // This is only for AppImage + if let Some(appimage) = env::var_os("APPDIR") { + let path = PathBuf::from(appimage); + if is_valid_path(&path) { + return Some(path); + } + } + None } diff --git a/gui/src-tauri/tauri.conf.json b/gui/src-tauri/tauri.conf.json index 74eb92ef3..21e153d1e 100644 --- a/gui/src-tauri/tauri.conf.json +++ b/gui/src-tauri/tauri.conf.json @@ -22,7 +22,10 @@ "shortDescription": "", "longDescription": "", "deb": { - "depends": [] + "depends": ["openjdk-17-jre-headless"], + "files": { + "/usr/share/slimevr/slimevr.jar": "../../server/build/libs/slimevr.jar" + } }, "macOS": { "frameworks": [], diff --git a/package.json b/package.json index c79758441..e3b63e6a9 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "scripts": { "gui": "npm run update-solarxr && cd gui && npm run tauri dev", "tauri": "cd gui && npm run tauri", + "skipbundler": "cd gui && npm run skipbundler", "build": "npm run tauri build", "update-solarxr": "cd solarxr-protocol && npm run build", "prepare": "husky install && npm run update-solarxr && patch-package"