diff options
| author | Rubén Beltrán del Río <jj@r.bdr.sh> | 2026-01-18 12:37:07 +0100 |
|---|---|---|
| committer | Rubén Beltrán del Río <jj@r.bdr.sh> | 2026-01-18 12:37:07 +0100 |
| commit | 267776561ea2da8c637cd2d5eaed189c3692b608 (patch) | |
| tree | cdab6be20502c785129193d97fe5c6b1472e4277 /Makefile | |
| parent | 87f291bd746a910655535204c9c9123e64a36fee (diff) | |
Use podman to build all instead
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 235 |
1 files changed, 105 insertions, 130 deletions
@@ -1,11 +1,14 @@ -profile := dev +profile := release target = $(shell rustc -vV | grep host | awk '{print $$2}') +channel := unstable + # Cargo outputs dev profile to 'debug' directory, not 'dev' 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 @@ -18,10 +21,7 @@ linuxdeploy := .cache/linuxdeploy.AppImage pkgver := $(shell grep '^pkgver=' build-aux/PKGBUILD | cut -d= -f2) pkgrel := $(shell grep '^pkgrel=' build-aux/PKGBUILD | cut -d= -f2) -# Distro-specific builds (set via: make -e distro=fedora43) -distro := - -# Podman images for arm builds +# Podman images for distro-specific builds fedora_versions := fedora42 fedora43 fedora-rawhide debian_versions := bookworm trixie bullseye fedora_image_fedora42 := fedora:42 @@ -30,6 +30,10 @@ fedora_image_fedora-rawhide := fedora:rawhide debian_image_bookworm := debian:bookworm debian_image_trixie := debian:trixie debian_image_bullseye := debian:bullseye +arch_image := archlinux:latest + +# Filename format: map-aarch64-unstable.flatpak or map-aarch64-unstable-fedora43.rpm +filename = $(app_name)-$(arch)-$(channel) define sign_and_deploy @./scripts/sign.sh "$(1)" "$(channel)" "$(arch)" @@ -50,7 +54,6 @@ endif # Build ######################################################################## build: compile_translations prepare - @$(eval target_dir := ./target/$(target)/$(output_dir)/map) cargo build --profile $(profile) --target $(target) # Code Quality ################################################################# @@ -85,25 +88,13 @@ po/%/LC_MESSAGES/systems.tranquil.Map.mo: po/%.po msgfmt $< -o $@ # Packaging #################################################################### - -# Filename format: map-aarch64-unstable.flatpak or map-aarch64-unstable-fedora43.rpm -filename = $(app_name)-$(arch)-$(channel)$(if $(distro),-$(distro),) +# +# Generic packages (run on bare metal) +# 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 -package-rpm: build -ifeq ($(findstring linux,$(target)),linux) - cargo generate-rpm --profile $(profile) --target $(target) - mv target/$(target)/generate-rpm/*.rpm $(filename).rpm -endif - -package-deb: build -ifeq ($(findstring linux,$(target)),linux) - cargo deb --profile $(profile) --target $(target) - mv target/$(target)/debian/*.deb $(filename).deb -endif - package-tar: build @$(eval staging := $(shell mktemp -d)) @install -Dm0755 target/$(target)/$(output_dir)/$(app_name) $(staging)/usr/bin/$(app_name) @@ -123,14 +114,6 @@ package-flatpak: update_flatpak_dependencies flatpak-builder --force-clean --user --install-deps-from=flathub --repo=repo --install builddir ./build-aux/systems.tranquil.Map.yml flatpak build-bundle repo $(filename).flatpak systems.tranquil.Map -package-pacman: - @$(eval staging := $(shell mktemp -d)) - rsync -a --filter=':- .gitignore' --exclude='.git' . $(staging)/src - cp build-aux/PKGBUILD $(staging)/ - cd $(staging) && PKGEXT='.pkg.tar.gz' makepkg -f - mv $(staging)/$(app_name)-$(pkgver)-$(pkgrel)-$(arch).pkg.tar.gz $(app_name)-$(arch)-$(channel)-arch.pkg.tar.gz - @rm -rf $(staging) - $(linuxdeploy): @mkdir -p .cache curl -L -o $(linuxdeploy) $(linuxdeploy_url) @@ -155,83 +138,65 @@ ifeq ($(findstring linux,$(target)),linux) @rm -rf $(appdir) endif -package: package-rpm package-deb package-tar package-pacman package-flatpak package-appimage - -# Distribution ################################################################# - -distribute-rpm: - @$(call sign_and_deploy,$(filename).rpm) - -distribute-deb: - @$(call sign_and_deploy,$(filename).deb) - -distribute-tar: - @$(call sign_and_deploy,$(filename).tar.gz) - -distribute-flatpak: - @$(call sign_and_deploy,$(filename).flatpak) - -distribute-pacman: - @$(call sign_and_deploy,$(app_name)-$(arch)-$(channel)-arch.pkg.tar.gz) - -distribute-appimage: - @$(call sign_and_deploy,$(filename).AppImage) +# +# Distro-specific packages (run inside podman containers) +# -distribute: distribute-rpm distribute-deb distribute-tar distribute-pacman distribute-flatpak distribute-appimage +# Internal target: runs inside arch container +package-pacman: + @$(eval staging := $(shell mktemp -d)) + rsync -a --filter=':- .gitignore' --exclude='.git' . $(staging)/src + cp build-aux/PKGBUILD $(staging)/ + cd $(staging) && PKGEXT='.pkg.tar.gz' makepkg -f + mv $(staging)/$(app_name)-$(pkgver)-$(pkgrel)-$(arch).pkg.tar.gz $(app_name)-$(arch)-$(channel)-arch.pkg.tar.gz + @rm -rf $(staging) -release: package distribute +# Internal target: runs inside fedora container +package-rpm: build +ifeq ($(findstring linux,$(target)),linux) + cargo generate-rpm --profile $(profile) --target $(target) + mv target/$(target)/generate-rpm/*.rpm $(filename)-$(distro).rpm +endif -# ARM builds - run locally for universal formats, podman for distro-specific -arm: -ifndef channel - $(eval channel := unstable) +# Internal target: runs inside debian container +package-deb: build +ifeq ($(findstring linux,$(target)),linux) + cargo deb --profile $(profile) --target $(target) + mv target/$(target)/debian/*.deb $(filename)-$(distro).deb endif - @echo "=== Building ARM packages (channel: $(channel)) ===" - @# Build universal formats locally - $(MAKE) -e profile=release -e channel=$(channel) -e target=aarch64-unknown-linux-gnu package-tar package-flatpak package-appimage package-pacman - @# Build distro-specific packages via podman - $(MAKE) -e channel=$(channel) arm-rpm-all arm-deb-all - @# Sign and distribute everything - $(MAKE) -e profile=release -e channel=$(channel) -e target=aarch64-unknown-linux-gnu distribute-tar distribute-flatpak distribute-appimage distribute-pacman - @for v in $(fedora_versions); do \ - $(MAKE) -e channel=$(channel) -e target=aarch64-unknown-linux-gnu -e distro=$$v distribute-rpm; \ - done - @for v in $(debian_versions); do \ - $(MAKE) -e channel=$(channel) -e target=aarch64-unknown-linux-gnu -e distro=$$v distribute-deb; \ - done -# Build all ARM RPMs via podman -arm-rpm-all: - @for v in $(fedora_versions); do \ - $(MAKE) -e channel=$(channel) -e distro=$$v arm-rpm; \ - done +# +# Podman wrappers for distro-specific builds +# -# Build single ARM RPM via podman (requires distro= to be set) -arm-rpm: +package-pacman-podman: + @echo "=== Building Arch package for $(arch) ===" + podman run --rm -v $(CURDIR):/src:Z -w /src $(arch_image) bash -c '\ + pacman -Syu --noconfirm make clang lld curl tar gzip gettext gtk4 libadwaita gtksourceview5 fakeroot && \ + curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ + source $$HOME/.cargo/env && \ + useradd -m builder && \ + chown -R builder:builder /src && \ + su builder -c "cd /src && make -e profile=$(profile) -e channel=$(channel) -e target=$(target) package-pacman"' + +package-rpm-podman: ifndef distro - $(error distro is required, e.g., make arm-rpm distro=fedora43) + $(error distro is required, e.g., make package-rpm-podman distro=fedora43) endif - @echo "=== Building ARM RPM for $(distro) ===" + @echo "=== Building RPM for $(distro) ($(arch)) ===" podman run --rm -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=release -e channel=$(channel) -e target=aarch64-unknown-linux-gnu -e distro=$(distro) package-rpm' + make -e profile=$(profile) -e channel=$(channel) -e target=$(target) -e distro=$(distro) package-rpm' -# Build all ARM DEBs via podman -arm-deb-all: - @for v in $(debian_versions); do \ - $(MAKE) -e channel=$(channel) -e distro=$$v arm-deb; \ - done - -# Build single ARM DEB via podman (requires distro= to be set) -arm-deb: +package-deb-podman: ifndef distro - $(error distro is required, e.g., make arm-deb distro=bookworm) + $(error distro is required, e.g., make package-deb-podman distro=bookworm) endif - @echo "=== Building ARM DEB for $(distro) ===" + @echo "=== Building DEB for $(distro) ($(arch)) ===" podman run --rm -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 && \ @@ -239,8 +204,49 @@ endif 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=release -e channel=$(channel) -e target=aarch64-unknown-linux-gnu -e distro=$(distro) package-deb' + make -e profile=$(profile) -e channel=$(channel) -e target=$(target) -e distro=$(distro) package-deb' + +package-rpm-all: + @for v in $(fedora_versions); do \ + $(MAKE) -e profile=$(profile) -e channel=$(channel) -e target=$(target) -e distro=$$v package-rpm-podman; \ + done + +package-deb-all: + @for v in $(debian_versions); do \ + $(MAKE) -e profile=$(profile) -e channel=$(channel) -e target=$(target) -e distro=$$v package-deb-podman; \ + done + +package: package-tar package-flatpak package-appimage package-pacman-podman package-rpm-all package-deb-all +# Distribution ################################################################# + +distribute-tar: + @$(call sign_and_deploy,$(filename).tar.gz) + +distribute-flatpak: + @$(call sign_and_deploy,$(filename).flatpak) + +distribute-appimage: + @$(call sign_and_deploy,$(filename).AppImage) + +distribute-pacman: + @$(call sign_and_deploy,$(app_name)-$(arch)-$(channel)-arch.pkg.tar.gz) + +distribute-rpm: + @for v in $(fedora_versions); do \ + $(call sign_and_deploy,$(filename)-$$v.rpm); \ + done + +distribute-deb: + @for v in $(debian_versions); do \ + $(call sign_and_deploy,$(filename)-$$v.deb); \ + done + +distribute: distribute-tar distribute-flatpak distribute-appimage distribute-pacman distribute-rpm distribute-deb + +# Release ###################################################################### + +release: lint package distribute # Installation ################################################################# @@ -268,43 +274,12 @@ uninstall: rm -f $(prefix)/share/locale/$$locale/LC_MESSAGES/systems.tranquil.Map.mo; \ done -# CI ########################################################################### -# -# CI target for generic builds (flatpak, appimage, tar) -ci-generic: lint -ifeq ($(GIT_REF),refs/heads/main) - $(MAKE) -e profile=release -e channel=unstable -e target=$(target) package-tar package-flatpak package-appimage distribute-tar distribute-flatpak distribute-appimage -else ifneq (,$(findstring refs/tags/,$(GIT_REF))) - $(MAKE) -e profile=release -e channel=$(subst refs/tags/,,$(GIT_REF)) -e target=$(target) package-tar package-flatpak package-appimage distribute-tar distribute-flatpak distribute-appimage -endif - -# CI target for .pkg.tar.gz builds (arch) -ci-arch: lint -ifeq ($(GIT_REF),refs/heads/main) - $(MAKE) -e profile=release -e channel=unstable -e target=$(target) package-pacman distribute-pacman -else ifneq (,$(findstring refs/tags/,$(GIT_REF))) - $(MAKE) -e profile=release -e channel=$(subst refs/tags/,,$(GIT_REF)) -e target=$(target) package-pacman distribute-pacman -endif - -# CI target for rpm builds (fedora) -ci-rpm: -ifeq ($(GIT_REF),refs/heads/main) - $(MAKE) -e profile=release -e channel=unstable -e target=$(target) -e distro=$(distro) package-rpm distribute-rpm -else ifneq (,$(findstring refs/tags/,$(GIT_REF))) - $(MAKE) -e profile=release -e channel=$(subst refs/tags/,,$(GIT_REF)) -e target=$(target) -e distro=$(distro) package-rpm distribute-rpm -endif - -# CI target for deb builds (debian) -ci-deb: -ifeq ($(GIT_REF),refs/heads/main) - $(MAKE) -e profile=release -e channel=unstable -e target=$(target) -e distro=$(distro) package-deb distribute-deb -else ifneq (,$(findstring refs/tags/,$(GIT_REF))) - $(MAKE) -e profile=release -e channel=$(subst refs/tags/,,$(GIT_REF)) -e target=$(target) -e distro=$(distro) package-deb distribute-deb -endif - -.PHONY: default build package package-rpm package-deb package-tar package-flatpak package-pacman package-appimage \ - distribute distribute-rpm distribute-deb distribute-tar distribute-flatpak distribute-pacman distribute-appimage \ - arm arm-rpm arm-rpm-all arm-deb arm-deb-all \ - prepare set_rust ci ci-arch ci-rpm ci-deb release test coverage format lint \ - update_flatpak_dependencies extract_strings find_translatable_files \ - ci-generic compile_translations install uninstall +.PHONY: default build test coverage format lint \ + find_translatable_files extract_strings compile_translations \ + update_flatpak_dependencies \ + package-tar package-flatpak package-appimage \ + package-pacman package-rpm package-deb \ + 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 |