forked from cobbler/cobbler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
174 lines (150 loc) · 4.52 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
TOP_DIR:=$(shell pwd)
DESTDIR=/
prefix=devinstall
statepath=/tmp/cobbler_settings/$(prefix)
all: clean build
clean:
@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 rpm-build release dist
@rm -f MANIFEST AUTHORS README
@rm -f config/version
@rm -f docs/*.1.gz
@echo "cleaning: temp files"
@rm -f *~
@rm -rf buildiso
@rm -f *.tmp
@rm -f *.log
@echo "cleaning: documentation"
@cd docs; make clean > /dev/null 2>&1
readme:
@echo "creating: README"
@cat README.md | sed -e 's/^\[!.*//g' | tail -n "+3" > README
doc:
@echo "creating: documentation"
@cd docs; make html > /dev/null 2>&1
qa:
@echo "checking: pyflakes"
@pyflakes \
*.py \
cobbler/*.py \
cobbler/modules/*.py \
cobbler/web/*.py cobbler/web/templatetags/*.py \
bin/cobbler* bin/*.py web/cobbler.wsgi
@echo "checking: pep8"
@pep8 -r --ignore E501 \
*.py \
cobbler/*.py \
cobbler/modules/*.py \
cobbler/web/*.py cobbler/web/templatetags/*.py \
bin/cobbler* bin/*.py web/cobbler.wsgi
authors:
@echo "creating: AUTHORS"
@cp AUTHORS.in AUTHORS
@git log --format='%aN <%aE>' | grep -v 'root' | sort -u >> AUTHORS
sdist: readme authors
@echo "creating: sdist"
@python setup.py sdist > /dev/null
release: clean qa readme authors sdist doc
@echo "creating: release artifacts"
@mkdir release
@cp dist/*.gz release/
@cp cobbler.spec release/
@cp debian/cobbler.dsc release/
@cp debian/changelog release/debian.changelog
@cp debian/control release/debian.control
@cp debian/rules release/debian.rules
test:
make savestate prefix=test
make rpms
make install
make eraseconfig
/sbin/service cobblerd restart
-(make nosetests)
make restorestate prefix=test
/sbin/service cobblerd restart
nosetests:
PYTHONPATH=./cobbler/ nosetests -v -w tests/cli/ 2>&1 | tee test.log
build:
python setup.py build -f
# Debian/Ubuntu requires an additional parameter in setup.py
install: build
python setup.py install --root $(DESTDIR) -f
devinstall:
-rm -rf $(DESTDIR)/usr/share/cobbler
make savestate
make install
make restorestate
savestate:
python setup.py -v savestate --root $(DESTDIR); \
# Check if we are on Red Hat, Suse or Debian based distribution
restorestate:
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
rm -rf $(statepath)
webtest: devinstall
make clean
make devinstall
make restartservices
# Check if we are on Red Hat, Suse or Debian based distribution
restartservices:
if [ -x /sbin/service ] ; then \
/sbin/service cobblerd restart; \
if [ -f /etc/init.d/httpd ] ; then \
/sbin/service httpd restart; \
elif [ -f /usr/lib/systemd/system/httpd.service ]; then \
/bin/systemctl restart httpd.service; \
else \
/sbin/service apache2 restart; \
fi; \
elif [ -x /bin/systemctl ]; then \
if [ -d /lib/systemd/system/apache2.service.d ]; then \
/bin/systemctl restart apache2.service; \
else \
/bin/systemctl restart httpd.service; \
fi \
else \
/usr/sbin/service cobblerd restart; \
/usr/sbin/service apache2 restart; \
fi
rpms: release
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
eraseconfig:
-rm /var/lib/cobbler/collections/distros/*
-rm /var/lib/cobbler/collections/images/*
-rm /var/lib/cobbler/collections/profiles/*
-rm /var/lib/cobbler/collections/systems/*
-rm /var/lib/cobbler/collections/repos/*
-rm /var/lib/cobbler/collections/mgmtclasses/*
-rm /var/lib/cobbler/collections/files/*
-rm /var/lib/cobbler/collections/packages/*
.PHONY: tags
tags:
find . \( -name build -o -name .git \) -prune -o -type f -name '*.py' -print | xargs etags -o TAGS --