Skip to content

Commit

Permalink
Merge pull request #629 from silentrald/bugfix/627
Browse files Browse the repository at this point in the history
[bugfix-627] build BSM with deb and flatpak for linux
  • Loading branch information
Zagrios authored Nov 30, 2024
2 parents 877879f + 4afad63 commit 5462c88
Show file tree
Hide file tree
Showing 25 changed files with 744 additions and 186 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module.exports = {
"jsx-a11y/control-has-associated-label": "off",
"react/button-has-type": "off",
"max-classes-per-file": "off",
"jest/no-standalone-expect": "off",
},
parserOptions: {
ecmaVersion: 2020,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.11.0
cache: "npm"
- run: npm ci
- run: npm run package
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.11.0
cache: "npm"
- run: npm ci
- run: npm run lint
6 changes: 3 additions & 3 deletions .github/workflows/node.js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.11.0
cache: "npm"
- run: npm ci
- run: npm run build
Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/release-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,27 @@ jobs:
- name: Check out Git repository
uses: actions/checkout@v4

- name: Install flatpak packages
run: sudo apt-get install -y flatpak flatpak-builder

- name: Setup flatpak repo
run: |
flatpak remote-add --if-not-exists --user \
flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
node-version: 22.11.0
cache: "npm"
- run: npm ci
- run: npm run publish:linux
- run: npm run build

- name: Build deb
run: npx electron-builder --config electron-builder.config.js --publish always --linux deb --x64

- name: Build flatpak
run: env DEBUG="@malept/flatpak-bundler" npx electron-builder --config electron-builder.config.js --publish always --linux flatpak

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@
-->
<div>
<h2><b>How to install?</b></h2>
</div>

<div>
<h3><b>Windows Installation</b></h3>
<ul>
<li>Download the <a href="https://github.com/Zagrios/bs-manager/releases/latest">latest release</a> from <a
href="https://github.com/Zagrios/bs-manager/releases">Releases</a>.</li>
Expand All @@ -239,6 +243,10 @@
<video src="https://github.com/Zagrios/bs-manager/assets/40648115/4215384e-eb68-40da-884c-f21df491ef75" />
</div>

<div>
<h3><b>Linux installation</b></h3>
<p>Refer to <a href="https://github.com/Zagrios/bs-manager/wiki/Linux">Linux wiki</a></p>
</div>

<!--
----------------------------------------
Expand Down Expand Up @@ -550,6 +558,8 @@
<li><a href="https://github.com/Iluhadesu">Iluhadesu</a> - Co-Developer & Co-Founder, Discord Bot Developer.</li>
<li><a href="https://github.com/GaetanGrd">GaetanGrd</a> - Co-Developer & Co-Founder, Documentation Lead.</li>
<li><a href="https://github.com/cheddZy">cheddZy</a> - Icon Creator.</li>
<li><a href="https://github.com/Insprill">Insprill</a> - Co-Developer, Linux Developer, AUR Maintainer.</li>
<li><a href="https://github.com/silentrald">silentrald</a> - Co-Developer, Linux Developer, deb and flatpak Maintainer.</li>
</ul>
</div>

Expand Down
6 changes: 6 additions & 0 deletions build/after-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add write permissions to anybody so that this can be sync with the
# github's bs-versions.json when starting bsmanager
/usr/bin/chmod +002 /opt/BSManager/resources/assets/jsons/bs-versions.json

# https://github.com/electron/electron/issues/42510
/usr/bin/chmod 4755 /opt/BSManager/chrome-sandbox
86 changes: 86 additions & 0 deletions docs/wiki/Linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Linux Guide

## Installation

Go to [Releases](https://github.com/Zagrios/bs-manager/releases) page and go to the latest release. Download the necessary build installer for your distro (see below).

### Ubuntu, Debian (deb)

Download the `.deb` file in the releases and run the following command:
```bash
dpkg -i ./bsmanager.deb
```

### Arch (AUR)

Refer to [bs-manager-git](https://aur.archlinux.org/packages/bs-manager-git).

To install AUR packages, you need to install [yay](https://github.com/Jguer/yay).

### Universal (flatpak)

This should work on any linux distribution. You are only required to have `flatpak` installed in your system. If it is not installed, then go to [flatpak](https://flatpak.org/setup/) to look for a guide on how to install it on your distro.

After installing, download the `.flatpak` file in the releases and run the following command:

```bash
flatpak install --user ./bsmanager.flatpak
```

If you are getting errors like packages not existing, run the command below so that it finds the correct packages.

```bash
sudo flatpak remote-add --if-not-exists --system flathub https://flathub.org/repo/flathub.flatpakrepo

# or

flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo
```

Flatpak also supports sandboxing which gives the minimal access to your machine. To configure this, you can download [Flatseal](https://flathub.org/apps/com.github.tchx84.Flatseal) which has a GUI to edit your permissions. You can also this with the `flatpak` executable but it will not be discussed here.

## Proton Setup

[Proton](https://github.com/ValveSoftware/Proton) is needed to run the Beat Saber executable under Linux. You need to download this from either from Steam or building it from their GitHub repo.

Once Proton is installed, when you open your BSManager application for the first time, it will ask you to link the _Proton Folder_. The _Proton Folder_ also verifies if the `proton` and `files/bin/wine64` binaries exists. Once set, you should be able to launch the Beat Saber (using `proton`) and install mods (using `files/bin/wine64`). You can still change the _Proton Folder_ in the **settings page** if any new version of Steam Proton is downloaded.

# Troubleshooting

## Permission denied on "bs-versions.json"

<pre>
Unhandled Exception UnhandledRejection Error: EACCES: permission denied, open '/opt/BSManager/resources/assets/jsons/bs-versions.json'
</pre>

To fix this issue, the current user must have write permissions to the "bs-versions.json". To correct the permissions do command below:

```bash
chmod +002 /opt/BSManager/resources/assets/jsons/bs-versions.json

# or

chown $(whoami) /opt/BSManager/resources/assets/jsons/bs-versions.json
```

## [deb] The SUID sandbox helper binary was found.

This is encountered when running the app file or executing the app in the terminal. This is due to a change to Ubuntu 24.04. In order to fix the issue, take a look into the path of "chrome-sandbox" described in the error log and give the correct permissions within the terminal, for example:

```bash
chmod 4755 /opt/BSManager/chrome-sandbox
```

ref: https://github.com/electron/electron/issues/42510

## [Flatpak] Steam Beat Saber version not showing / Proton not detected

Flatpak should have permissions with the steam games folder. By default, the minimum permissions are `~/.steam/steam/steamapps/common:ro` and `~/.steam/steam/steamapps/common:ro`. If you changed the steam installation path, add that path instead into the permissions.

## [Flatpak] Changing installation folder

To change the installation path of the **BSManager** folder, you have to edit the flatpak permissions to destination folder.
- In flatpak or Flatseal, add the destination folder with `:create` permissions.
- In BSM, move the folder to the destination folder.
- [Optional] In flatpak or Flatseal, remove the original folder permissions.

94 changes: 94 additions & 0 deletions electron-builder.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
const config = {
extraResources: [
"./assets/jsons/bs-versions.json",
"./assets/jsons/patreons.json",
"./assets/proto/song_details_cache_v1.proto"
],
productName: "BSManager",
appId: "org.erb.BSManager",
asarUnpack: "**\\*.{node,dll}",
files: [
"dist/**/*",
"node_modules",
"package.json"
],
afterSign: ".erb/scripts/notarize.js",
afterPack: ".erb/scripts/after-pack.js",
win: {
signingHashAlgorithms: ["sha256"],
target: [
"nsis",
"nsis-web"
],
icon: "./build/icons/win/favicon.ico",
extraResources: [
"./build/icons/win",
"./assets/scripts/*.exe"
],
},
linux: {
target: [
"deb",
],
icon: "./build/icons/png",
category: "Utility;Game;",
extraResources: [
"./build/icons/png",
"./assets/scripts/DepotDownloader"
],
protocols: {
name: "BSManager",
schemes: [
"bsmanager",
"beatsaver",
"bsplaylist",
"modelsaber",
"web+bsmap",
],
},
},
deb: {
fpm: ["--after-install=build/after-install.sh"],
},
flatpak: {
finishArgs: [
// Wayland/X11 Rendering
"--socket=wayland",
"--socket=x11",
"--share=ipc",
// Open GL
"--device=dri",
// Audio output
"--socket=pulseaudio",
// Read/write home directory access
"--filesystem=~/BSManager:create", // Default BSManager installation folder
"--filesystem=~/.steam/steam/steamapps:ro", // for the libraryfolders.vdf
"--filesystem=~/.steam/steam/steamapps/common:ro", // Steam game folder
"--filesystem=~/.steam/steam/steamapps/common/Beat Saber:create", // For installing mods/maps to original Beat Saber version
// Allow communication with network
"--share=network",
// System notifications with libnotify
"--talk-name=org.freedesktop.Notifications",
"--talk-name=org.freedesktop.Flatpak",
]
},
directories: {
app: "release/app",
buildResources: "assets",
output: "release/build",
},
publish: {
provider: "github",
owner: "Zagrios",
},
fileAssociations: [
{
ext: "bplist",
description: "Beat Saber Playlist (BSManager)",
icon: "./assets/bsm_file.ico",
role: "Viewer",
},
],
};

module.exports = config;
60 changes: 4 additions & 56 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"rebuild": "electron-rebuild --parallel --types prod,dev,optional --module-dir release/app",
"prestart": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.main.dev.ts",
"lint": "cross-env NODE_ENV=development eslint . --ext .js,.jsx,.ts,.tsx",
"package": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --publish never && npm run build:dll",
"package": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --config electron-builder.config.js && npm run build:dll",
"start": "ts-node ./.erb/scripts/check-port-in-use.js && npm run prestart && npm run start:renderer",
"start:main": "concurrently -k \"cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --watch --config ./.erb/configs/webpack.config.main.dev.ts\" \"electronmon .\"",
"start:preload": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.preload.dev.ts",
"start:renderer": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack serve --config ./.erb/configs/webpack.config.renderer.dev.ts",
"test": "jest",
"test:unit": "jest ./src/__tests__/unit",
"publish": "npm run build && electron-builder -c.win.certificateSha1=2164d6a7d641ecf6ad57852f665a518ca2bf960f --publish always --win --x64",
"publish:linux": "npm run build && electron-builder --publish always --linux --x64"
"publish": "npm run build && electron-builder -c.win.certificateSha1=2164d6a7d641ecf6ad57852f665a518ca2bf960f --config electron-builder.config.js --publish always --win --x64",
"publish:linux": "npm run build && electron-builder --config electron-builder.config.js --publish never --linux --x64"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": [
Expand All @@ -38,63 +38,11 @@
]
},
"build": {
"extraResources": [
"./assets/jsons/bs-versions.json",
"./assets/jsons/patreons.json",
"./assets/proto/song_details_cache_v1.proto"
],
"productName": "BSManager",
"appId": "org.erb.BSManager",
"asarUnpack": "**\\*.{node,dll}",
"files": [
"dist/**/*",
"node_modules",
"package.json"
],
"afterSign": ".erb/scripts/notarize.js",
"afterPack": ".erb/scripts/after-pack.js",
"win": {
"signingHashAlgorithms": [
"sha256"
],
"target": [
"nsis",
"nsis-web"
],
"icon": "./build/icons/win/favicon.ico",
"extraResources": [
"./build/icons/win",
"./assets/scripts/*.exe"
]
},
"linux": {
"target": [
"AppImage"
],
"icon": "./build/icons/png",
"category": "Utility;Game;",
"extraResources": [
"./build/icons/png",
"./assets/scripts/DepotDownloader"
]
},
"directories": {
"app": "release/app",
"buildResources": "assets",
"output": "release/build"
},
"publish": {
"provider": "github",
"owner": "Zagrios"
},
"fileAssociations": [
{
"ext": "bplist",
"description": "Beat Saber Playlist (BSManager)",
"icon": "./assets/bsm_file.ico",
"role": "Viewer"
}
]
}
},
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 5462c88

Please sign in to comment.