Merge pull request #289 from bawsdeep/main

Needed rework of my script to generate the Appimage
This commit is contained in:
Andrew Pareles 2025-03-01 18:50:14 -08:00 committed by GitHub
commit f711c68798
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 256 additions and 0 deletions

View file

@ -0,0 +1,135 @@
#!/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
BUILD_IMAGE_NAME="void-appimage-builder"
# 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
# Delete any existing AppImage to avoid bloating the build
rm -f Void-x86_64.AppImage
# 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
# Create .dockerignore file
echo "Creating .dockerignore file..."
cat > .dockerignore << EOF
Dockerfile.build
.dockerignore
.git
.gitignore
.DS_Store
*~
*.swp
*.swo
*.tmp
*.bak
*.log
*.err
node_modules/
venv/
*.egg-info/
*.tox/
dist/
EOF
# Build Docker image without cache
echo "Building Docker image (no cache)..."
docker build --no-cache -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 -rf VoidApp.AppDir .dockerignore appimagetool
echo "AppImage creation complete! Your AppImage is: Void-x86_64.AppImage"

114
scripts/appimage/readme.md Normal file
View file

@ -0,0 +1,114 @@
# Void AppImage Creation Script
This script automates the process of creating an AppImage for the Void Editor using Docker. It works on macOS and Linux platforms.
## 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
```
## 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.

7
scripts/appimage/void.desktop Executable file
View file

@ -0,0 +1,7 @@
[Desktop Entry]
Name=void
Exec=void
Icon=void
Type=Application
Categories=Utility;
Comment=Void Linux Application

BIN
scripts/appimage/void.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 KiB