diff --git a/scripts/appimage/create_appimage.sh b/scripts/appimage/create_appimage.sh new file mode 100755 index 00000000..334be06c --- /dev/null +++ b/scripts/appimage/create_appimage.sh @@ -0,0 +1,112 @@ +#!/bin/bash + +# Exit on error +set -e + +# Check platform +platform=$(uname) + +if [[ "$platform" == "Darwin" ]]; then + echo "Running on macOS. Note that the AppImage created will only work on Linux systems." + if ! command -v docker &> /dev/null; then + echo "Docker Desktop for Mac is not installed. Please install it from https://www.docker.com/products/docker-desktop" + exit 1 + fi +elif [[ "$platform" == "Linux" ]]; then + echo "Running on Linux. Proceeding with AppImage creation..." +else + echo "This script is intended to run on macOS or Linux. Current platform: $platform" + exit 1 +fi + +# Enable BuildKit +export DOCKER_BUILDKIT=1 + +BASE_IMAGE_NAME="void-appimage-base" +BUILD_IMAGE_NAME="void-appimage-builder" +CONTAINER_NAME="void-appimage-temp" + +# Check if Docker is running +if ! docker info >/dev/null 2>&1; then + echo "Docker is not running. Please start Docker first." + exit 1 +fi + +# Check and install Buildx if needed +if ! docker buildx version >/dev/null 2>&1; then + echo "Installing Docker Buildx..." + mkdir -p ~/.docker/cli-plugins/ + curl -SL https://github.com/docker/buildx/releases/download/v0.13.1/buildx-v0.13.1.linux-amd64 -o ~/.docker/cli-plugins/docker-buildx + chmod +x ~/.docker/cli-plugins/docker-buildx +fi + +# Download appimagetool if not present +if [ ! -f "appimagetool" ]; then + echo "Downloading appimagetool..." + wget -O appimagetool "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" + chmod +x appimagetool +fi + +# Create build Dockerfile +echo "Creating build Dockerfile..." +cat > Dockerfile.build << 'EOF' +# syntax=docker/dockerfile:1 +FROM ubuntu:20.04 + +# Install required dependencies +RUN apt-get update && apt-get install -y \ + libfuse2 \ + libglib2.0-0 \ + libgtk-3-0 \ + libx11-xcb1 \ + libxss1 \ + libxtst6 \ + libnss3 \ + libasound2 \ + libdrm2 \ + libgbm1 \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app +EOF + +# Build Docker image +echo "Building Docker image..." +docker build -t "$BUILD_IMAGE_NAME" -f Dockerfile.build . + +# Create AppImage using local appimagetool +echo "Creating AppImage..." +docker run --rm --privileged -v "$(pwd):/app" "$BUILD_IMAGE_NAME" bash -c ' +cd /app && \ +rm -rf VoidApp.AppDir && \ +mkdir -p VoidApp.AppDir/usr/bin VoidApp.AppDir/usr/lib VoidApp.AppDir/usr/share/applications && \ +find . -maxdepth 1 ! -name VoidApp.AppDir ! -name "." ! -name ".." -exec cp -r {} VoidApp.AppDir/usr/bin/ \; && \ +cp void.png VoidApp.AppDir/ && \ +echo "[Desktop Entry]" > VoidApp.AppDir/void.desktop && \ +echo "Name=Void" >> VoidApp.AppDir/void.desktop && \ +echo "Exec=void" >> VoidApp.AppDir/void.desktop && \ +echo "Icon=void" >> VoidApp.AppDir/void.desktop && \ +echo "Type=Application" >> VoidApp.AppDir/void.desktop && \ +echo "Categories=Utility;" >> VoidApp.AppDir/void.desktop && \ +echo "Comment=Void Linux Application" >> VoidApp.AppDir/void.desktop && \ +chmod +x VoidApp.AppDir/void.desktop && \ +cp VoidApp.AppDir/void.desktop VoidApp.AppDir/usr/share/applications/ && \ +echo "#!/bin/bash" > VoidApp.AppDir/AppRun && \ +echo "HERE=\$(dirname \"\$(readlink -f \"\${0}\")\")" >> VoidApp.AppDir/AppRun && \ +echo "export PATH=\${HERE}/usr/bin:\${PATH}" >> VoidApp.AppDir/AppRun && \ +echo "export LD_LIBRARY_PATH=\${HERE}/usr/lib:\${LD_LIBRARY_PATH}" >> VoidApp.AppDir/AppRun && \ +echo "exec \${HERE}/usr/bin/void --no-sandbox \"\$@\"" >> VoidApp.AppDir/AppRun && \ +chmod +x VoidApp.AppDir/AppRun && \ +chmod -R 755 VoidApp.AppDir && \ + +# Strip unneeded symbols from the binary to reduce size +strip --strip-unneeded VoidApp.AppDir/usr/bin/void + +ls -la VoidApp.AppDir/ && \ +ARCH=x86_64 ./appimagetool -n VoidApp.AppDir Void-x86_64.AppImage +' + +# Clean up +rm Dockerfile.build + +echo "AppImage creation complete! Your AppImage is: Void-x86_64.AppImage" \ No newline at end of file diff --git a/scripts/appimage/readme.md b/scripts/appimage/readme.md new file mode 100644 index 00000000..1ccd3319 --- /dev/null +++ b/scripts/appimage/readme.md @@ -0,0 +1,130 @@ +# Void Linux AppImage Creation Script + +This script automates the process of creating an AppImage for a Void Linux application using Docker. It works on macOS and Linux platforms and is designed for developers looking to package their Void Linux application as an AppImage for easy distribution. + +## Requirements + +* **Docker:** The script relies on Docker to build the AppImage inside a container. +* **macOS or Linux:** The script is designed for these platforms. On macOS, it generates a Linux-compatible AppImage. +* **Internet Connection:** Required for downloading necessary tools (like `docker-buildx` and `appimagetool` inside the Docker container). + +## Prerequisites + +1. **Install Docker:** + + * **macOS:** Download and install Docker Desktop from [docker.com](docker.com). + * **Ubuntu:** + ```bash + sudo apt install docker.io + ``` + * **Arch Linux:** + ```bash + sudo pacman -S docker + ``` + * **Fedora:** + ```bash + sudo dnf install docker + ``` + +2. **Set Docker User Group:** + + Docker requires users to be part of the `docker` group to run Docker commands without `sudo`. + + ```bash + sudo usermod -aG docker $USER + ``` + + After running this command, log out and log back in for the group changes to take effect. + +3. **Enable and Start Docker:** + + ```bash + sudo systemctl enable docker + sudo systemctl start docker + ``` + +4. **Install Buildx (Optional but Recommended):** + + Buildx is used for efficient Docker builds. The script will automatically install Buildx if it is missing, but installing it beforehand can improve performance. + + ```bash + docker buildx install + ``` + +## Minimum Dependency Versions + +The script is executed inside an Ubuntu 20.04-based Docker container. While the script handles dependencies within the container, these minimum versions on the host system are recommended for smoother operation: + +* **Docker:** Minimum Version 19.03.0 or higher (required for BuildKit and Buildx). +* **Buildx:** Minimum Version 0.10.0 or higher. + +## Ubuntu Dependencies (Installed via Docker) + +These dependencies are installed within the Docker container (Ubuntu 20.04 base). You generally don't need to install them manually: + +* `libfuse2` +* `libglib2.0-0` +* `libgtk-3-0` +* `libx11-xcb1` +* `libxss1` +* `libxtst6` +* `libnss3` +* `libasound2` +* `libdrm2` +* `libgbm1` + +## Usage Instructions + +1. **Clone or Download the Script:** + + Save the script to your system as `create_appimage.sh`. + +2. **Make the Script Executable:** + + ```bash + chmod +x create_appimage.sh + ``` + +3. **Copy Required Files:** + + Copy the following files to the directory where the app binary is being bundled (created during the build process): + + * `create_appimage.sh` + * `void.desktop` + * `void.png` + +4. **Run the Script:** + + ```bash + ./create_appimage.sh + ``` + +5. **Result:** + + After the script completes, it will generate an AppImage named `Void-x86_64.AppImage` (or similar, depending on your architecture) in the current directory. + +## Script Overview + +* **Platform Check:** Checks for macOS or Linux. Exits if unsupported. +* **Docker Checks:** Ensures Docker is installed and running. +* **Buildx Installation:** Installs `docker buildx` if missing. +* **`appimagetool` Download:** Downloads `appimagetool` inside the Docker container. +* **Dockerfile Creation:** Creates a temporary `Dockerfile.build` for the Ubuntu-based environment. +* **Docker Image Build:** Builds a Docker image and runs the build process. +* **AppImage Creation:** + * Creates the `VoidApp.AppDir` structure. + * Copies binaries, resources, and the `.desktop` entry. + * Copies `void.desktop` and `void.png`. + * Strips unnecessary symbols from the binary. + * Runs `appimagetool` to generate the AppImage. +* **Cleanup:** Removes the temporary `Dockerfile.build`. + +## Troubleshooting + +* **Docker Not Running:** Ensure Docker is installed and running. +* **Permission Issues:** Try running the script with `sudo` or check Docker permissions. +* **Outdated Dependencies:** Ensure you have the minimum required versions. + +## License + +This script is provided "as is". It is free to use, modify, and distribute, but comes with no warranty. diff --git a/scripts/appimage/void.desktop b/scripts/appimage/void.desktop new file mode 100755 index 00000000..8649b00a --- /dev/null +++ b/scripts/appimage/void.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Name=void +Exec=void +Icon=void +Type=Application +Categories=Utility; +Comment=Void Linux Application diff --git a/scripts/appimage/void.png b/scripts/appimage/void.png new file mode 100644 index 00000000..225179f8 Binary files /dev/null and b/scripts/appimage/void.png differ