Makefile 1.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
BUILD_DIR = ./build
DIST_DIR = ./dist
VIR_DIR = $(BUILD_DIR)/middleware_virtualenv

. PHONY : debsource
debsource : $(DIST_DIR)/ldh_middleware-?.?.?-py3-none-any.whl builddeb
debsource : PYTHON_PKG = $(DIST_DIR)/ldh_middleware-?.?.?-py3-none-any.whl

$(DIST_DIR)/ldh_middleware-?.?.?-py3-none-any.whl :
	python3 setup.py sdist bdist_wheel

. PHONY : debpypi
debpypi : builddeb
debpypi : PYTHON_PKG = ldh_middleware

$(VIR_DIR)/bin/ldh_middleware :
	virtualenv --python=python3 $(VIR_DIR) && . $(VIR_DIR)/bin/activate \
	&& pip install $(PYTHON_PKG) && deactivate
	cd $(VIR_DIR) && \
	virtualenv-tools --update-path /opt/purist/middleware_virtualenv

.PHONY : builddeb
builddeb : LDH_VERSION = $(shell awk '/^Version:/ {print $$2}' \
	$(VIR_DIR)/lib/python3.?/site-packages/ldh_middleware-*.dist-info/METADATA)
builddeb : LDH_DESC = $(shell awk -F': ' '/^Summary:/ {print $$2}' \
	$(VIR_DIR)/lib/python3.?/site-packages/ldh_middleware-*.dist-info/METADATA)
builddeb : LDH_URL = $(shell awk '/^Home-page:/ {print $$2}' \
	$(VIR_DIR)/lib/python3.?/site-packages/ldh_middleware-*.dist-info/METADATA)
builddeb : $(VIR_DIR)/bin/ldh_middleware
	rbenv exec fpm --vendor "Purism SPC" --maintainer liberty@puri.sm \
	  --license AGPL-3.0-or-later --prefix /opt/purist/middleware_virtualenv \
	  --version "$(LDH_VERSION)" --description "$(LDH_DESC)" --url "$(LDH_URL)" \
	  --after-install bin/afterinst.sh \
	  --depends python3 --depends supervisor --depends uwsgi --depends nginx \
	  --depends uwsgi-emperor --depends uwsgi-plugin-python3 \
	  --chdir $(VIR_DIR) -s dir -t deb -n ldh_middleware .

clean :
	rm -f ldh-middleware_*_amd64.deb
	rm -rf $(BUILD_DIR) $(DIST_DIR) ldh_middleware.egg-info/