Makefile 2.29 KB
Newer Older
Michal Horejsek's avatar
Michal Horejsek committed
1

Michal Horejsek's avatar
Michal Horejsek committed
2 3
.PHONY: all prepare-dev test lint run-py2 run-py3 release build clean
SHELL=/bin/bash
Michal Horejsek's avatar
Michal Horejsek committed
4

5
# Normally it would be just twistd but it runs always with Python 2 in this moment.
6
TWISTD_CMD=-m haas_proxy
7
TWISTD_RUN_ARGS=-l - -n haas_proxy -d ${DEVICE_TOKEN}
8

Michal Horejsek's avatar
Michal Horejsek committed
9 10
FPM_CMD=fpm -f -d sshpass -m 'haas@nic.cz' -s python
FPM_CMD_PY2=${FPM_CMD} --python-bin /usr/bin/python2 --python-package-name-prefix python
11
FPM_CMD_PY3=${FPM_CMD} --python-bin /usr/bin/python3 --python-package-name-prefix python3 --python-install-lib /usr/lib/python3/dist-packages
Michal Horejsek's avatar
Michal Horejsek committed
12 13 14 15 16 17 18 19 20 21 22

all:
	@echo "make prepare-dev"
	@echo "make test"
	@echo "make lint"
	@echo "make run"
	@echo "make build"
	@echo "make clean"


prepare-dev:
23
	@# lib*-dev and cffi for building cryptography, dependency of twisted.
24
	apt-get install -y python python-dev python-pip python3 python3-dev python3-pip sshpass libffi-dev libssl-dev
25 26 27
	# Upgrade setuptools and pip to avoid error when installing modules with environmnent markers
	python2 -m pip install -U setuptools pip
	python3 -m pip install -U setuptools pip
28 29
	python2 -m pip install -U cffi pyOpenSSL
	python3 -m pip install -U cffi pyOpenSSL
30 31
	python2 -m pip install -e .[test]
	python3 -m pip install -e .[test]
Michal Horejsek's avatar
Michal Horejsek committed
32 33

    # Build dependencies
Michal Horejsek's avatar
Michal Horejsek committed
34
	apt-get install -y ruby ruby-dev rubygems build-essential rpm
Michal Horejsek's avatar
Michal Horejsek committed
35 36 37
	gem install --no-ri --no-rdoc fpm

test:
38 39
	if [ `which python2` ]; then python2 -m pytest test_haas_proxy.py; fi
	if [ `which python3` ]; then python3 -m pytest test_haas_proxy.py; fi
Michal Horejsek's avatar
Michal Horejsek committed
40 41

lint:
42
	python3 -m pylint --rcfile=pylintrc haas_proxy haas_proxy/twisted/plugins/haas_proxy_plugin.py
Michal Horejsek's avatar
Michal Horejsek committed
43

44
run-py2:
Michal Horejsek's avatar
Michal Horejsek committed
45
	python2 ${TWISTD_CMD} ${TWISTD_RUN_ARGS}
46
run-py3:
Michal Horejsek's avatar
Michal Horejsek committed
47
	python3 ${TWISTD_CMD} ${TWISTD_RUN_ARGS}
Michal Horejsek's avatar
Michal Horejsek committed
48

Michal Horejsek's avatar
Michal Horejsek committed
49 50 51 52 53 54
release: build
	rm -rf release
	mkdir release
	mv *deb *rpm *tar.gz release
	cd release; for f in `ls`; do md5sum "$${f}" > "$${f}.checksum"; done

55 56 57
upload:
	python3 setup.py register sdist upload

58 59 60 61
upload-docker: build-docker
	docker tag haas-proxy cznic/haas-proxy
	docker push cznic/haas-proxy

Michal Horejsek's avatar
Michal Horejsek committed
62 63 64 65 66 67 68 69 70 71
build:
	# Debian packages
	${FPM_CMD_PY2} -t deb setup.py
	${FPM_CMD_PY3} -t deb setup.py

	# Red Hat packages
	${FPM_CMD_PY2} -t rpm setup.py
	${FPM_CMD_PY3} -t rpm setup.py

    # Just archive, no deps
Michal Horejsek's avatar
Michal Horejsek committed
72
	python setup.py sdist --formats=gztar --dist-dir .
Michal Horejsek's avatar
Michal Horejsek committed
73

74 75 76
build-docker:
	docker build --no-cache -t haas-proxy .

Michal Horejsek's avatar
Michal Horejsek committed
77 78
clean:
	python setup.py clean
Michal Horejsek's avatar
Michal Horejsek committed
79
	rm -rf *.deb *.rpm *.tar