forked from ClusterLabs/pcs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
237 lines (211 loc) · 7.9 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# Compatibility with GNU/Linux [i.e. Debian] based distros
UNAME_OS_GNU := $(shell if uname -o | grep -q "GNU/Linux" ; then echo true; else echo false; fi)
DISTRO_DEBIAN := $(shell if [ -e /etc/debian_version ] ; then echo true; else echo false; fi)
IS_DEBIAN=false
DISTRO_DEBIAN_VER_8=false
ifndef PYTHON
PYTHON := $(shell which python3 || which python2 || which python)
endif
ifeq ($(UNAME_OS_GNU),true)
ifeq ($(DISTRO_DEBIAN),true)
IS_DEBIAN=true
DISTRO_DEBIAN_VER_8 := $(shell if grep -q -i "^8\|jessie" /etc/debian_version ; then echo true; else echo false; fi)
# dpkg-architecture is in the optional dpkg-dev package, unfortunately.
#DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
# TODO: Use lsb_architecture to get the multiarch tuple if/when it becomes available in distributions.
DEB_HOST_MULTIARCH := $(shell dpkg -L libc6 | sed -nr 's|^/etc/ld\.so\.conf\.d/(.*)\.conf$$|\1|p')
endif
endif
ifndef PYTHON_SITELIB
PYTHON_SITELIB=$(shell $(PYTHON) -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
endif
ifeq ($(PYTHON_SITELIB), /usr/lib/python2.6/dist-packages)
EXTRA_SETUP_OPTS="--install-layout=deb"
endif
ifeq ($(PYTHON_SITELIB), /usr/lib/python2.7/dist-packages)
EXTRA_SETUP_OPTS="--install-layout=deb"
endif
ifeq ($(PYTHON_SITELIB), /usr/lib/python3/dist-packages)
EXTRA_SETUP_OPTS="--install-layout=deb"
endif
# Check for systemd presence
ifeq ($(SYSTEMCTL_OVERRIDE),true)
IS_SYSTEMCTL=true
else
ifeq ($(SYSTEMCTL_OVERRIDE),false)
IS_SYSTEMCTL=false
else
IS_SYSTEMCTL = $(shell if [ -d /run/systemd/system ] || [ -d /var/run/systemd/system ] ; then echo true ; else echo false; fi)
endif
endif
# Check for an override for building gems
ifndef BUILD_GEMS
BUILD_GEMS=true
endif
MANDIR=/usr/share/man
ifndef PREFIX
PREFIX=$(shell prefix=`$(PYTHON) -c "import sys; print(sys.prefix)"` || prefix="/usr"; echo $$prefix)
endif
ifndef systemddir
systemddir=/usr/lib/systemd
endif
ifndef initdir
initdir=/etc/init.d
endif
ifndef install_settings
ifeq ($(IS_DEBIAN),true)
install_settings=true
else
install_settings=false
endif
endif
ifndef BASH_COMPLETION_DIR
BASH_COMPLETION_DIR=${DESTDIR}/etc/bash_completion.d
endif
ifndef PCSD_PARENT_DIR
ifeq ($(IS_DEBIAN),true)
PCSD_PARENT_DIR = /usr/share
else
PCSD_PARENT_DIR = ${PREFIX}/lib
endif
endif
ifndef PCS_PARENT_DIR
PCS_PARENT_DIR=${DESTDIR}/${PREFIX}/lib/pcs
endif
BUNDLED_LIB_INSTALL_DIR=${PCS_PARENT_DIR}/bundled
ifndef BUNDLED_LIB_DIR
BUNDLED_LIB_DIR=./pcs/bundled/
endif
BUNDLED_LIB_DIR_ABS=$(shell readlink -f ${BUNDLED_LIB_DIR})
BUNDLES_TMP_DIR=${BUNDLED_LIB_DIR_ABS}/tmp
ifndef SNMP_MIB_DIR
SNMP_MIB_DIR=/share/snmp/mibs/
endif
SNMP_MIB_DIR_FULL=${DESTDIR}/${PREFIX}/${SNMP_MIB_DIR}
pcsd_fonts = \
LiberationSans-Regular.ttf;LiberationSans:style=Regular \
LiberationSans-Bold.ttf;LiberationSans:style=Bold \
LiberationSans-BoldItalic.ttf;LiberationSans:style=BoldItalic \
LiberationSans-Italic.ttf;LiberationSans:style=Italic \
Overpass-Regular.ttf;Overpass:style=Regular \
Overpass-Bold.ttf;Overpass:style=Bold
install: install_bundled_libs
# make Python interpreter execution sane (via -Es flags)
printf "[build]\nexecutable = $(PYTHON) -Es\n" > setup.cfg
$(PYTHON) setup.py install --root=$(or ${DESTDIR}, /) ${EXTRA_SETUP_OPTS}
# fix excessive script interpreting "executable" quoting with old setuptools:
# https://github.com/pypa/setuptools/issues/188
# https://bugzilla.redhat.com/1353934
sed -i '1s|^\(#!\)"\(.*\)"$$|\1\2|' ${DESTDIR}${PREFIX}/bin/pcs
sed -i '1s|^\(#!\)"\(.*\)"$$|\1\2|' ${DESTDIR}${PREFIX}/bin/pcs_snmp_agent
rm setup.cfg
mkdir -p ${DESTDIR}${PREFIX}/sbin/
mv ${DESTDIR}${PREFIX}/bin/pcs ${DESTDIR}${PREFIX}/sbin/pcs
install -D -m644 pcs/bash_completion ${BASH_COMPLETION_DIR}/pcs
install -m644 -D pcs/pcs.8 ${DESTDIR}/${MANDIR}/man8/pcs.8
# pcs SNMP install
mv ${DESTDIR}${PREFIX}/bin/pcs_snmp_agent ${PCS_PARENT_DIR}/pcs_snmp_agent
install -d ${DESTDIR}/var/log/pcs
install -d ${SNMP_MIB_DIR_FULL}
install -m 644 pcs/snmp/mibs/PCMK-PCS*-MIB.txt ${SNMP_MIB_DIR_FULL}
install -m 644 -D pcs/snmp/pcs_snmp_agent.conf ${DESTDIR}/etc/sysconfig/pcs_snmp_agent
install -m 644 -D pcs/snmp/pcs_snmp_agent.8 ${DESTDIR}/${MANDIR}/man8/pcs_snmp_agent.8
ifeq ($(IS_SYSTEMCTL),true)
install -d ${DESTDIR}/${systemddir}/system/
install -m 644 pcs/snmp/pcs_snmp_agent.service ${DESTDIR}/${systemddir}/system/
endif
ifeq ($(IS_DEBIAN),true)
ifeq ($(install_settings),true)
rm -f ${DESTDIR}${PYTHON_SITELIB}/pcs/settings.py
tmp_settings=`mktemp`; \
sed s/DEB_HOST_MULTIARCH/${DEB_HOST_MULTIARCH}/g pcs/settings.py.debian > $$tmp_settings; \
install -m644 $$tmp_settings ${DESTDIR}${PYTHON_SITELIB}/pcs/settings.py; \
rm -f $$tmp_settings
$(PYTHON) -m compileall -fl ${DESTDIR}${PYTHON_SITELIB}/pcs/settings.py
endif
endif
install_pcsd:
ifeq ($(BUILD_GEMS),true)
make -C pcsd build_gems
endif
mkdir -p ${DESTDIR}/var/log/pcsd
ifeq ($(IS_DEBIAN),true)
mkdir -p ${DESTDIR}/usr/share/
cp -r pcsd ${DESTDIR}/usr/share/
install -m 644 -D pcsd/pcsd.conf ${DESTDIR}/etc/default/pcsd
install -d ${DESTDIR}/etc/pam.d
install pcsd/pcsd.pam.debian ${DESTDIR}/etc/pam.d/pcsd
ifeq ($(install_settings),true)
rm -f ${DESTDIR}/usr/share/pcsd/settings.rb
tmp_settings_pcsd=`mktemp`; \
sed s/DEB_HOST_MULTIARCH/${DEB_HOST_MULTIARCH}/g pcsd/settings.rb.debian > $$tmp_settings_pcsd; \
install -m644 $$tmp_settings_pcsd ${DESTDIR}/usr/share/pcsd/settings.rb; \
rm -f $$tmp_settings_pcsd
endif
ifeq ($(IS_SYSTEMCTL),true)
install -d ${DESTDIR}/${systemddir}/system/
install -m 644 pcsd/pcsd.service.debian ${DESTDIR}/${systemddir}/system/pcsd.service
else
install -m 755 -D pcsd/pcsd.debian ${DESTDIR}/${initdir}/pcsd
endif
else
mkdir -p ${DESTDIR}${PCSD_PARENT_DIR}/
cp -r pcsd ${DESTDIR}${PCSD_PARENT_DIR}/
install -m 644 -D pcsd/pcsd.conf ${DESTDIR}/etc/sysconfig/pcsd
install -d ${DESTDIR}/etc/pam.d
install pcsd/pcsd.pam ${DESTDIR}/etc/pam.d/pcsd
ifeq ($(IS_SYSTEMCTL),true)
install -d ${DESTDIR}/${systemddir}/system/
install -m 644 pcsd/pcsd.service ${DESTDIR}/${systemddir}/system/
# ${DESTDIR}${PCSD_PARENT_DIR}/pcsd/pcsd holds the selinux context
install -m 755 pcsd/pcsd.service-runner ${DESTDIR}${PCSD_PARENT_DIR}/pcsd/pcsd
rm ${DESTDIR}${PCSD_PARENT_DIR}/pcsd/pcsd.service-runner
else
install -m 755 -D pcsd/pcsd ${DESTDIR}/${initdir}/pcsd
endif
endif
install -m 700 -d ${DESTDIR}/var/lib/pcsd
install -m 644 -D pcsd/pcsd.logrotate ${DESTDIR}/etc/logrotate.d/pcsd
install -m644 -D pcsd/pcsd.8 ${DESTDIR}/${MANDIR}/man8/pcsd.8
$(foreach font,$(pcsd_fonts),\
$(eval font_file = $(word 1,$(subst ;, ,$(font)))) \
$(eval font_def = $(word 2,$(subst ;, ,$(font)))) \
$(eval font_path = $(shell fc-match '--format=%{file}' '$(font_def)')) \
$(if $(font_path),ln -s -f $(font_path) ${DESTDIR}${PCSD_PARENT_DIR}/pcsd/public/css/$(font_file);,$(error Font $(font_def) not found)) \
)
build_bundled_libs:
ifndef PYAGENTX_INSTALLED
rm -rf ${BUNDLES_TMP_DIR}
mkdir -p ${BUNDLES_TMP_DIR}
$(MAKE) -C pcs/snmp/ build_bundled_libs
rm -rf ${BUNDLES_TMP_DIR}
endif
install_bundled_libs: build_bundled_libs
ifndef PYAGENTX_INSTALLED
install -d ${BUNDLED_LIB_INSTALL_DIR}
cp -r ${BUNDLED_LIB_DIR_ABS}/packages ${BUNDLED_LIB_INSTALL_DIR}
endif
uninstall:
rm -f ${DESTDIR}${PREFIX}/sbin/pcs
rm -rf ${DESTDIR}${PYTHON_SITELIB}/pcs
ifeq ($(IS_DEBIAN),true)
rm -rf ${DESTDIR}/usr/share/pcsd
rm -rf ${DESTDIR}/usr/share/pcs
else
rm -rf ${DESTDIR}${PREFIX}/lib/pcsd
rm -rf ${DESTDIR}${PREFIX}/lib/pcs
endif
ifeq ($(IS_SYSTEMCTL),true)
rm -f ${DESTDIR}/${systemddir}/system/pcsd.service
rm -f ${DESTDIR}/${systemddir}/system/pcs_snmp_agent.service
else
rm -f ${DESTDIR}/${initdir}/pcsd
endif
rm -f ${DESTDIR}/etc/pam.d/pcsd
rm -rf ${DESTDIR}/var/lib/pcsd
rm -f ${SNMP_MIB_DIR_FULL}/PCMK-PCS*-MIB.txt
tarball:
$(PYTHON) setup.py sdist --formats=tar
$(PYTHON) maketarballs.py
newversion:
$(PYTHON) newversion.py