Add Linux/macOS automated build script for Citron AppImage and update README

This commit is contained in:
azazelv5 2025-03-09 15:25:31 -06:00
parent 34f1b42ae3
commit 00539e1d6f
2 changed files with 172 additions and 19 deletions

View file

@ -10,8 +10,7 @@ This repository contains scripts to build [Citron](https://git.citron-emu.org/Ci
- `steamdeck`: Steamdeck mode builds Citron with optimizations for better performance.
- `compatibility`: Compatibility mode builds Citron with optimizations for older architectures.
- `debug`: Debug mode includes additional debugging symbols but is slower.
- Steam Deck starting script (`start_build_steamdeck_podman.sh`) for easier execution on Steam Deck without modifying SteamOS.
- Included Windows batch file (`start_build_windows_wsl.bat`) for automated start with interactive prompt for all options.
- Included startup scripts for Windows, Steam Deck, Linux, and macOS (`start_build_<OS>...`) that automate the build process with an 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.
@ -29,14 +28,15 @@ This repository contains scripts to build [Citron](https://git.citron-emu.org/Ci
```sh
podman --version
```
If not installed, install it from the Software Center.
If Podman is not installed, you can install it from the SteamOS Software Center.
- Sufficient disk space (\~5GB for the build process).
### Linux / macOS
- [Docker](https://docs.docker.com/get-docker/) installed.
**Note for users on ARM-based devices (e.g., macOS M1/M2 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:
### **Note for users on ARM-based devices (e.g., macOS M1/M2 or similar ARM64 platforms):**
If you encounter issues during the build process, it may be due to architecture incompatibilities with the docker image. Try one of the following solutions:
- Use an ARM64-compatible container image by specifying the platform explicitly:
```sh
docker build --platform=linux/arm64 -t citron-builder .
@ -48,6 +48,8 @@ This repository contains scripts to build [Citron](https://git.citron-emu.org/Ci
docker run --platform=linux/amd64 --rm -v "$(pwd)":/output citron-builder
```
Any feedback or contributions to improve the script for ARM-based host builds is welcome.
## Usage
### Windows
@ -73,7 +75,7 @@ This repository contains scripts to build [Citron](https://git.citron-emu.org/Ci
5. The Citron AppImage file will be created in the current directory.
6. The script will prompt you about optional disk cleanup.
6. After the build process, the script will prompt you to perform optional disk cleanup.
### Linux / macOS
@ -86,23 +88,24 @@ This repository contains scripts to build [Citron](https://git.citron-emu.org/Ci
Alternatively, download and extract the repository as a ZIP file.
2. Build and run the Docker container:
2. Make the start script executable:
```sh
docker build -t citron-builder .
docker run --rm -v "$(pwd)":/output citron-builder
chmod +x start_build_linux_macOS.sh
```
3. Ensure an active internet connection for downloading dependencies.
4. The Citron AppImage file will be created in the current directory.
5. (Optional) Remove the `citron-builder` image to save disk space:
3. Run the linux/macOS build script:
```sh
docker rmi -f citron-builder
./start_build_linux_macOS.sh
```
4. Follow the on-screen prompts to select your build mode and Citron version.
5. Ensure an active internet connection for downloading dependencies.
6. The Citron AppImage file will be created in the current directory.
7. The script will prompt you about optional disk cleanup.
### Steam Deck (Podman)
1. Switch to [Desktop Mode](https://help.steampowered.com/en/faqs/view/671A-4453-E8D2-323C).
@ -132,7 +135,7 @@ This repository contains scripts to build [Citron](https://git.citron-emu.org/Ci
7. Follow the on-screen prompts to select your build mode and Citron version.
8. The Steam Deck may enter sleep mode during the build process. To prevent this, click on the battery icon and then on "Manually block sleep and screen locking".
8. The Steam Deck may enter sleep mode during the build process. To prevent sleep mode, click the battery icon in the system tray and select "Manually block sleep and screen locking."
9. The Citron AppImage file will be created in the current directory.
@ -140,7 +143,7 @@ This repository contains scripts to build [Citron](https://git.citron-emu.org/Ci
## Advanced Docker Usage
For users running Docker in Linux or macOS, you can modify the Docker run command accordingly:
The startup scripts for each OS cover most use cases, but you can manually run the Docker container using the examples below:
- Use the default command for the latest Citron build optimized for Steam Deck:
@ -187,7 +190,7 @@ citron-v0.5-canary-refresh-release.AppImage
## Troubleshooting
- Verify internet connectivity or possible outages from both the Citron repository and all the external dependencies if the build process fails. Check the [Citron Discord](https://discord.gg/VcSDxrBYUJ) community for more information.
- If the build process fails, check your internet connection and verify that the Citron repository and external dependencies are accessible. Check the [Citron Discord](https://discord.gg/VcSDxrBYUJ) community for more information.
## Credits

150
start_build_linux_macOS.sh Normal file
View file

@ -0,0 +1,150 @@
#!/bin/bash
# Title: Citron AppImage Build Script (Linux & macOS)
# Description: Builds and runs the Arch Linux Docker container to create a Citron AppImage.
set -e # Exit on any error
# Check if Docker is installed
echo "Checking for Docker installation..."
if ! command -v docker &> /dev/null; then
echo "=============================================================="
echo " Docker is not installed on your system."
echo " Please install Docker from: https://docs.docker.com/get-docker/"
echo "=============================================================="
exit 1
fi
# Check if Docker is running
echo "Checking if Docker is running..."
if ! docker info &> /dev/null; then
echo "=============================================================="
echo " Docker is not running. Please start Docker and try again."
echo "=============================================================="
exit 1
fi
# Ask user for version
echo "========================================================"
echo " Choose the version to build:"
echo " 1. [Default] 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, Branch name or Commit Hash)"
echo "========================================================"
read -p "Enter choice ([1]/2/3/4): " VERSION_CHOICE
case "$VERSION_CHOICE" in
2) CITRON_VERSION="v0.5-canary-refresh" ;;
3) CITRON_VERSION="v0.4-canary-refresh" ;;
4) read -p "Enter the version (Tag, Branch or Commit Hash): " CITRON_VERSION ;;
*) CITRON_VERSION="master" ;;
esac
# Ask user for build mode
echo "========================================================"
echo " Choose the build mode:"
echo " 1. [Default] SteamDeck optimizations"
echo " 2. Release mode"
echo " 3. Compatibility mode (for older architectures)"
echo " 4. Debug mode"
echo "========================================================"
read -p "Enter choice ([1]/2/3/4): " BUILD_MODE_CHOICE
case "$BUILD_MODE_CHOICE" in
2) CITRON_BUILD_MODE="release" ;;
3) CITRON_BUILD_MODE="compatibility" ;;
4) CITRON_BUILD_MODE="debug" ;;
*) CITRON_BUILD_MODE="steamdeck" ;;
esac
# Ask user if they want to cache the Git repository
echo "========================================================"
echo " Do you want to cache the Git repository for "
echo " subsequent builds? (This may speed up builds but "
echo " will consume around 1 GB of disk space.)"
echo " 1. Yes"
echo " 2. [Default] No"
echo "========================================================"
read -p "Enter choice (1/[2]): " CACHE_REPO
USE_CACHE=false
[ "$CACHE_REPO" = "1" ] && USE_CACHE=true
# Ask user if they want to output Linux binaries
echo "========================================================"
echo " Do you want to output Linux binaries?"
echo " 1. Yes"
echo " 2. [Default] No"
echo "========================================================"
read -p "Enter choice (1/[2]): " OUTPUT_BINARIES
OUTPUT_LINUX_BINARIES=false
[ "$OUTPUT_BINARIES" = "1" ] && OUTPUT_LINUX_BINARIES=true
# Detect system architecture
ARCH=$(uname -m)
if [ "$ARCH" = "arm64" ]; then
echo "ARM device detected"
# Detect if host is macOS
if [ "$(uname)" = "Darwin" ]; then
echo "Mac Detected"
# Check if Rosetta 2 is installed using pkgutil
if ! pkgutil --pkgs | grep -q "com.apple.pkg.RosettaUpdateAuto"; then
echo "=============================================================="
echo " Rosetta 2 is required to run the ARM64 Docker container on"
echo " macOS. Please install Rosetta 2 and try again."
echo " Command to install Rosetta 2: softwareupdate --install-rosetta --agree-to-license"
echo "=============================================================="
exit 1
fi
fi
echo "Building Citron AppImage for ARM64..."
# Build the new image for ARM64
docker build --platform=linux/amd64 -t citron-builder .
# Run the container with the selected options
docker run --platform=linux/amd64 --rm \
-e CITRON_VERSION=$CITRON_VERSION \
-e CITRON_BUILD_MODE=$CITRON_BUILD_MODE \
-e OUTPUT_LINUX_BINARIES=$OUTPUT_LINUX_BINARIES \
-e USE_CACHE=$USE_CACHE \
-v "$(pwd)":/output \
citron-builder
else
# Build the new image
docker build -t citron-builder .
# Run the container with the selected options
docker run --rm \
-e CITRON_VERSION=$CITRON_VERSION \
-e CITRON_BUILD_MODE=$CITRON_BUILD_MODE \
-e OUTPUT_LINUX_BINARIES=$OUTPUT_LINUX_BINARIES \
-e USE_CACHE=$USE_CACHE \
-v "$(pwd)":/output \
citron-builder
fi
# Ask user if they want to remove the Docker image
echo "========================================================"
echo " Do you want to remove the citron-builder image "
echo " to save disk space? (Y/n)"
echo "========================================================"
read -p "Enter choice: " DELETE_IMAGE
if [[ -z "$DELETE_IMAGE" || "$DELETE_IMAGE" =~ ^[Yy]$ ]]; then
echo "Removing citron-builder image..."
docker rmi -f citron-builder
fi
# Ask user if they want to delete the cached Git repository
if [ -f citron.tar.zst ]; then
echo "========================================================"
echo " Do you want to delete the cached repository "
echo " file citron.tar.zst to free up space? (y/[N])"
echo "========================================================"
read -p "Enter choice: " DELETE_CACHE
if [[ "$DELETE_CACHE" =~ ^[Yy]$ ]]; then
echo "Deleting cached repository..."
rm -f citron.tar.zst
fi
fi