This repository has been archived by the owner on Jun 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Makefile
172 lines (142 loc) · 4.91 KB
/
Makefile
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# https://github.com/phusion/baseimage-docker/blob/master/Makefile
# https://github.com/ansible/ansible/blob/devel/Makefile#L230
NAME = bearded-avenger
VERSION := $(shell cat VERSION | cut -f1 -d' ')
OS = $(shell uname -s)
PYTHON = python
.PHONY: all build docker docker-run test develop
all: build test
test:
pytest --cov=cif
pep8:
@echo "#############################################"
@echo "# Running PEP8 Compliance Tests"
@echo "#############################################"
-pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225,E261,E241 cif/
python:
$(PYTHON) setup.py build
develop:
(bash ./helpers/develop.sh)
ubuntu14:
(bash ./helpers/ubuntu14.sh)
docker:
(cd builds/docker && make build)
docker-run:
(cd builds/docker && make run)
run:
supervisord
vagrant:
vagrant up
vagrant-ubuntu14:
vagrant up
vagrant-centos7:
VAGRANT_VAGRANTFILE=Vagrantfile.centos7 vagrant up
vagrant-destroy:
vagrant destroy --force
vagrant-reload: vagrant-destroy vagrant
install:
$(PYTHON) setup.py install
clean:
@echo "Cleaning up distutils stuff"
rm -rf build
rm -rf dist
@echo "Cleaning up byte compiled python stuff"
find . -type f -regex ".*\.py[co]$$" -delete
find . -type d -regex ".*__pycache__" -delete
@echo "Cleaning up output from test runs"
rm -rf tests/__pycache__
@echo "Cleaning up RPM building stuff"
rm -rf MANIFEST rpm-build
@echo "Cleaning up Debian building stuff"
find . -type f -name '*.pyc' -delete
sdist: clean
$(PYTHON) setup.py sdist
# Pyinstaller params
# https://mborgerson.com/creating-an-executable-from-a-python-script
# TODO - move build up to main dir instead of cif/ fix the pathex in specs
PYINSTALLER = pyinstaller
PYINSTALLER_OPTS = --distpath=$(PYINSTALLER_DIST_PATH) --workpath=$(PYINSTALLER_WORK_PATH) -y --onefile
PYINSTALLER_SPEC_DIR = packaging/pyinstaller
PYINSTALLER_SPECS = cif-router.spec cif-httpd.spec
PYINSTALLER_BUILD = pyinstaller-build
PYINSTALLER_DIST_PATH = dist
PYINSTALLER_WORK_PATH = temp
binaries:
mkdir -p $(PYINSTALLER_BUILD) ;
cp -a cif $(PYINSTALLER_BUILD) ;
cp -a $(PYINSTALLER_SPEC_DIR)/*.spec $(PYINSTALLER_BUILD)/ ;
@for SPEC in $(PYINSTALLER_SPECS) ; do \
(cd $(PYINSTALLER_BUILD) && $(PYINSTALLER) $(PYINSTALLER_OPTS) $${SPEC} ) ; \
done
pyinstaller-clean:
rm -rf
# DEB build parameters
DEBUILD_BIN ?= debuild
DPUT_BIN ?= dput
DPUT_OPTS ?=
DEB_DATE := $(shell date +"%a, %d %b %Y %T %z")
ifeq ($(OFFICIAL),yes)
DEB_RELEASE = $(RELEASE)ppa
# Sign OFFICIAL builds using 'DEBSIGN_KEYID'
# DEBSIGN_KEYID is required when signing
ifneq ($(DEBSIGN_KEYID),)
DEBUILD_OPTS += -k$(DEBSIGN_KEYID)
endif
else
DEB_RELEASE = 0.git$(DATE)$(GITINFO)
# Do not sign unofficial builds
DEBUILD_OPTS += -uc -us
DPUT_OPTS += -u
endif
DEBUILD = $(DEBUILD_BIN) $(DEBUILD_OPTS)
DEB_PPA ?= ppa
# Choose the desired Ubuntu release: lucid precise saucy trusty
DEB_DIST ?= unstable
debian: pyinstaller-clean pyinstaller
@for DIST in $(DEB_DIST) ; do \
mkdir -p deb-build/$${DIST}/$(NAME)-$(VERSION)/ ; \
cp -a packaging/debian deb-build/$${DIST}/$(NAME)-$(VERSION)/ ; \
cp -a $(PYINSTALLER_BUILD)/$(PYINSTALLER_DIST_PATH)/* deb-build/$${DIST}/$(NAME)-$(VERSION)/ ; \
sed -ie "s|%VERSION%|$(VERSION)|g;s|%RELEASE%|$(DEB_RELEASE)|;s|%DIST%|$${DIST}|g;s|%DATE%|$(DEB_DATE)|g" deb-build/$${DIST}/$(NAME)-$(VERSION)/debian/changelog ; \
done
deb: debian
@for DIST in $(DEB_DIST) ; do \
(cd deb-build/$${DIST}/$(NAME)-$(VERSION)/ && $(DEBUILD) -b) ; \
done
@echo "#############################################"
@echo "bearded-avenger DEB artifacts:"
@for DIST in $(DEB_DIST) ; do \
echo deb-build/$${DIST}/$(NAME)_$(VERSION)-$(DEB_RELEASE)~$${DIST}_amd64.changes ; \
done
@echo "#############################################"
debian-clean:
rm -rf deb-build
# RPM build parameters
RPMSPECDIR= packaging/rpm
RPMSPEC = $(RPMSPECDIR)/bearded-avenger.spec
RPMDIST = $(shell rpm --eval '%{?dist}')
RPMRELEASE = $(RELEASE)
ifneq ($(OFFICIAL),yes)
RPMRELEASE = 0.git$(DATE)$(GITINFO)
endif
RPMNVR = "$(NAME)-$(VERSION)-$(RPMRELEASE)$(RPMDIST)"
rpmcommon: pyinstaller-clean pyinstaller
@mkdir -p rpm-build
cp -a $(PYINSTALLER_DIST_PATH)/* rpm-build/
cp -a packaging/rpm/*.spec rpm-build/
@sed -e 's#^Version:.*#Version: $(VERSION)#' -e 's#^Release:.*#Release: $(RPMRELEASE)%{?dist}#' $(RPMSPEC) >rpm-build/$(NAME).spec
rpm: rpmcommon
@rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir $(RPMSPECDIR)" \
--define "_sourcedir %{_topdir}" \
--define "_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm" \
-ba rpm-build/$(NAME).spec
@rm -f rpm-build/$(NAME).spec
@echo "#############################################"
@echo "bearded-avenger RPM is built:"
@echo " rpm-build/$(RPMNVR).noarch.rpm"
@echo "#############################################"
clean: debian-clean pyinstaller-clean