diff options
| author | Rubén Beltrán del Río <jj@r.bdr.sh> | 2026-01-17 12:27:11 +0100 |
|---|---|---|
| committer | Rubén Beltrán del Río <jj@r.bdr.sh> | 2026-01-17 12:51:31 +0100 |
| commit | 260a2d079dc500ba50b0f06a43b341fe65fd2d45 (patch) | |
| tree | 186a19783a0c9562db0475c8386e543e695b5949 /Makefile | |
| parent | 88d6bf80f5cdbbb90ead197bd41a67eb8c44e50e (diff) | |
Add distribution logic
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 95 |
1 files changed, 70 insertions, 25 deletions
@@ -1,10 +1,10 @@ profile := dev target = $(shell rustc -vV | grep host | awk '{print $$2}') -architectures := x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu +architectures := aarch64-unknown-linux-gnu app_name := map deploy_host := deploy@build.r.bdr.sh deploy_path := /srv/http/build.r.bdr.sh/$(app_name)-linux -install_path := /usr/local/bin/$(app_name) +prefix := /usr/local flatpak_cargo_generator := $(HOME)/projects/vendor/flatpak-builder-tools/cargo define sign_and_deploy @@ -62,50 +62,95 @@ po/%/LC_MESSAGES/systems.tranquil.Map.mo: po/%.po # Packaging #################################################################### -package: $(architectures) - -release: rpm tar deb - @$(eval filename := $(app_name)-$(target)-$(channel)) +filename = $(app_name)-$(target)-$(channel) 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 -flatpak: update_flatpak_dependencies - @flatpak-builder --force-clean --user --install-deps-from=flathub --repo=repo --install builddir ./build-aux/systems.tranquil.Map.yml +package-rpm: build +ifeq ($(findstring linux,$(target)),linux) + cargo generate-rpm --profile $(profile) --target $(target) + mv target/$(target)/generate-rpm/*.rpm $(filename).rpm +endif -deb: build +package-deb: build ifeq ($(findstring linux,$(target)),linux) - @$(eval filename := $(app_name)-$(target)-$(channel)) cargo deb --profile $(profile) --target $(target) mv target/$(target)/debian/*.deb $(filename).deb - @$(call sign_and_deploy,$(filename).deb) endif -rpm: build -ifeq ($(findstring linux,$(target)),linux) - @$(eval filename := $(app_name)-$(target)-$(channel)) - cargo generate-rpm --profile $(profile) --target $(target) - mv target/$(target)/generate-rpm/*.rpm $(filename).rpm +package-tar: build + @$(eval staging := $(shell mktemp -d)) + @install -Dm0755 target/$(target)/$(profile)/$(app_name) $(staging)/usr/bin/$(app_name) + @install -Dm0644 resources/logo.svg $(staging)/usr/share/icons/hicolor/scalable/apps/systems.tranquil.Map.svg + @install -Dm0644 resources/systems.tranquil.Map.desktop $(staging)/usr/share/applications/systems.tranquil.Map.desktop + @install -Dm0644 resources/systems.tranquil.Map.metainfo.xml $(staging)/usr/share/metainfo/systems.tranquil.Map.metainfo.xml + @install -Dm0644 resources/systems.tranquil.Map.service $(staging)/usr/share/dbus-1/services/systems.tranquil.Map.service + @install -Dm0644 resources/wmap.lang $(staging)/usr/share/gtksourceview-5/language-specs/wmap.lang + @for po_file in po/*.po; do \ + locale=$$(basename "$$po_file" .po); \ + install -Dm0644 po/$$locale/LC_MESSAGES/systems.tranquil.Map.mo $(staging)/usr/share/locale/$$locale/LC_MESSAGES/systems.tranquil.Map.mo; \ + done + tar -czvf $(filename).tar.gz -C $(staging) usr + @rm -rf $(staging) + +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: package-rpm package-deb package-tar package-flatpak + +# Distribution ################################################################# + +distribute-rpm: @$(call sign_and_deploy,$(filename).rpm) -endif -tar: build - @$(eval filename := $(app_name)-$(target)-$(channel)) - tar -czvf $(filename).tar.gz -C target/$(target)/$(profile)/ $(app_name) +distribute-deb: + @$(call sign_and_deploy,$(filename).deb) + +distribute-tar: @$(call sign_and_deploy,$(filename).tar.gz) -# Distribution ################################################################# +distribute-flatpak: + @$(call sign_and_deploy,$(filename).flatpak) + +distribute: distribute-rpm distribute-deb distribute-tar distribute-flatpak + +release: package distribute + +# Installation ################################################################# install: build - @cp target/$(target)/$(profile)/ $(install_path) + install -Dm0755 target/$(target)/$(profile)/$(app_name) $(prefix)/bin/$(app_name) + install -Dm0644 resources/logo.svg $(prefix)/share/icons/hicolor/scalable/apps/systems.tranquil.Map.svg + install -Dm0644 resources/systems.tranquil.Map.desktop $(prefix)/share/applications/systems.tranquil.Map.desktop + install -Dm0644 resources/systems.tranquil.Map.metainfo.xml $(prefix)/share/metainfo/systems.tranquil.Map.metainfo.xml + install -Dm0644 resources/systems.tranquil.Map.service $(prefix)/share/dbus-1/services/systems.tranquil.Map.service + install -Dm0644 resources/wmap.lang $(prefix)/share/gtksourceview-5/language-specs/wmap.lang + @for po_file in po/*.po; do \ + locale=$$(basename "$$po_file" .po); \ + install -Dm0644 po/$$locale/LC_MESSAGES/systems.tranquil.Map.mo $(prefix)/share/locale/$$locale/LC_MESSAGES/systems.tranquil.Map.mo; \ + done + +uninstall: + rm -f $(prefix)/bin/$(app_name) + rm -f $(prefix)/share/icons/hicolor/scalable/apps/systems.tranquil.Map.svg + rm -f $(prefix)/share/applications/systems.tranquil.Map.desktop + rm -f $(prefix)/share/metainfo/systems.tranquil.Map.metainfo.xml + rm -f $(prefix)/share/dbus-1/services/systems.tranquil.Map.service + rm -f $(prefix)/share/gtksourceview-5/language-specs/wmap.lang + @for po_file in po/*.po; do \ + locale=$$(basename "$$po_file" .po); \ + rm -f $(prefix)/share/locale/$$locale/LC_MESSAGES/systems.tranquil.Map.mo; \ + done # CI ########################################################################### ci: lint coverage ifeq ($(GIT_REF),refs/heads/main) - $(MAKE) -e profile=release -e channel=unstable package + $(MAKE) -e profile=release -e channel=unstable $(architectures) else ifneq (,$(findstring refs/tags/,$(GIT_REF))) - $(MAKE) -e profile=release -e channel=$(subst refs/tags/,,$(GIT_REF)) package + $(MAKE) -e profile=release -e channel=$(subst refs/tags/,,$(GIT_REF)) $(architectures) endif $(architectures): @@ -116,4 +161,4 @@ else endif -.PHONY: default build $(architectures) rpm package prepare set_rust ci release test coverage format flatpak update_flatpak_dependencies extract_strings find_translatable_files compile_translations +.PHONY: default build $(architectures) package package-rpm package-deb package-tar package-flatpak distribute distribute-rpm distribute-deb distribute-tar distribute-flatpak prepare set_rust ci release test coverage format update_flatpak_dependencies extract_strings find_translatable_files compile_translations install uninstall |