forked from cobbler/cobbler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
177 lines (144 loc) · 5.89 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
MAKEFLAGS += --no-print-directory
#
# Setup Makefile to match your environment
#
PYTHON=/usr/bin/python3
# check for executables
BLACK = $(shell which black)
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
@rm -rf cobbler/__pycache__
@rm -rf cobbler/**/__pycache__
@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
@rm -rf docs/_build
@echo "cleaning: temp files"
@rm -f *~
@rm -rf buildiso
@rm -f *.tmp
@rm -f *.log
@rm -f supervisord.pid
@rm -rf .pytest_cache
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
man: ## Creates documentation and man pages using Sphinx
@${PYTHON} -m sphinx -b man -j auto ./docs ./build/sphinx/man
qa: ## If black is found then it is run.
ifeq ($(strip $(BLACK)),)
@echo "No black found"
else
@echo "checking: black ${BLACK}"
@${BLACK} .
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-centos8: ## Executes the testscript for testing cobbler in a docker container on CentOS8.
./docker/rpms/build-and-install-rpms.sh el8 docker/rpms/CentOS_8/CentOS8.dockerfile
test-fedora37: ## Executes the testscript for testing cobbler in a docker container on Fedora 37.
./docker/rpms/build-and-install-rpms.sh fc37 docker/rpms/Fedora_37/Fedora37.dockerfile
test-debian10: ## Executes the testscript for testing cobbler in a docker container on Debian 10.
./docker/debs/build-and-install-debs.sh deb10 docker/debs/Debian_10/Debian10.dockerfile
test-debian11: ## Executes the testscript for testing cobbler in a docker container on Debian 11.
./docker/debs/build-and-install-debs.sh deb11 docker/debs/Debian_11/Debian11.dockerfile
system-test: ## Runs the system tests
$(MAKE) -C system-tests
system-test-env: ## Configures the environment for system tests
$(MAKE) -C system-tests bootstrap
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; \
git config --add safe.directory /code; \
${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 [ -d $(DESTDIR)/var/www/cobbler ] ; then \
chmod -R +x $(DESTDIR)/var/www/cobbler/svc; \
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: authors ## Creates native debs in a directory called deb-build. The release target is called during the build process.
@source distro_build_configs.sh; \
debuild -us -uc
@mkdir -p deb-build; \
cp ../cobbler_* deb-build/; \
cp ../cobbler-tests* deb-build/
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/*
-rm /var/lib/cobbler/cobbler_collections/menus/*
.PHONY: system-test