#!/usr/bin/make -f export DEB_BUILD_MAINT_OPTIONS = hardening=+all export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic export DEB_CXXFLAGS_MAINT_APPEND = -Wall -pedantic # trust upstream optimization level by default ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS))) export DEB_CFLAGS_MAINT_STRIP=-O2 export DEB_CXXFLAGS_MAINT_STRIP=-O2 endif include /usr/share/dpkg/default.mk include /usr/share/rustc/architecture.mk export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS export DEB_HOST_RUST_TYPE DEB_HOST_GNU_TYPE export PYBUILD_NAME=matrix-synapse export PATH := /usr/share/cargo/bin:$(PATH) export CARGO=/usr/share/cargo/bin/cargo export CARGO_HOME=$(CURDIR)/debian/cargo_home export DEB_CARGO_CRATE=$(DEB_SOURCE)_$(DEB_VERSION_UPSTREAM) # resolve all direct entries in first "package..." section in TODO VENDORLIBS = $(shell perl -nE \ '/^(?:\s{2}[*]\s*(?:(package)|(\S+))|\s{4}[*]\s*(\S+))/ or next; \ $$i++ if $$1; exit if $$i > 1 or $$2; say $$3 if $$3 and $$i;' \ debian/TODO) comma = , _mangle = perl -gpi \ -e 's/$(1)\W+version = "\K\Q$(subst |,$(comma),$(2))"/$(subst |,$(comma),$(3))"/g;' \ $(patsubst %,debian/vendorlibs/%/Cargo.toml,$(4)) %: dh $@ --buildsystem=pybuild execute_before_dh_auto_configure: sed -i '/common/s/~=/>=/' pyproject.toml mkdir -p debian/cargo_registry for file in $(CURDIR)/debian/vendorlibs/* ; do \ name=`basename "$$file"` ;\ [ -e debian/cargo_registry/"$$name" ] || ln -sT "$$file" debian/cargo_registry/"$$name" ;\ done $(CARGO) prepare-debian debian/cargo_registry --link-from-system execute_after_dh_auto_clean: rm -rf debian/cargo_registry mv Cargo.lock debian/Cargo.lock.orig || true rm -f setup.py rm -rf debian/cargo_home target override_dh_auto_install: dh_auto_install for f in $$(find debian/$(PYBUILD_NAME) -name 'jquery*min.js'); \ do \ rm $$f; \ ln -s /usr/share/javascript/jquery/jquery.min.js $$f; \ done sed -i \ -e 's,#!/usr/bin/env perl,#!/usr/bin/perl,' \ debian/*/usr/bin/* mv debian/*/usr/bin/* debian/*/usr/libexec/*/ /usr/share/cargo/bin/dh-cargo-built-using matrix-synapse execute_after_dh_installdocs: mv debian/$(PYBUILD_NAME)/usr/share/doc/matrix-synapse/installation.md \ debian/$(PYBUILD_NAME)/usr/share/doc/matrix-synapse/INSTALL.md mv debian/$(PYBUILD_NAME)/usr/share/doc/matrix-synapse/upgrade.md \ debian/$(PYBUILD_NAME)/usr/share/doc/matrix-synapse/UPGRADE.md ln -sr debian/$(PYBUILD_NAME)/usr/share/doc/matrix-synapse/UPGRADE.md \ debian/$(PYBUILD_NAME)/usr/share/doc/matrix-synapse/UPGRADE.rst sed -i \ -e 's,/opt/venvs/matrix-synapse/bin/python,/usr/bin/python3,' \ -e 's,Restart=always,Restart=on-failure,' \ debian/*/usr/share/doc/matrix-synapse/misc/systemd-with-workers/system/*.service override_dh_compress: dh_compress -XREADME override_dh_auto_clean: mv debian/Cargo.lock.orig Cargo.lock || true dh_auto_clean ifeq ($(DEB_HOST_ARCH_BITS),32) override_dh_auto_test: -dh_auto_test endif PYTHONS=$(wildcard /usr/bin/python3.? /usr/bin/python3.??) CURRENT_PYTHON=$(shell readlink -f /usr/bin/python3) OTHER_PYTHONS=$(filter-out $(CURRENT_PYTHON),$(PYTHONS)) OTHER_PYTHON_VERSIONS=$(subst /usr/bin/python,,$(OTHER_PYTHONS)) pybuild-autopkgtest: export PYBUILD_VERBOSE=1 pybuild-autopkgtest: export PYBUILD_DISABLE=$(OTHER_PYTHON_VERSIONS) .PHONY: pybuild-autopkgtest # custom target unused during official build get-vendorlibs: # preserve and use pristine Cargo.lock [ -f Cargo.lock.orig ] || cp Cargo.lock Cargo.lock.orig cp -f Cargo.lock.orig Cargo.lock # modernize crates cargo update # preserve needed crates cargo vendor --versioned-dirs debian/vendorlibs~ rm -rf debian/vendorlibs mkdir debian/vendorlibs cd debian/vendorlibs~ && mv --target-directory=../vendorlibs $(VENDORLIBS) # use newer crates $(call _mangle,structopt,0.2,>= 0.2| <= 0.3,ulid-1.1.3) # use older crates $(call _mangle,memoffset,0.9,>= 0.8.0| <= 0.9,pyo3-0.21.2) # avoid WASM-only crates perl -gpi \ -e 's/\[target(\W+cfg\(target)?\W+wasm[^\n]*(\n[^\[\n][^\n]*)*//g;' \ debian/vendorlibs/ulid-1.1.3/Cargo.toml # strip checksums for mangled crates echo '{"package":"Could not get crate checksum","files":{}}' \ | tee $(patsubst %,debian/vendorlibs/%/.cargo-checksum.json,\ pyo3-0.21.2 \ ulid-1.1.3 \ ) # cleanup rm -rf debian/vendorlibs~ [ ! -f Cargo.lock.orig ] || mv -f Cargo.lock.orig Cargo.lock