Add Steam Deck script and update README and build script for Distrobox support

This commit is contained in:
azazelv5 2025-03-03 18:58:57 -06:00
parent 7f7c94698e
commit ff99cc2a5f
4 changed files with 228 additions and 13 deletions

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
*.tar.zst
*.AppImage
*.Dockerfile
/linux-binaries*
/linux-binaries*
/workdir

View file

@ -128,7 +128,7 @@ cmake .. -GNinja \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
ninja
sudo ninja install
ninja install
# Set output file name
if [[ "$CITRON_VERSION" == "master" ]]; then
@ -146,12 +146,12 @@ fi
# Build the AppImage
cd ${WORKING_DIR}/Citron
sudo ${WORKING_DIR}/Citron/appimage-builder.sh citron ${WORKING_DIR}/Citron/build
${WORKING_DIR}/Citron/appimage-builder.sh citron ${WORKING_DIR}/Citron/build
# Prepare AppImage deployment
cd ${WORKING_DIR}/Citron/build/deploy-linux
sudo cp /usr/lib/libSDL3.so* ${WORKING_DIR}/Citron/build/deploy-linux/AppDir/usr/lib/
sudo wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
cp /usr/lib/libSDL3.so* ${WORKING_DIR}/Citron/build/deploy-linux/AppDir/usr/lib/
wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x appimagetool-x86_64.AppImage
# Workaround for lack of FUSE support in WSL
./appimagetool-x86_64.AppImage --appimage-extract

View file

@ -1,22 +1,30 @@
# Citron Docker Builder
# Citron AppImage Builder
This repository contains a script to build [Citron](https://git.citron-emu.org/Citron/Citron) using an Arch Linux Docker container. It automates the process of setting up a clean environment and generating a Citron AppImage for Steam Deck with support for multiple build modes.
This repository contains scripts to build [Citron](https://git.citron-emu.org/Citron/Citron) using either an Arch Linux Docker container or a Distrobox container for Steam Deck. It automates the process of setting up a clean environment and generating a Citron AppImage with support for multiple build modes.
## Features
- Uses Docker to provide a consistent build environment.
- Uses Docker or Distrobox to provide a consistent build environment.
- Supports multiple build modes (`release`, `steamdeck`, `compatibility`, `debug`).
- Included Windows batch file for automated start with interactive prompt for all options.
- Outputs a Citron AppImage in the current working directory.
- Option to output Linux binaries separately.
- Option to cache the Citron Git repository for subsequent builds.
- Dedicated Steam Deck script (`start_build_steamdeck_distrobox.sh`) for easier execution on Steam Deck.
## Requirements
### Windows
- [Docker Desktop for Windows](https://docs.docker.com/desktop/setup/install/windows-install/) installed and running on your system.
### Steam Deck
- SteamOS 3.5+ with [Distrobox](https://github.com/89luca89/distrobox) preinstalled.
- Sufficient disk space (~5GB for build process).
### Linux / macOS
- [Docker](https://docs.docker.com/get-docker/) installed.
**Note for users on ARM-based devices (e.g., macOS M1/M2, Raspberry Pi, AWS Graviton, or similar ARM64 platforms):** If you encounter issues during the build process, it may be due to architecture incompatibilities. Try one of the following solutions:
@ -37,13 +45,16 @@ This repository contains a script to build [Citron](https://git.citron-emu.org/C
### Windows
1. Clone this repository:
```sh
git clone https://github.com/azazelv5/citron-appimage-builder.git
cd citron-appimage-builder
```
Alternatively, you can download the repository as a zip file and extract it.
2. Run the batch script:
```sh
start_build_windows_wsl.bat
```
@ -57,13 +68,16 @@ This repository contains a script to build [Citron](https://git.citron-emu.org/C
### Linux / macOS
1. Clone this repository:
```sh
git clone https://github.com/azazelv5/citron-appimage-builder.git
cd citron-appimage-builder
```
Alternatively, you can download the repository as a zip file and extract it.
2. Build and run the Docker container:
```sh
docker build -t citron-builder .
docker run --rm -v "$(pwd)":/output citron-builder
@ -74,13 +88,45 @@ This repository contains a script to build [Citron](https://git.citron-emu.org/C
4. The Citron AppImage file will be created in the current directory.
5. (Optional) Remove the citron-builder image to save disk space:
```sh
docker rmi -f citron-builder
```
## Options
### Steam Deck (Distrobox)
Modify the docker run command accordingly, depending on your needs:
1. Switch to [Desktop Mode](https://help.steampowered.com/en/faqs/view/671A-4453-E8D2-323C).
2. Open a terminal (Konsole is the default terminal app).
3. Ensure you are in your home directory:
```sh
cd ~
```
4. Clone this repository:
```sh
git clone https://github.com/azazelv5/citron-appimage-builder.git
cd citron-appimage-builder
```
5. Make the script executable:
```sh
chmod +x start_build_steamdeck_distrobox.sh
```
6. Run the Steam Deck build script:
```sh
./start_build_steamdeck_distrobox.sh
```
7. Follow the on-screen prompts to select your build mode and Citron version.
8. The Citron AppImage file will be created in the current directory.
## Options (Docker)
For users running Linux or macOS, you can modify the Docker run command accordingly:
- Use the default command for the latest Citron build optimized for Steam Deck:
```sh
@ -96,24 +142,26 @@ Modify the docker run command accordingly, depending on your needs:
```sh
docker run --rm -e CITRON_BUILD_MODE=compatibility -e CITRON_VERSION=v0.5-canary-refresh -v "$(pwd)":/output citron-builder
```
- Enable Linux binary output if you need separate non-AppImage executables:
```sh
docker run --rm -e OUTPUT_LINUX_BINARIES=true -v "${pwd}":/output citron-builder
docker run --rm -e OUTPUT_LINUX_BINARIES=true -v "$(pwd)":/output citron-builder
```
- Use cache options to speed up subsequent builds by preserving Citron's source repository between runs:
```sh
docker run --rm -e USE_CACHE=true -v "${pwd}":/output citron-builder
docker run --rm -e USE_CACHE=true -v "$(pwd)":/output citron-builder
```
## Output Naming
The generated AppImage filename will follow this format:
- **Latest builds:** `citron-nightly-<build_mode>-<timestamp>-<commit_hash>.AppImage`
- **Versioned builds:** `citron-<version>-<build_mode>.AppImage`
For example:
```sh
citron-nightly-steamdeck-20250228-153045-abcdefg.AppImage
citron-v0.5-canary-refresh-release.AppImage

View file

@ -0,0 +1,166 @@
#!/bin/bash
# =========================================================
# Title: Citron AppImage Build Steam Deck Script
# Description: Builds and runs an Arch Linux container inside Distrobox
# to create a Citron AppImage.
# =========================================================
set -e # Exit immediately if any command fails
echo "======================================="
echo " Citron AppImage Build Steam Deck Script"
echo "======================================="
echo "This script will build a Citron AppImage using Distrobox."
echo "Distrobox should be preinstalled with SteamOS 3.5."
echo ""
# =========================================================
# CHECK FOR DISTROBOX INSTALLATION
# =========================================================
echo ">>> Checking for Distrobox installation..."
if ! command -v distrobox &> /dev/null; then
echo -e "\n========================================================"
echo " ERROR: Distrobox is not installed on your system."
echo " Please install Distrobox manually or update your SteamOS to 3.5+."
echo -e "========================================================\n"
exit 1
fi
echo "✔ Distrobox is installed. Proceeding with setup..."
echo ""
# =========================================================
# ASK USER FOR VERSION SELECTION
# =========================================================
echo ">>> Select the Citron version to build:"
echo " 1. Latest master branch (nightly build)"
echo " 2. Citron Canary Refresh Version 0.5"
echo " 3. Citron Canary Refresh Version 0.4"
echo " 4. Specific version (Tag or Branch name)"
read -rp "Enter choice [1-4]: " VERSION_CHOICE
case "$VERSION_CHOICE" in
1) CITRON_VERSION="master" ;;
2) CITRON_VERSION="v0.5-canary-refresh" ;;
3) CITRON_VERSION="v0.4-canary-refresh" ;;
4) read -rp "Enter the version (Tag/Branch): " CITRON_VERSION ;;
*) echo "Invalid choice. Defaulting to latest master branch."; CITRON_VERSION="master" ;;
esac
echo ""
# =========================================================
# ASK USER FOR BUILD MODE
# =========================================================
echo ">>> Select the build mode:"
echo " 1. SteamDeck optimizations"
echo " 2. Release mode"
echo " 3. Compatibility mode (for older architectures)"
echo " 4. Debug mode"
read -rp "Enter choice [1-4]: " BUILD_MODE_CHOICE
case "$BUILD_MODE_CHOICE" in
1) CITRON_BUILD_MODE="steamdeck" ;;
2) CITRON_BUILD_MODE="release" ;;
3) CITRON_BUILD_MODE="compatibility" ;;
4) CITRON_BUILD_MODE="debug" ;;
*) echo "Invalid choice. Defaulting to SteamDeck optimizations."; CITRON_BUILD_MODE="steamdeck" ;;
esac
echo ""
# =========================================================
# ASK USER ABOUT CACHING GIT REPOSITORY
# =========================================================
echo ">>> Do you want to cache the Git repository for subsequent builds?"
echo " 1. Yes (may use ~1 GB of disk space)"
echo " 2. No (default)"
read -rp "Enter choice [1-2]: " CACHE_REPO
USE_CACHE=false
if [[ "$CACHE_REPO" == "1" ]]; then
USE_CACHE=true
fi
echo ""
# =========================================================
# ASK USER ABOUT OUTPUTTING LINUX BINARIES
# =========================================================
echo ">>> Do you want to output Linux binaries?"
echo " 1. Yes"
echo " 2. No (default)"
read -rp "Enter choice [1-2]: " OUTPUT_BINARIES
OUTPUT_LINUX_BINARIES=false
if [[ "$OUTPUT_BINARIES" == "1" ]]; then
OUTPUT_LINUX_BINARIES=true
fi
echo ""
# =========================================================
# CREATE AND ENTER DISTROBOX CONTAINER
# =========================================================
CONTAINER_NAME="citron-builder"
echo ">>> Checking if Distrobox container '$CONTAINER_NAME' exists..."
if ! distrobox list | grep -q "$CONTAINER_NAME"; then
echo "Creating a new Distrobox container with Arch Linux..."
distrobox create --name "$CONTAINER_NAME" --yes --image archlinux:latest --additional-packages "base-devel boost catch2 cmake ffmpeg fmt git glslang libzip lz4 mbedtls ninja nlohmann-json openssl opus qt5 sdl2 zlib zstd zip unzip qt6-base qt6-tools qt6-svg qt6-declarative qt6-webengine sdl3 qt6-multimedia clang qt6-wayland fuse2 rapidjson wget sdl3 dos2unix"
else
echo "Using existing Distrobox container '$CONTAINER_NAME'."
echo "If you encounter issues, try removing it manually with: 'distrobox rm -f $CONTAINER_NAME'."
fi
echo ""
# =========================================================
# SET OUTPUT AND WORKING DIRECTORIES
# =========================================================
OUTPUT_DIR="$(pwd)"
WORKING_DIR="$(pwd)/workdir"
mkdir -p "$WORKING_DIR"
chmod 777 "$WORKING_DIR"
# =========================================================
# ENTERING AND PREPARING THE DISTROBOX CONTAINER
# =========================================================
echo ">>> Entering and preparing the Distrobox container..."
distrobox enter --additional-flags "--env CITRON_VERSION=$CITRON_VERSION --env CITRON_BUILD_MODE=$CITRON_BUILD_MODE --env USE_CACHE=$USE_CACHE --env OUTPUT_LINUX_BINARIES=$OUTPUT_LINUX_BINARIES --env OUTPUT_DIR=$OUTPUT_DIR --env WORKING_DIR=$WORKING_DIR" "$CONTAINER_NAME" -- bash << 'EOF'
dos2unix ./build-citron.sh
chmod +x ./build-citron.sh
echo ">>> Inside container, executing build script..."
./build-citron.sh
EOF
# =========================================================
# CLEANUP WORKING DIRECTORY
# =========================================================
echo ">>> Cleaning up working directory..."
rm -rf "$WORKING_DIR"
echo "✔ Cleanup complete."
echo ""
# =========================================================
# ASK USER TO REMOVE DISTROBOX CONTAINER
# =========================================================
read -rp "Do you want to remove the '$CONTAINER_NAME' Distrobox container? ([Y]/n): " DELETE_BOX
if [[ "$DELETE_BOX" =~ ^[Yy]?$ ]]; then
distrobox rm --force "$CONTAINER_NAME"
echo "✔ Distrobox container removed."
else
echo "✔ Distrobox container kept."
fi
echo ""
# =========================================================
# ASK USER TO DELETE CACHED GIT REPOSITORY
# =========================================================
if [ -f citron.tar.zst ]; then
read -rp "Do you want to delete the cached repository file citron.tar.zst to free up space? (y/[N]): " DELETE_CACHE
if [[ "$DELETE_CACHE" =~ ^[Yy]$ ]]; then
rm -f citron.tar.zst
echo "✔ Cache deleted."
else
echo "✔ Cache kept."
fi
fi