From 238fd3b539679a9f53f0b9523f8e4b8d749697d2 Mon Sep 17 00:00:00 2001 From: Rubén Beltrán del Río Date: Sun, 18 Jan 2026 15:20:57 +0100 Subject: Use Containerfiles for builds --- Makefile | 101 ++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 54 insertions(+), 47 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index d90e460..b842136 100644 --- a/Makefile +++ b/Makefile @@ -2,40 +2,40 @@ profile := release target = $(shell rustc -vV | grep host | awk '{print $$2}') channel := unstable +# Config: Directories & Locations ############################################## # Cargo outputs dev profile to 'debug' directory, not 'dev' +prefix := /usr/local ifeq ($(profile),dev) output_dir := debug else output_dir := $(profile) endif - -# Extract just the architecture (first component of target triple) -arch = $(firstword $(subst -, ,$(target))) -app_name := map -deploy_host := deploy@build.r.bdr.sh -deploy_path := /srv/http/build.r.bdr.sh/$(app_name)-linux -prefix := /usr/local flatpak_cargo_generator := $(HOME)/projects/vendor/flatpak-builder-tools/cargo + +# Config: Packaging Config ##################################################### linuxdeploy_url := https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-$(shell uname -m).AppImage linuxdeploy := .cache/linuxdeploy.AppImage pkgver := $(shell grep '^pkgver=' build-aux/PKGBUILD | cut -d= -f2) pkgrel := $(shell grep '^pkgrel=' build-aux/PKGBUILD | cut -d= -f2) -# Podman images for distro-specific builds -fedora_versions := fedora42 fedora43 fedora-rawhide -debian_versions := bookworm trixie bullseye -fedora_image_fedora42 := fedora:42 -fedora_image_fedora43 := fedora:43 -fedora_image_fedora-rawhide := fedora:rawhide -debian_image_bookworm := debian:bookworm -debian_image_trixie := debian:trixie -debian_image_bullseye := debian:bullseye -# lopsided/archlinux provides multi-arch images (amd64, arm64, etc.) -arch_image := lopsided/archlinux:latest - # Filename format: map-aarch64-unstable.flatpak or map-aarch64-unstable-fedora43.rpm filename = $(app_name)-$(arch)-$(channel) +# Config: Naming ############################################################### +arch = $(firstword $(subst -, ,$(target))) +app_name := map + +# Config: Container Images ##################################################### +fedora_versions := fedora42 fedora43 fedora-rawhide +# Note: bullseye excluded - no GTK4/libadwaita packages available +debian_versions := bookworm trixie forky +all_containers := arch $(fedora_versions) $(debian_versions) +container_image_prefix := map-build + +# Config: Release Location ##################################################### +deploy_host := deploy@build.r.bdr.sh +deploy_path := /srv/http/build.r.bdr.sh/$(app_name)-linux + define sign_and_deploy @./scripts/sign.sh "$(1)" "$(channel)" "$(arch)" rsync -avz $(1) $(deploy_host):$(deploy_path) @@ -88,10 +88,20 @@ po/%/LC_MESSAGES/systems.tranquil.Map.mo: po/%.po @mkdir -p $(dir $@) msgfmt $< -o $@ +# Container Images ############################################################# + +build-container-%: + @echo "=== Building container image: $(container_image_prefix):$* ===" + podman build -t $(container_image_prefix):$* build-containers/$* + +build-containers: $(addprefix build-container-,$(all_containers)) + # Packaging #################################################################### -# -# Generic packages (run on bare metal) -# + + +# Generic packages +# These run directly on the host machine, since the assumption is that it +# shouldn't affect the outcome. update_flatpak_dependencies: cd $(flatpak_cargo_generator) && `poetry env activate` && python3 flatpak-cargo-generator.py $(CURDIR)/Cargo.lock -o $(CURDIR)/build-aux/cargo-sources.json && deactivate @@ -139,9 +149,9 @@ ifeq ($(findstring linux,$(target)),linux) @rm -rf $(appdir) endif -# -# Distro-specific packages (run inside podman containers) -# +# Distro-specific packages +# These run inside containers, as we want to make sure they're built with the +# libraries available in that particular distribution. # Internal target: runs inside arch container package-pacman: @@ -172,36 +182,28 @@ endif package-pacman-podman: @echo "=== Building Arch package for $(arch) ===" - podman run --rm --userns=keep-id -v $(CURDIR):/src:Z -w /src $(arch_image) bash -c '\ - pacman -Syu --noconfirm make clang lld curl tar gzip gettext gtk4 libadwaita gtksourceview5 fakeroot rsync rust && \ - make -e profile=$(profile) -e channel=$(channel) -e target=$(target) package-pacman' + podman run --rm -v $(CURDIR):/src:Z -w /src $(container_image_prefix):arch bash -c '\ + staging=$$(mktemp -d) && \ + cp -r /src/. $$staging/ && \ + chown -R builder:builder $$staging && \ + su builder -c "cd $$staging && make -e profile=$(profile) -e channel=$(channel) -e target=$(target) package-pacman" && \ + cp $$staging/$(app_name)-$(arch)-$(channel)-arch.pkg.tar.gz /src/' package-rpm-podman: ifndef distro $(error distro is required, e.g., make package-rpm-podman distro=fedora43) endif @echo "=== Building RPM for $(distro) ($(arch)) ===" - podman run --rm --userns=keep-id -v $(CURDIR):/src:Z -w /src $(fedora_image_$(distro)) bash -c '\ - dnf install -y make clang lld curl tar gzip gettext gtk4-devel libadwaita-devel gtksourceview5-devel pkg-config && \ - curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ - source $$HOME/.cargo/env && \ - curl -L --proto "=https" --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash && \ - cargo binstall cargo-generate-rpm --no-confirm && \ - make -e profile=$(profile) -e channel=$(channel) -e target=$(target) -e distro=$(distro) package-rpm' + podman run --rm -v $(CURDIR):/src:Z -w /src $(container_image_prefix):$(distro) \ + make -e profile=$(profile) -e channel=$(channel) -e target=$(target) -e distro=$(distro) package-rpm package-deb-podman: ifndef distro $(error distro is required, e.g., make package-deb-podman distro=bookworm) endif @echo "=== Building DEB for $(distro) ($(arch)) ===" - podman run --rm --userns=keep-id -v $(CURDIR):/src:Z -w /src $(debian_image_$(distro)) bash -c '\ - apt-get update && \ - apt-get install -y make clang lld curl tar gzip gettext libgtk-4-dev libadwaita-1-dev libgtksourceview-5-dev pkg-config && \ - curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ - source $$HOME/.cargo/env && \ - curl -L --proto "=https" --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash && \ - cargo binstall cargo-deb --no-confirm && \ - make -e profile=$(profile) -e channel=$(channel) -e target=$(target) -e distro=$(distro) package-deb' + podman run --rm -v $(CURDIR):/src:Z -w /src $(container_image_prefix):$(distro) \ + make -e profile=$(profile) -e channel=$(channel) -e target=$(target) -e distro=$(distro) package-deb package-rpm-all: @for v in $(fedora_versions); do \ @@ -231,19 +233,23 @@ distribute-pacman: distribute-rpm: @for v in $(fedora_versions); do \ - $(call sign_and_deploy,$(filename)-$$v.rpm); \ + ./scripts/sign.sh "$(filename)-$$v.rpm" "$(channel)" "$(arch)" && \ + rsync -avz $(filename)-$$v.rpm $(deploy_host):$(deploy_path) && \ + rsync -avz $(filename)-$$v.rpm.minisig $(deploy_host):$(deploy_path); \ done distribute-deb: @for v in $(debian_versions); do \ - $(call sign_and_deploy,$(filename)-$$v.deb); \ + ./scripts/sign.sh "$(filename)-$$v.deb" "$(channel)" "$(arch)" && \ + rsync -avz $(filename)-$$v.deb $(deploy_host):$(deploy_path) && \ + rsync -avz $(filename)-$$v.deb.minisig $(deploy_host):$(deploy_path); \ done distribute: distribute-tar distribute-flatpak distribute-appimage distribute-pacman distribute-rpm distribute-deb # Release ###################################################################### -release: lint package distribute +release: lint build-containers package distribute # Installation ################################################################# @@ -279,4 +285,5 @@ uninstall: package-pacman-podman package-rpm-podman package-deb-podman \ package-rpm-all package-deb-all package \ distribute-tar distribute-flatpak distribute-appimage distribute-pacman distribute-rpm distribute-deb distribute \ - release install uninstall set_rust prepare + release install uninstall set_rust prepare \ + build-containers -- cgit