forked from aki/docker-aseprite-linux
This commit replaces the previous multi-distribution Docker build system with a unified Flatpak build process executed inside a Docker container. This is the intended final architecture for building Aseprite bundles.
**Key Changes:**
* **Transition to Flatpak:** The core build logic now uses `flatpak-builder` and a Flatpak manifest (`com.aseprite.Aseprite.yaml`) to compile Aseprite and its dependencies against a standard Flatpak SDK runtime.
* **Unified Docker Environment:** Replaced distribution-specific `Dockerfile.<distro>` files with a single `Dockerfile` that sets up a consistent environment containing `flatpak-builder` and the necessary Flatpak SDK.
* **Simplified Makefile:** Removed OS detection logic and multi-distro targets. The Makefile now orchestrates:
1. Running `prepare_sources.sh` on the host (still responsible for reliable source fetching/syncing).
2. Building the single Flatpak builder Docker image.
3. Running `flatpak-builder` inside a *privileged* container (required for `flatpak-builder` sandboxing) to perform the actual build.
4. Running `flatpak build-bundle` inside the container.
5. Extracting the final `.flatpak` bundle from the container to `./target/aseprite.flatpak`.
* **Updated .gitignore:** Added `build/`, `target/`, `*.flatpak`, and `*.log` to ignore Flatpak build directories, output bundles, and logs. Removed the old `dependencies` ignore pattern.
* **Prepare Sources Update:** Modified `prepare_sources.sh` to explicitly initialize `depot_tools` on the host, as this is required before sources are copied into the Flatpak build environment for `gn` usage.
* **Removal of Old Files:** Deleted `Dockerfile.<distro>`, `Dockerfile.debian`, `Dockerfile.fedora`, `Dockerfile.arch` (multi-distro Dockerfiles), and the original generic `Dockerfile` and `docker-compose.yml`.
**Rationale:**
This refactor moves to the planned final architecture. Building within a Flatpak SDK provides a highly consistent environment independent of the host Linux distribution. The output is a portable `.flatpak` bundle, simplifying distribution and runtime compatibility compared to dynamically linking against varied host libraries. While `prepare_sources.sh` on the host still handles the initial (and potentially rate-limited) source fetching, the subsequent build process is significantly standardized and more reliable.
This architecture is now the **forward-maintained** build method.
96 lines
3.1 KiB
Makefile
96 lines
3.1 KiB
Makefile
# --- Configuration ---
|
|
# Uses a single Dockerfile with flatpak-builder inside
|
|
IMAGE_NAME := aseprite-flatpak-builder
|
|
DOCKERFILE := Dockerfile
|
|
TARGET_DIR := ${PWD}/target
|
|
OUTPUT_FILE := ${TARGET_DIR}/aseprite.flatpak
|
|
BUILD_DIR := ${PWD}/build
|
|
SRC_DIR := ${PWD}/src
|
|
FLATPAK_STATE_DIR := ${PWD}/flatpak-state
|
|
FLATPAK_CACHE_DIR := ${PWD}/flatpak-cache
|
|
|
|
# --- Main Targets ---
|
|
# Default target
|
|
all: build
|
|
|
|
# Prepare source files by running the script
|
|
# Use .PHONY to ensure it always runs if called directly
|
|
.PHONY: prepare-sources
|
|
prepare-sources:
|
|
@echo "--- Preparing sources using prepare_sources.sh ---"
|
|
@./prepare_sources.sh
|
|
|
|
# Build the Docker image which runs flatpak-builder inside
|
|
# Implicitly depends on sources being ready after prepare-sources runs
|
|
.PHONY: build-image
|
|
build-image:
|
|
@echo "--- Building Aseprite Flatpak builder image (${IMAGE_NAME}) ---"
|
|
@docker build -t ${IMAGE_NAME} -f ${DOCKERFILE} .
|
|
|
|
# Run flatpak-builder inside a privileged container
|
|
# Create persistent cache directories to improve caching
|
|
.PHONY: run-flatpak-builder
|
|
run-flatpak-builder:
|
|
@echo "--- Running flatpak-builder inside container ---"
|
|
@mkdir -p ${BUILD_DIR} ${FLATPAK_STATE_DIR} ${FLATPAK_CACHE_DIR}
|
|
@docker run \
|
|
--rm \
|
|
--privileged \
|
|
--device /dev/fuse \
|
|
-v ${SRC_DIR}:/sources:ro \
|
|
-v ${BUILD_DIR}:/build \
|
|
-v ${FLATPAK_STATE_DIR}:/root/.local/share/flatpak-builder \
|
|
-v ${FLATPAK_CACHE_DIR}:/root/.cache/flatpak-builder \
|
|
-v ${PWD}/com.aseprite.Aseprite.yaml:/build/com.aseprite.Aseprite.yaml:ro \
|
|
-w /build \
|
|
${IMAGE_NAME} \
|
|
sh -c "flatpak-builder --disable-rofiles-fuse --state-dir=/root/.local/share/flatpak-builder --ccache --force-clean build-dir com.aseprite.Aseprite.yaml --repo=repo"
|
|
|
|
# Create the Flatpak bundle from the repo built in the previous step
|
|
.PHONY: create-bundle
|
|
create-bundle: run-flatpak-builder
|
|
@echo "--- Creating Flatpak bundle ---"
|
|
@docker run \
|
|
--rm \
|
|
--privileged \
|
|
--device /dev/fuse \
|
|
-v ${BUILD_DIR}:/build \
|
|
-w /build \
|
|
${IMAGE_NAME} \
|
|
sh -c "flatpak build-bundle repo aseprite.flatpak com.aseprite.Aseprite"
|
|
|
|
# Copy the final bundle from the intermediate directory to the output directory
|
|
.PHONY: extract-flatpak
|
|
extract-flatpak: create-bundle
|
|
@echo "--- Copying Flatpak bundle to target directory ---"
|
|
@mkdir -p ${TARGET_DIR}
|
|
@cp ${BUILD_DIR}/aseprite.flatpak ${OUTPUT_FILE}
|
|
@echo "Aseprite Flatpak bundle is in ${OUTPUT_FILE}"
|
|
|
|
# Prepare build target: Prepare sources, build Docker image
|
|
.PHONY: prepare
|
|
prepare: prepare-sources build-image
|
|
@echo "--- Prepare complete ---"
|
|
|
|
# Main build target: Run builder, create bundle, extract
|
|
.PHONY: build
|
|
build: run-flatpak-builder create-bundle extract-flatpak
|
|
@echo "--- Build complete ---"
|
|
|
|
# --- Utility Targets ---
|
|
# Clean up the output and intermediate build directories
|
|
.PHONY: clean
|
|
clean:
|
|
@echo "--- Cleaning up ---"
|
|
@rm -rf ${TARGET_DIR}
|
|
@rm -rf ${BUILD_DIR}
|
|
@echo "Cleanup complete."
|
|
|
|
# Deep clean - removes all caches as well
|
|
.PHONY: deep-clean
|
|
deep-clean: clean
|
|
@echo "--- Deep cleaning (including caches) ---"
|
|
@rm -rf ${FLATPAK_STATE_DIR}
|
|
@rm -rf ${FLATPAK_CACHE_DIR}
|
|
@echo "Deep cleanup complete."
|