Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion packaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ This directory contains Linux packaging scripts for Tux Manager.

- Debian/Ubuntu (`.deb`) via `package-deb.sh`
- Fedora/RHEL/Alma/Rocky (`.rpm` + `.src.rpm`) via `package-rpm.sh`
- Flatpak (`.flatpak`) via `package-flatpak.sh`
- AppImage (`.AppImage`) via `package-appimage.sh`

## Unsupported targets
- Flatpak (`.flatpak`) via `package-flatpak.sh` - runs in container and doesn't allow access to host's /proc

## Dependencies

Expand Down Expand Up @@ -36,6 +39,8 @@ Notes:

### Flatpak

NOTE: flatpak doesn't work right now - the resulting app runs in isolation and doesn't have access to /proc so you can't use it to full extent

Required tools/runtime:

```bash
Expand All @@ -48,6 +53,28 @@ Notes:
- The script validates that `flatpak`, `flatpak-builder`, `flathub`, and required runtime/sdk refs are present before building.
- The resulting bundle is written to `packaging/output/`.

### AppImage

Required tools/packages:

* https://github.com/linuxdeploy/linuxdeploy
* https://github.com/linuxdeploy/linuxdeploy-plugin-qt
* https://github.com/linuxdeploy/linuxdeploy-plugin-appimage

Download released appimages from all 3, put them into some directory and create symlinks with bare names, then add this folder to PATH variable

```bash
sudo apt-get install build-essential pkg-config qt6-base-dev
linuxdeploy --version
linuxdeploy-plugin-qt --help
linuxdeploy-plugin-appimage --help
```

Notes:
- `linuxdeploy`, `linuxdeploy-plugin-qt`, and `linuxdeploy-plugin-appimage` must be available in `PATH`.
- The script reuses the desktop/icon metadata from `packaging/flatpak/`.
- The resulting AppImage is written to `packaging/output/`.

## Usage

From repo root:
Expand Down Expand Up @@ -105,6 +132,23 @@ Optional:
Output (in `packaging/output/`):
- `tux-manager-<version>-<arch>.flatpak`

### Build AppImage

```bash
cd packaging
./package-appimage.sh
```

Optional:

```bash
./package-appimage.sh --qt /path/to/qt/bin
./package-appimage.sh --version 1.2.3
```

Output (in `packaging/output/`):
- `tux-manager-<version>-<arch>.AppImage`

## Install

### Debian/Ubuntu
Expand All @@ -126,3 +170,10 @@ sudo dnf install packaging/output/tux-manager-*.rpm
flatpak install --user packaging/output/tux-manager-*.flatpak
flatpak run io.github.benapetr.TuxManager
```

### AppImage

```bash
chmod +x packaging/output/tux-manager-*.AppImage
./packaging/output/tux-manager-*.AppImage
```
158 changes: 158 additions & 0 deletions packaging/package-appimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#!/bin/bash
################################################################################
# package-appimage.sh - Build and package Tux Manager as an AppImage
################################################################################

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/config"

PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
OUTPUT_DIR="$PROJECT_ROOT/packaging/output"
BUILD_DIR="$PROJECT_ROOT/packaging/.appimage-build"
APPDIR="$PROJECT_ROOT/packaging/.AppDir"
DESKTOP_FILE_SRC="$PROJECT_ROOT/packaging/flatpak/io.github.benapetr.TuxManager.desktop"
ICON_FILE_SRC="$PROJECT_ROOT/packaging/flatpak/io.github.benapetr.TuxManager.svg"
METADATA_FILE_SRC="$PROJECT_ROOT/packaging/flatpak/io.github.benapetr.TuxManager.metainfo.xml"

QT_BIN_PATH=""
NCPUS=$(nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)

while [[ $# -gt 0 ]]; do
case "$1" in
--qt)
QT_BIN_PATH="$2"
shift 2
;;
--version)
APP_VERSION="$2"
shift 2
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--qt /path/to/qt/bin] [--version x.y.z]"
exit 1
;;
esac
done

if [ -n "$QT_BIN_PATH" ]; then
export PATH="$QT_BIN_PATH:$PATH"
fi

echo "================================="
echo "Building Tux Manager AppImage"
echo "================================="
echo "CPUs: $NCPUS"
echo "Version: $APP_VERSION"
echo ""

if [ -z "$QT_BIN_PATH" ]; then
if command -v qmake6 >/dev/null 2>&1; then
QMAKE_CMD="qmake6"
elif command -v qmake >/dev/null 2>&1; then
QMAKE_CMD="qmake"
else
echo "Error: qmake not found in PATH."
echo "Install Qt development tools or use --qt to specify Qt bin path."
exit 1
fi
else
if command -v qmake6 >/dev/null 2>&1; then
QMAKE_CMD="qmake6"
elif command -v qmake >/dev/null 2>&1; then
QMAKE_CMD="qmake"
else
echo "Error: qmake not found in specified Qt path: $QT_BIN_PATH"
exit 1
fi
fi

if ! command -v linuxdeploy >/dev/null 2>&1; then
echo "Error: linuxdeploy not found in PATH."
echo "Install linuxdeploy and re-run."
exit 1
fi

if ! command -v linuxdeploy-plugin-qt >/dev/null 2>&1; then
echo "Error: linuxdeploy-plugin-qt not found in PATH."
echo "Install linuxdeploy-plugin-qt and re-run."
exit 1
fi

if ! command -v linuxdeploy-plugin-appimage >/dev/null 2>&1; then
echo "Error: linuxdeploy-plugin-appimage not found in PATH."
echo "Install linuxdeploy-plugin-appimage and re-run."
exit 1
fi

if [ ! -f "$DESKTOP_FILE_SRC" ]; then
echo "Error: Desktop file not found: $DESKTOP_FILE_SRC"
exit 1
fi

if [ ! -f "$ICON_FILE_SRC" ]; then
echo "Error: Icon file not found: $ICON_FILE_SRC"
exit 1
fi

mkdir -p "$OUTPUT_DIR"
rm -rf "$BUILD_DIR" "$APPDIR"
mkdir -p "$BUILD_DIR" \
"$APPDIR/usr/bin" \
"$APPDIR/usr/share/applications" \
"$APPDIR/usr/share/icons/hicolor/scalable/apps" \
"$APPDIR/usr/share/metainfo"

echo "Step 1: Building application..."
cd "$BUILD_DIR"
"$QMAKE_CMD" "$PROJECT_ROOT/src/TuxManager.pro"
make -j"$NCPUS"

echo ""
echo "Step 2: Creating AppDir..."
install -Dm755 "$BUILD_DIR/$APP_NAME" "$APPDIR/usr/bin/$APP_NAME"
install -Dm644 "$DESKTOP_FILE_SRC" "$APPDIR/usr/share/applications/io.github.benapetr.TuxManager.desktop"
install -Dm644 "$ICON_FILE_SRC" "$APPDIR/usr/share/icons/hicolor/scalable/apps/io.github.benapetr.TuxManager.svg"
if [ -f "$METADATA_FILE_SRC" ]; then
install -Dm644 "$METADATA_FILE_SRC" "$APPDIR/usr/share/metainfo/io.github.benapetr.TuxManager.metainfo.xml"
fi

ln -sf usr/share/applications/io.github.benapetr.TuxManager.desktop "$APPDIR/io.github.benapetr.TuxManager.desktop"
ln -sf usr/share/icons/hicolor/scalable/apps/io.github.benapetr.TuxManager.svg "$APPDIR/io.github.benapetr.TuxManager.svg"

echo ""
echo "Step 3: Bundling AppImage..."
cd "$PROJECT_ROOT"
rm -f "$PROJECT_ROOT"/*.AppImage
export QMAKE
QMAKE="$(command -v "$QMAKE_CMD")"

linuxdeploy \
--appdir "$APPDIR" \
--desktop-file "$APPDIR/usr/share/applications/io.github.benapetr.TuxManager.desktop" \
--icon-file "$APPDIR/usr/share/icons/hicolor/scalable/apps/io.github.benapetr.TuxManager.svg" \
--plugin qt \
--output appimage

mapfile -t APPIMAGE_FILES < <(find "$PROJECT_ROOT" -maxdepth 1 -type f -name "*.AppImage" | sort) || true
if [ ${#APPIMAGE_FILES[@]} -eq 0 ]; then
echo "Error: linuxdeploy did not produce an AppImage."
exit 1
fi

ARCH="$(uname -m)"
OUTPUT_PATH="$OUTPUT_DIR/${APP_NAME}-${APP_VERSION}-${ARCH}.AppImage"
mv "${APPIMAGE_FILES[0]}" "$OUTPUT_PATH"

echo ""
echo "================================="
echo "Build complete!"
echo "================================="
echo "AppImage: $OUTPUT_PATH"
echo ""
echo "To run:"
echo " chmod +x $OUTPUT_PATH"
echo " $OUTPUT_PATH"
echo ""
Loading