better installer and portable mode
This commit is contained in:
parent
ada55faf13
commit
53a02cc7da
6 changed files with 97 additions and 79 deletions
13
README.md
13
README.md
|
|
@ -24,14 +24,19 @@ npm start
|
||||||
|
|
||||||
## Building & installing
|
## Building & installing
|
||||||
|
|
||||||
`./build.sh` produces `build/PLWL-<version>.tar.gz`: the Electron runtime with the whole app (code, renderer and bundled `files/`) packed into `electron/resources/app.asar`, plus a `plwl` launcher, a `plwl.desktop` template and `install.sh`:
|
`./build.sh` produces `build/PLWL-<version>.tar.gz`: the Electron runtime renamed to `olcxja.plwl/` (binary `olcxja.plwl/olcxja.plwl`) with the whole app (code, renderer and bundled `files/`) packed into `olcxja.plwl/resources/app.asar`, plus the `olcxja.plwl.png` icon, `install.sh` and `createshortcut.sh`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
tar -xzf PLWL-<version>.tar.gz
|
tar -xzf PLWL-<version>.tar.gz
|
||||||
cd PLWL
|
cd PLWL
|
||||||
./install.sh # copies to ~/.local/lib/PLWL, adds ~/.local/bin/plwl + a desktop shortcut, launches the app
|
./install.sh # copies everything to ~/.local/bin/olcxja.plwl/,
|
||||||
# or run without installing:
|
# installs the icon (olcxja.plwl.png) + shortcut
|
||||||
./plwl
|
# removes the extraction folder, launches
|
||||||
|
|
||||||
|
./createshortcut.sh # portable mode: only installs the icon + shortcut
|
||||||
|
|
||||||
|
# or run without any shortcuts:
|
||||||
|
./olcxja.plwl/olcxja.plwl
|
||||||
```
|
```
|
||||||
|
|
||||||
## Wine & Proton support
|
## Wine & Proton support
|
||||||
|
|
|
||||||
32
build.sh
32
build.sh
|
|
@ -15,37 +15,21 @@ fi
|
||||||
|
|
||||||
rm -rf build/dist
|
rm -rf build/dist
|
||||||
mkdir -p build/dist/PLWL
|
mkdir -p build/dist/PLWL
|
||||||
cp -r node_modules/electron/dist build/dist/PLWL/electron
|
cp -r node_modules/electron/dist build/dist/PLWL/olcxja.plwl
|
||||||
|
mv build/dist/PLWL/olcxja.plwl/electron build/dist/PLWL/olcxja.plwl/olcxja.plwl
|
||||||
|
chmod +x build/dist/PLWL/olcxja.plwl/olcxja.plwl
|
||||||
|
|
||||||
# 2. Pack the app payload (code + renderer + bundled files) into app.asar.
|
# 2. Pack the app payload (code + renderer + bundled files) into app.asar.
|
||||||
STAGE=build/dist/.app-stage
|
STAGE=build/dist/.app-stage
|
||||||
mkdir -p "$STAGE"
|
mkdir -p "$STAGE"
|
||||||
cp -r src renderer files package.json "$STAGE/"
|
cp -r src renderer files package.json "$STAGE/"
|
||||||
npx asar pack "$STAGE" build/dist/PLWL/electron/resources/app.asar
|
npx asar pack "$STAGE" build/dist/PLWL/olcxja.plwl/resources/app.asar
|
||||||
rm -rf "$STAGE"
|
rm -rf "$STAGE"
|
||||||
|
|
||||||
# 3. Launcher, desktop entry and installer.
|
# 3. Icon, installer and portable-shortcut helper.
|
||||||
cat > build/dist/PLWL/plwl << 'EOF'
|
cp renderer/plwl.png build/dist/PLWL/olcxja.plwl.png
|
||||||
#!/usr/bin/env bash
|
cp tools/install.sh tools/createshortcut.sh build/dist/PLWL/
|
||||||
set -e
|
chmod +x build/dist/PLWL/install.sh build/dist/PLWL/createshortcut.sh
|
||||||
cd "$(dirname "$0")"
|
|
||||||
exec ./electron/electron . "$@"
|
|
||||||
EOF
|
|
||||||
chmod +x build/dist/PLWL/plwl
|
|
||||||
|
|
||||||
cat > build/dist/PLWL/plwl.desktop << 'EOF'
|
|
||||||
[Desktop Entry]
|
|
||||||
Type=Application
|
|
||||||
Name=PLWL
|
|
||||||
Comment=Portable Linux Wine Launcher
|
|
||||||
Exec=plwl
|
|
||||||
Icon=plwl
|
|
||||||
Terminal=false
|
|
||||||
Categories=Game;
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cp tools/install.sh build/dist/PLWL/install.sh
|
|
||||||
chmod +x build/dist/PLWL/install.sh
|
|
||||||
|
|
||||||
# 4. Tarball.
|
# 4. Tarball.
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
|
||||||
const APP_NAME = 'PLWL'
|
|
||||||
|
|
||||||
function findPng() {
|
function findPng() {
|
||||||
const p = path.resolve(__dirname, '..', 'renderer', 'plwl.png')
|
const p = path.resolve(__dirname, '..', 'renderer', 'plwl.png')
|
||||||
try {
|
try {
|
||||||
|
|
@ -15,44 +13,12 @@ function findPng() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeIconThemeDirs(png) {
|
|
||||||
try {
|
|
||||||
const sizes = { '16x16': 16, '32x32': 32, '48x48': 48, '256x256': 256 }
|
|
||||||
const home = process.env.HOME
|
|
||||||
if (!home) return
|
|
||||||
const exe = path.join(require('./paths').APP_ROOT, 'plwl')
|
|
||||||
const execPath = fs.existsSync(exe)
|
|
||||||
? exe
|
|
||||||
: (process.env.PLWL_EXEC || 'plwl')
|
|
||||||
const base = path.join(home, '.local', 'share', 'icons')
|
|
||||||
for (const [dir, size] of Object.entries(sizes)) {
|
|
||||||
const themeDir = path.join(base, 'hicolor', dir, 'apps')
|
|
||||||
fs.mkdirSync(themeDir, { recursive: true })
|
|
||||||
fs.copyFileSync(png, path.join(themeDir, 'plwl.png'))
|
|
||||||
}
|
|
||||||
const desktopDir = path.join(home, '.local', 'share', 'applications')
|
|
||||||
fs.mkdirSync(desktopDir, { recursive: true })
|
|
||||||
const desktop = [
|
|
||||||
'[Desktop Entry]',
|
|
||||||
'Type=Application',
|
|
||||||
`Name=${APP_NAME}`,
|
|
||||||
'Comment=Portable Linux Wine Launcher',
|
|
||||||
`Exec=${execPath}`,
|
|
||||||
`Icon=plwl`,
|
|
||||||
'Terminal=false',
|
|
||||||
'Categories=Game;'
|
|
||||||
].join('\n')
|
|
||||||
fs.writeFileSync(path.join(desktopDir, 'plwl.desktop'), desktop)
|
|
||||||
} catch {}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setAppIcon(app) {
|
function setAppIcon(app) {
|
||||||
const png = findPng()
|
const png = findPng()
|
||||||
if (!png) return
|
if (!png) return
|
||||||
try {
|
try {
|
||||||
app.setIcon(png)
|
app.setIcon(png)
|
||||||
} catch {}
|
} catch {}
|
||||||
writeIconThemeDirs(png)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { setAppIcon }
|
module.exports = { setAppIcon }
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
|
||||||
// Packaged builds run from <portable root>/electron/resources/app.asar:
|
// Packaged builds run from <portable root>/olcxja.plwl/resources/app.asar:
|
||||||
// the portable layout (<root>/files) is two levels above the resources dir
|
// the portable layout (<root>/files) is two levels above the resources dir
|
||||||
// and files bundled with the release are unpacked next to the asar.
|
// and files bundled with the release are unpacked next to the asar.
|
||||||
function computeRoots() {
|
function computeRoots() {
|
||||||
|
|
|
||||||
41
tools/createshortcut.sh
Normal file
41
tools/createshortcut.sh
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# PLWL portable shortcut creator — bundled inside the release tarball.
|
||||||
|
# Installs the icon into the user icon theme and creates a .desktop entry
|
||||||
|
# pointing at ./olcxja.plwl/olcxja.plwl in the folder this script lives in
|
||||||
|
# (portable mode — no files are copied anywhere).
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
APP_DIR="$HOME/.local/share/applications"
|
||||||
|
ICON_BASE="$HOME/.local/share/icons/hicolor"
|
||||||
|
ICON_SRC="$SCRIPT_DIR/olcxja.plwl.png"
|
||||||
|
EXE="$SCRIPT_DIR/olcxja.plwl/olcxja.plwl"
|
||||||
|
|
||||||
|
[ -f "$EXE" ] || { echo "createshortcut.sh: olcxja.plwl runtime not found in $SCRIPT_DIR" >&2; exit 1; }
|
||||||
|
chmod +x "$EXE" 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "1. Installing icon..."
|
||||||
|
if [ -f "$ICON_SRC" ]; then
|
||||||
|
for dir in 16x16 32x32 48x48 256x256; do
|
||||||
|
mkdir -p "$ICON_BASE/$dir/apps"
|
||||||
|
cp "$ICON_SRC" "$ICON_BASE/$dir/apps/olcxja.plwl.png"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "2. Creating shortcut..."
|
||||||
|
mkdir -p "$APP_DIR"
|
||||||
|
cat > "$APP_DIR/olcxja.plwl.desktop" << EOF
|
||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=PLWL
|
||||||
|
Comment=Portable Linux Wine Launcher
|
||||||
|
Exec="$EXE"
|
||||||
|
Icon=olcxja.plwl
|
||||||
|
Terminal=false
|
||||||
|
Categories=Game;
|
||||||
|
EOF
|
||||||
|
chmod +x "$APP_DIR/olcxja.plwl.desktop"
|
||||||
|
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$APP_DIR" 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "Shortcut created: $APP_DIR/olcxja.plwl.desktop -> $EXE"
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# PLWL installer — bundled inside the release tarball (build/PLWL-<version>.tar.gz).
|
# PLWL installer — bundled inside the release tarball (build/PLWL-<version>.tar.gz).
|
||||||
# Modeled after LarpixClient's install.sh: copies the app into ~/.local,
|
|
||||||
# registers a desktop shortcut and removes the extraction folder.
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "WARNING: Make sure you don't run this script in a folder that contains anything more than PLWL"
|
echo "WARNING: Make sure you don't run this script in a folder that contains anything more than PLWL"
|
||||||
|
|
@ -11,35 +9,59 @@ read -r -p "Press Enter to continue (or Ctrl+C, to cancel)..."
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
INSTALL_DIR="$HOME/.local/lib/PLWL"
|
INSTALL_DIR="$HOME/.local/bin/olcxja.plwl"
|
||||||
BIN_DIR="$HOME/.local/bin"
|
|
||||||
APP_DIR="$HOME/.local/share/applications"
|
APP_DIR="$HOME/.local/share/applications"
|
||||||
|
ICON_BASE="$HOME/.local/share/icons/hicolor"
|
||||||
|
ICON_SRC="$SCRIPT_DIR/olcxja.plwl.png"
|
||||||
|
EXE="$INSTALL_DIR/olcxja.plwl/olcxja.plwl"
|
||||||
|
|
||||||
if [ "$SCRIPT_DIR" = "$INSTALL_DIR" ] || [ "$SCRIPT_DIR" = "$HOME" ] || [ "$SCRIPT_DIR" = "/" ]; then
|
if [ "$SCRIPT_DIR" = "$INSTALL_DIR" ] || [ "$SCRIPT_DIR" = "$HOME" ] || [ "$SCRIPT_DIR" = "/" ]; then
|
||||||
echo "install.sh: refusing to run from '$SCRIPT_DIR'" >&2
|
echo "install.sh: refusing to run from '$SCRIPT_DIR'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
case "$INSTALL_DIR/" in
|
||||||
|
"$SCRIPT_DIR"/*)
|
||||||
|
echo "install.sh: refusing to install into the extraction folder ('$SCRIPT_DIR')" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
[ -f "$SCRIPT_DIR/olcxja.plwl/olcxja.plwl" ] || { echo "install.sh: olcxja.plwl runtime not found in $SCRIPT_DIR" >&2; exit 1; }
|
||||||
|
|
||||||
echo "1. Copying files..."
|
echo "1. Copying files..."
|
||||||
mkdir -p "$INSTALL_DIR" "$BIN_DIR" "$APP_DIR"
|
mkdir -p "$INSTALL_DIR" "$APP_DIR"
|
||||||
cp -r "$SCRIPT_DIR/." "$INSTALL_DIR/"
|
cp -r "$SCRIPT_DIR/." "$INSTALL_DIR/"
|
||||||
|
|
||||||
echo "2. Creating shortcut..."
|
echo "2. Installing icon..."
|
||||||
sed -i "s|^Exec=.*|Exec=$BIN_DIR/plwl|" "$INSTALL_DIR/plwl.desktop"
|
if [ -f "$ICON_SRC" ]; then
|
||||||
mv "$INSTALL_DIR/plwl.desktop" "$APP_DIR/plwl.desktop"
|
for dir in 16x16 32x32 48x48 256x256; do
|
||||||
chmod +x "$APP_DIR/plwl.desktop"
|
mkdir -p "$ICON_BASE/$dir/apps"
|
||||||
|
cp "$ICON_SRC" "$ICON_BASE/$dir/apps/olcxja.plwl.png"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
echo "3. Adding executable permissions..."
|
echo "3. Creating shortcut..."
|
||||||
chmod +x "$INSTALL_DIR/plwl"
|
cat > "$APP_DIR/olcxja.plwl.desktop" << EOF
|
||||||
ln -sfn "$INSTALL_DIR/plwl" "$BIN_DIR/plwl"
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=PLWL
|
||||||
|
Comment=Portable Linux Wine Launcher
|
||||||
|
Exec="$EXE"
|
||||||
|
Icon=olcxja.plwl
|
||||||
|
Terminal=false
|
||||||
|
Categories=Game;
|
||||||
|
EOF
|
||||||
|
chmod +x "$APP_DIR/olcxja.plwl.desktop"
|
||||||
|
|
||||||
echo "4. Cleaning installation..."
|
echo "4. Adding executable permissions..."
|
||||||
rm -f "$INSTALL_DIR/install.sh"
|
chmod +x "$EXE"
|
||||||
|
|
||||||
|
echo "5. Cleaning installation..."
|
||||||
|
rm -f "$INSTALL_DIR/install.sh" "$INSTALL_DIR/createshortcut.sh"
|
||||||
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$APP_DIR" 2>/dev/null || true
|
command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$APP_DIR" 2>/dev/null || true
|
||||||
|
|
||||||
echo "5. Installation completed. Cleaning up and launching..."
|
echo "6. Installation completed. Cleaning up and launching..."
|
||||||
rm -rf "${SCRIPT_DIR:?}"/*
|
rm -rf "${SCRIPT_DIR:?}"/*
|
||||||
nohup "$BIN_DIR/plwl" >/dev/null 2>&1 &
|
nohup "$EXE" >/dev/null 2>&1 &
|
||||||
disown 2>/dev/null || true
|
disown 2>/dev/null || true
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue