forked from cobbler/cobbler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
188 lines (159 loc) · 6.51 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#
# Setup Makefile to match your environment
#
PYTHON=/usr/bin/python3
# check for executables
PYFLAKES = $(shell { command -v pyflakes-3 || command -v pyflakes3 || command -v pyflakes; } 2> /dev/null)
PYCODESTYLE := $(shell { command -v pycodestyle-3 || command -v pycodestyle3 || command -v pycodestyle; } 2> /dev/null)
HTTPD = $(shell which httpd)
APACHE2 = $(shell which apache2)
# Debian / Ubuntu have /bin/sh -> dash
SHELL = /bin/bash
TOP_DIR:=$(shell pwd)
DESTDIR=/
prefix=devinstall
statepath=/tmp/cobbler_settings/$(prefix)
# Taken from: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
all: clean build ## Executes the clean target and afterwards the build target.
clean: ## Cleans Python bytecode, build artifacts and the temp files.
@echo "cleaning: python bytecode"
@rm -f *.pyc
@rm -f cobbler/*.pyc
@rm -f cobbler/modules/*.pyc
@rm -f cobbler/web/*.pyc
@rm -f cobbler/web/templatetags/*.pyc
@echo "cleaning: build artifacts"
@rm -rf build release dist cobbler.egg-info
@rm -rf rpm-build/*
@rm -rf deb-build/*
@rm -f MANIFEST AUTHORS
@rm -f config/version
@rm -f docs/*.1.gz
@echo "cleaning: temp files"
@rm -f *~
@rm -rf buildiso
@rm -f *.tmp
@rm -f *.log
cleandoc: ## Cleans the docs directory.
@echo "cleaning: documentation"
@cd docs; make clean > /dev/null 2>&1
doc: ## Creates the documentation with sphinx in html form.
@echo "creating: documentation"
@cd docs; make html > /dev/null 2>&1
qa: ## If pyflakes and/or pycodestyle is found then they are run.
ifeq ($(strip $(PYFLAKES)),)
@echo "No pyflakes found"
else
@echo "checking: pyflakes ${PYFLAKES}"
@${PYFLAKES} \
*.py \
cobbler/*.py \
cobbler/modules/*.py \
cobbler/web/*.py cobbler/web/templatetags/*.py \
bin/cobbler* bin/*.py web/cobbler.wsgi
endif
ifeq ($(strip $(PYCODESTYLE)),)
@echo "No pycodestyle found"
else
@echo "checking: pycodestyle"
@${PYCODESTYLE} -r --ignore E501,E402,E722,W504 \
*.py \
cobbler/*.py \
cobbler/modules/*.py \
cobbler/web/*.py cobbler/web/templatetags/*.py \
bin/cobbler* bin/*.py web/cobbler.wsgi
endif
authors: ## Creates the AUTHORS file.
@echo "creating: AUTHORS"
@cp AUTHORS.in AUTHORS
@git log --format='%aN <%aE>' | grep -v 'root' | sort -u >> AUTHORS
sdist: authors ## Creates the sdist for release preparation.
@echo "creating: sdist"
@source distro_build_configs.sh; \
${PYTHON} setup.py sdist bdist_wheel
release: clean qa authors sdist ## Creates the full release.
@echo "creating: release artifacts"
@mkdir release
@cp dist/*.gz release/
@cp distro_build_configs.sh release/
@cp cobbler.spec release/
test-centos7: ## Executes the testscript for testing cobbler in a docker container on CentOS7.
./tests/build-and-install-rpms.sh --with-tests el7 dockerfiles/CentOS7.dockerfile
test-centos8: ## Executes the testscript for testing cobbler in a docker container on CentOS8.
./tests/build-and-install-rpms.sh --with-tests el8 dockerfiles/CentOS8.dockerfile
test-fedora31: ## Executes the testscript for testing cobbler in a docker container on Fedora 31.
./tests/build-and-install-rpms.sh --with-tests f31 dockerfiles/Fedora31.dockerfile
test-debian10: ## Executes the testscript for testing cobbler in a docker container on Debian 10.
./tests/build-and-install-debs.sh --with-tests deb10 dockerfiles/Debian10.dockerfile
build: ## Runs the Python Build.
@source distro_build_configs.sh; \
${PYTHON} setup.py build -f
install: build ## Runs the build target and then installs via setup.py
# Debian/Ubuntu requires an additional parameter in setup.py
@source distro_build_configs.sh; \
${PYTHON} setup.py install --root $(DESTDIR) -f
devinstall: ## This deletes the /usr/share/cobbler directory and then runs the targets savestate, install and restorestate.
-rm -rf $(DESTDIR)/usr/share/cobbler
make savestate
make install
make restorestate
savestate: ## This runs the setup.py task savestate.
@source distro_build_configs.sh; \
${PYTHON} setup.py -v savestate --root $(DESTDIR); \
restorestate: ## This restores a state which was previously saved via the target savestate. (Also run via setup.py)
# Check if we are on Red Hat, SUSE or Debian based distribution
@source distro_build_configs.sh; \
${PYTHON} setup.py -v restorestate --root $(DESTDIR); \
find $(DESTDIR)/var/lib/cobbler/triggers | xargs chmod +x
if [ -n "`getent passwd apache`" ] ; then \
chown -R apache $(DESTDIR)/var/www/cobbler; \
elif [ -n "`getent passwd wwwrun`" ] ; then \
chown -R wwwrun $(DESTDIR)/usr/share/cobbler/web; \
elif [ -n "`getent passwd www-data`"] ; then \
chown -R www-data $(DESTDIR)/usr/share/cobbler/web; \
fi
if [ -d $(DESTDIR)/var/www/cobbler ] ; then \
chmod -R +x $(DESTDIR)/var/www/cobbler/svc; \
fi
if [ -d $(DESTDIR)/usr/share/cobbler/web ] ; then \
chmod -R +x $(DESTDIR)/usr/share/cobbler/web; \
fi
if [ -d $(DESTDIR)/srv/www/cobbler/svc ]; then \
chmod -R +x $(DESTDIR)/srv/www/cobbler/svc; \
fi
rm -rf $(statepath)
webtest: devinstall ## Runs the task devinstall and then runs the targets clean and devinstall.
make clean
make devinstall
rpms: release ## Runs the target release and then creates via rpmbuild the rpms in a directory called rpm-build.
mkdir -p rpm-build
cp dist/*.gz rpm-build/
rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir %{_topdir}" \
--define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \
--define "_sourcedir %{_topdir}" \
-ba cobbler.spec
# Only build a binary package
debs: release ## Runs the target release and then creates via debbuild the debs in a directory called deb-build.
mkdir -p deb-build
mkdir -p deb-build/{BUILD,BUILDROOT,DEBS,SDEBS,SOURCES}
cp dist/*.gz deb-build/
debbuild --define "_topdir %(pwd)/deb-build" \
--define "_builddir %{_topdir}" \
--define "_specdir %{_topdir}" \
--define "_sourcedir %{_topdir}" \
-vv -bb cobbler.spec
eraseconfig: ## Deletes the cobbler data jsons which are created when using the file provider.
-rm /var/lib/cobbler/cobbler_collections/distros/*
-rm /var/lib/cobbler/cobbler_collections/images/*
-rm /var/lib/cobbler/cobbler_collections/profiles/*
-rm /var/lib/cobbler/cobbler_collections/systems/*
-rm /var/lib/cobbler/cobbler_collections/repos/*
-rm /var/lib/cobbler/cobbler_collections/mgmtclasses/*
-rm /var/lib/cobbler/cobbler_collections/files/*
-rm /var/lib/cobbler/cobbler_collections/packages/*