forked from xapi-project/sm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·382 lines (354 loc) · 12.8 KB
/
Makefile
File metadata and controls
executable file
·382 lines (354 loc) · 12.8 KB
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
PYLINT=$(shell command -v pylint-3 || echo pylint)
PYTHONLIBDIR = $(shell python3 -c "import sys; print(sys.path.pop())")
# Sompatibility drivers
SM_COMPAT_DRIVERS :=
# Executable SR drivers
SM_DRIVERS :=
SM_DRIVERS += DummySR
SM_DRIVERS += EXTSR
SM_DRIVERS += FileSR
SM_DRIVERS += HBASR
SM_DRIVERS += ISOSR
SM_DRIVERS += LVHDoHBASR
SM_DRIVERS += LVHDoISCSISR
SM_DRIVERS += LVHDSR
SM_DRIVERS += LVMoHBASR
SM_DRIVERS += LVMoISCSISR
SM_DRIVERS += LVMSR
SM_DRIVERS += NFSSR
SM_DRIVERS += RawISCSISR
SM_DRIVERS += SMBSR
SM_DRIVERS += udevSR
# Things which are library parts of SR drivers
SM_DRIVER_LIBS :=
SM_DRIVER_LIBS += DummySR
SM_DRIVER_LIBS += EXTSR
SM_DRIVER_LIBS += FileSR
SM_DRIVER_LIBS += HBASR
SM_DRIVER_LIBS += ISOSR
SM_DRIVER_LIBS += LVHDoHBASR
SM_DRIVER_LIBS += LVHDoISCSISR
SM_DRIVER_LIBS += LVHDSR
SM_DRIVER_LIBS += NFSSR
SM_DRIVER_LIBS += RawISCSISR
SM_DRIVER_LIBS += SMBSR
SM_DRIVER_LIBS += udevSR
# Libraries which have moved in to sm.core
SM_CORE_LIBS :=
SM_CORE_LIBS += util
SM_CORE_LIBS += scsiutil
SM_CORE_LIBS += mpath_dmp
SM_CORE_LIBS += mpath_cli
SM_CORE_LIBS += mpath_null
SM_CORE_LIBS += xs_errors
SM_CORE_LIBS += iscsi
SM_CORE_LIBS += wwid_conf
SM_CORE_LIBS += lock
SM_CORE_LIBS += flock
SM_CORE_LIBS += f_exceptions
# Add a "pretend" core lib to cover the iscsi differences
# This uses sm.core.iscsi but provides some methods which
# sm-core-libs provided differently.
SM_CORE_LIBS += libiscsi
SM_LIBS :=
SM_LIBS += BaseISCSI
SM_LIBS += blktap2
SM_LIBS += cbtutil
SM_LIBS += cifutils
SM_LIBS += cleanup
SM_LIBS += constants
SM_LIBS += devscan
SM_LIBS += fjournaler
SM_LIBS += ipc
SM_LIBS += journaler
SM_LIBS += lock_queue
SM_LIBS += LUNperVDI
SM_LIBS += lvhdutil
SM_LIBS += lvmanager
SM_LIBS += lvmcache
SM_LIBS += lvutil
SM_LIBS += metadata
SM_LIBS += mpathcount
SM_LIBS += nfs
SM_LIBS += on_slave
SM_LIBS += pluginutil
SM_LIBS += refcounter
SM_LIBS += resetvdis
SM_LIBS += SR
SM_LIBS += SRCommand
SM_LIBS += sr_health_check
SM_LIBS += srmetadata
SM_LIBS += sysdevice
SM_LIBS += trim_util
SM_LIBS += VDI
SM_LIBS += vhdutil
# Things used as commands which install in libexec
# which are in python and need compatibility symlinks from
# /opt
SM_LIBEXEC_PY_CMDS :=
SM_LIBEXEC_PY_CMDS += cleanup
SM_LIBEXEC_PY_CMDS += lvhdutil
SM_LIBEXEC_PY_CMDS += mpathcount
SM_LIBEXEC_PY_CMDS += resetvdis
SM_LIBEXEC_PY_CMDS += sr_health_check
SM_LIBEXEC_PY_CMDS += verifyVHDsOnSR
# Things used as commands which install in libexec
# which are in python and need a compatibility symlink
# from /opt's plugins directory
SM_PLUGIN_UTILS := keymanagerutil
# Things which are written as commands but have
# a .py extension which may eventually be dropped
# They are installed in libexec under a subdirectory
# and symlinked from /opt using their original names
SM_LIBEXEC_PY_XTRAS :=
SM_LIBEXEC_PY_XTRAS += scsi_host_rescan
# SCRIPTS which install in libexec
SM_LIBEXEC_SCRIPTS := local-device-change
SM_LIBEXEC_SCRIPTS += check-device-sharing
SM_LIBEXEC_SCRIPTS += usb_change
SM_LIBEXEC_SCRIPTS += kickpipe
SM_LIBEXEC_SCRIPTS += set-iscsi-initiator
SM_LIBEXEC_SCRIPTS += make-dummy-sr
SM_LIBEXEC_SCRIPTS += storage-init
# Populates the plugin library in the python lib path
SM_PLUGINS :=
SM_PLUGINS += __init__.py
SM_PLUGINS += keymanagerutil.py
SM_PLUGIN_SCRIPTS :=
SM_PLUGIN_SCRIPTS += lvhd-thin
SM_PLUGIN_SCRIPTS += on-slave
SM_PLUGIN_SCRIPTS += testing-hooks
SM_PLUGIN_SCRIPTS += coalesce-leaf
SM_PLUGIN_SCRIPTS += nfs-on-slave
SM_PLUGIN_SCRIPTS += tapdisk-pause
SM_PLUGIN_SCRIPTS += intellicache-clean
SM_PLUGIN_SCRIPTS += trim
SM_UDEV_SCRIPTS := xs-mpath-scsidev.sh
SM_XAPI_SHUTDOWN_SCRIPTS := stop_all_gc
# Libraries which remain in drivers/ and get installed in
# /opt/xensource/sm. All of which will eventually be wrappers around
# sm.core libs for backwards compatibility and can hopefully be one
# day dropped
SM_COMPAT_LIBS := util
SM_COMPAT_LIBS += scsiutil
SM_COMPAT_LIBS += mpath_dmp
SM_COMPAT_LIBS += mpath_cli
SM_COMPAT_LIBS += xs_errors
SM_COMPAT_LIBS += iscsilib
SM_COMPAT_LIBS += wwid_conf
SM_COMPAT_LIBS += lock
SM_COMPAT_LIBS += flock
SM_COMPAT_LIBS += mpath_null
SM_COMPAT_LIBS += SR
SM_COMPAT_LIBS += SRCommand
SM_COMPAT_LIBS += VDI
SM_COMPAT_LIBS += BaseISCSI
SM_COMPAT_LIBS += lvutil
SM_COMPAT_LIBS += lvmcache
SM_COMPAT_LIBS += vhdutil
SM_COMPAT_LIBS += lvhdutil
SM_COMPAT_LIBS += cifutils
SM_COMPAT_LIBS += nfs
SM_COMPAT_LIBS += devscan
SM_COMPAT_LIBS += sysdevice
SM_COMPAT_LIBS += LUNperVDI
SM_COMPAT_LIBS += refcounter
SM_COMPAT_LIBS += journaler
SM_COMPAT_LIBS += fjournaler
SM_COMPAT_LIBS += lock_queue
SM_COMPAT_LIBS += ipc
SM_COMPAT_LIBS += srmetadata
SM_COMPAT_LIBS += metadata
SM_COMPAT_LIBS += lvmanager
SM_COMPAT_LIBS += trim_util
SM_COMPAT_LIBS += pluginutil
SM_COMPAT_LIBS += constants
SM_COMPAT_LIBS += cbtutil
UDEV_RULES = 65-multipath 55-xs-mpath-scsidev 57-usb 58-xapi 99-purestorage
MPATH_CUSTOM_CONF = custom.conf
SMLOG_CONF = SMlog
SM_XML := XE_SR_ERRORCODES
OPT_SM_DEST := /opt/xensource/sm/
OPT_DEBUG_DEST := /opt/xensource/debug/
OPT_BIN_DEST := /opt/xensource/bin/
OPT_LIBEXEC := /opt/xensource/libexec/
MASTER_SCRIPT_DEST := /etc/xensource/master.d/
PLUGIN_SCRIPT_DEST := /etc/xapi.d/plugins/
BIN_DEST := /usr/bin/
SM_LIBEXEC := /usr/libexec/sm/
SM_DATADIR := /usr/share/sm/
UDEV_RULES_DIR := /etc/udev/rules.d/
UDEV_SCRIPTS_DIR := /etc/udev/scripts/
SYSTEMD_SERVICE_DIR := /usr/lib/systemd/system/
INIT_DIR := /etc/rc.d/init.d/
MPATH_CUSTOM_CONF_DIR := /etc/multipath/conf.d/
MODPROBE_DIR := /etc/modprobe.d/
EXTENSION_SCRIPT_DEST := /etc/xapi.d/extensions/
LOGROTATE_DIR := /etc/logrotate.d/
SM_STAGING := $(DESTDIR)
SM_STAMP := $(MY_OBJ_DIR)/.staging_stamp
SM_PY_FILES = $(foreach LIB, $(SM_LIBS), libs/sm/$(LIB).py) libs/sm/__init__.py
SM_CORE_PY_FILES = $(foreach LIB, $(SM_CORE_LIBS), libs/sm/core/$(LIB).py) libs/sm/core/__init__.py
SM_DRIVER_PY_FILES = $(foreach LIB, $(SM_DRIVER_LIBS), libs/sm/drivers/$(LIB).py) libs/sm/drivers/__init__.py $(foreach DRIVER, $(SM_DRIVERS), drivers/$(DRIVER))
SM_COMPAT_PY_FILES = $(foreach LIB, $(SM_COMPAT_LIBS), compat-libs/$(LIB).py) $(foreach DRIVER, $(SM_COMPAT_DRIVERS), drivers/$(DRIVER)SR.py)
# Various bits of python which need to be included in pylint etc, but are installed via other means
SM_XTRA_PY_FILES :=
SM_XTRA_PY_FILES += $(foreach LIB, $(SM_LIBEXEC_PY_CMDS), utils/$(LIB))
SM_XTRA_PY_FILES += $(foreach LIB, $(SM_LIBEXEC_PY_XTRAS), utils/$(LIB).py)
SM_XTRA_PY_FILES += utils/mpathutil.py
SM_XTRA_PY_FILES += utils/blktap2
SM_XTRA_PY_FILES += utils/tapdisk-cache-stats
SM_XTRA_PY_FILES += utils/keymanagerutil
.PHONY: build
build:
make -C dcopy
.PHONY: precommit
precommit: build
@ QUIT=0; \
CHANGED=$$(git status --porcelain $(SM_PY_FILES) $(SM_CORE_PY_FILES) $(SM_DRIVER_PY_FILES) $(SM_COMPAT_PY_FILES) | awk '{print $$2}'); \
for i in $$CHANGED; do \
echo Checking $${i} ...; \
PYTHONPATH=./drivers:./libs:./misc/fairlock:$$PYTHONPATH $(PYLINT) --rcfile=tests/pylintrc $${i}; \
[ $$? -ne 0 ] && QUIT=1 ; \
done; \
if [ $$QUIT -ne 0 ]; then \
exit 1; \
fi; \
echo "Precommit succeeded with no outstanding issues found."
.PHONY: precheck
precheck: build
PYTHONPATH=./drivers:./libs:./misc/fairlock:$$PYTHONPATH $(PYLINT) --rcfile=tests/pylintrc $(SM_PY_FILES) $(SM_CORE_PY_FILES) $(SM_DRIVER_PY_FILES) $(SM_XTRA_PY_FILES) $(SM_COMPAT_PY_FILES)
echo "Precheck succeeded with no outstanding issues found."
.PHONY: install
install: precheck
mkdir -p $(SM_STAGING)
$(call mkdir_clean,$(SM_STAGING))
mkdir -p $(SM_STAGING)$(OPT_SM_DEST)
mkdir -p $(SM_STAGING)$(UDEV_RULES_DIR)
mkdir -p $(SM_STAGING)$(UDEV_SCRIPTS_DIR)
mkdir -p $(SM_STAGING)$(INIT_DIR)
mkdir -p $(SM_STAGING)$(SYSTEMD_SERVICE_DIR)
mkdir -p $(SM_STAGING)$(MPATH_CUSTOM_CONF_DIR)
mkdir -p $(SM_STAGING)$(MODPROBE_DIR)
mkdir -p $(SM_STAGING)$(LOGROTATE_DIR)
mkdir -p $(SM_STAGING)$(OPT_DEBUG_DEST)
mkdir -p $(SM_STAGING)$(OPT_BIN_DEST)
mkdir -p $(SM_STAGING)$(MASTER_SCRIPT_DEST)
mkdir -p $(SM_STAGING)$(PLUGIN_SCRIPT_DEST)
mkdir -p $(SM_STAGING)$(EXTENSION_SCRIPT_DEST)
mkdir -p $(SM_STAGING)$(SM_LIBEXEC)
mkdir -p $(SM_STAGING)$(OPT_LIBEXEC)
mkdir -p $(SM_STAGING)$(OPT_SM_DEST)/plugins
mkdir -p $(SM_STAGING)/sbin
# SM libs
mkdir -p $(SM_STAGING)/$(PYTHONLIBDIR)/sm
install -D -m 644 libs/sm/__init__.py $(SM_STAGING)$(PYTHONLIBDIR)/sm/__init__.py
for i in $(SM_PY_FILES); do \
install -D -m 644 $$i $(SM_STAGING)$(PYTHONLIBDIR)/sm/; \
done
# Core libs
mkdir -p $(SM_STAGING)/$(PYTHONLIBDIR)/sm/core
install -D -m 644 libs/sm/core/__init__.py $(SM_STAGING)$(PYTHONLIBDIR)/sm/core/__init__.py
for i in $(SM_CORE_LIBS); do \
install -D -m 644 libs/sm/core/$$i.py $(SM_STAGING)$(PYTHONLIBDIR)/sm/core/; \
done
# Driver libs
mkdir -p $(SM_STAGING)/$(PYTHONLIBDIR)/sm/drivers
install -D -m 644 libs/sm/drivers/__init__.py $(SM_STAGING)$(PYTHONLIBDIR)/sm/drivers/__init__.py
for i in $(SM_DRIVER_LIBS); do \
install -D -m 644 libs/sm/drivers/$$i.py $(SM_STAGING)$(PYTHONLIBDIR)/sm/drivers/; \
done
# Data files (primarily XML error definitions)
mkdir -p $(SM_STAGING)$(SM_DATADIR)
for i in $(SM_XML); do \
install -D -m 644 libs/sm/core/$$i.xml $(SM_STAGING)$(SM_DATADIR)/; \
done
# Legacy SM python files
for i in $(SM_COMPAT_PY_FILES); do \
install -m 755 $$i $(SM_STAGING)$(OPT_SM_DEST); \
done
# Plugin utilities
for i in $(SM_PLUGIN_UTILS); do \
install -D -m 755 utils/$$i $(SM_STAGING)/$(SM_LIBEXEC)$$i; \
ln -sf $(SM_LIBEXEC)$$i $(SM_STAGING)$(OPT_SM_DEST)plugins/$$i".py"; \
done
# Actual plugins (and plugin libraries)
for i in $(SM_PLUGINS); do \
install -D -m 755 libs/sm/plugins/$$i $(SM_STAGING)/$(PYTHONLIBDIR)/sm/plugins/$$i; \
done
install -m 644 multipath/$(MPATH_CUSTOM_CONF) \
$(SM_STAGING)/$(MPATH_CUSTOM_CONF_DIR)
install -m 755 multipath/multipath-root-setup \
$(SM_STAGING)/$(SM_LIBEXEC)/multipath-root-setup
install -m 644 etc/logrotate.d/$(SMLOG_CONF) \
$(SM_STAGING)/$(LOGROTATE_DIR)
install -m 644 etc/make-dummy-sr.service \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
install -m 644 systemd/xs-sm.service \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
install -m 644 systemd/sm-mpath-root.service \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
install -m 644 systemd/usb-scan.* \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
install -m 644 systemd/mpathcount.* \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
install -m 644 systemd/storage-init.service \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
install -m 644 systemd/sr_health_check.service \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
install -m 644 systemd/sr_health_check.timer \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
install -m 644 systemd/SMGC@.service \
$(SM_STAGING)/$(SYSTEMD_SERVICE_DIR)
for i in $(UDEV_RULES); do \
install -m 644 udev/$$i.rules \
$(SM_STAGING)$(UDEV_RULES_DIR); done
# Install SR drivers with symlinks from the legacy location
for i in $(SM_DRIVERS); do \
install -D -m 755 drivers/$$i $(SM_STAGING)/$(SM_LIBEXEC)/drivers/$$i; \
ln -sf $(SM_LIBEXEC)drivers/$$i $(SM_STAGING)$(OPT_SM_DEST)/$$i; \
done
# Install legacy SR drivers
cd $(SM_STAGING)$(OPT_SM_DEST) && for i in $(SM_COMPAT_DRIVERS); do \
ln -sf $$i"SR.py" $$i"SR"; \
done
install -m 755 scripts/02-vhdcleanup $(SM_STAGING)$(MASTER_SCRIPT_DEST)
for i in $(SM_PLUGIN_SCRIPTS); do \
install -D -m 755 scripts/plugins/$$i $(SM_STAGING)$(PLUGIN_SCRIPT_DEST)/$$i; \
done
# Install libexec scripts with symlinks from the legacy location
for s in $(SM_LIBEXEC_SCRIPTS); do \
install -m 755 scripts/$$s $(SM_STAGING)$(SM_LIBEXEC)/$$s; \
ln -sf $(SM_LIBEXEC)$$s $(SM_STAGING)$(OPT_LIBEXEC)/$$s; \
done
# Install libexec commands with symlinks from the legacy location
for s in $(SM_LIBEXEC_PY_CMDS); do \
install -m 755 utils/$$s $(SM_STAGING)$(SM_LIBEXEC)/$$s; \
ln -sf $(SM_LIBEXEC)$$s $(SM_STAGING)$(OPT_SM_DEST)/"$$s".py; \
done
# Install libexec extras with symlinks from the legacy location
for s in $(SM_LIBEXEC_PY_XTRAS); do \
install -D -m 755 utils/"$$s".py $(SM_STAGING)$(SM_LIBEXEC)/xtra/$$s; \
ln -sf $(SM_LIBEXEC)xtra/$$s $(SM_STAGING)$(OPT_SM_DEST)/"$$s".py; \
done
mkdir -p $(SM_STAGING)/etc/xapi.d/xapi-pre-shutdown
for s in $(SM_XAPI_SHUTDOWN_SCRIPTS); do \
install -m 755 scripts/$$s $(SM_STAGING)/etc/xapi.d/xapi-pre-shutdown/$$s; \
done
for s in $(SM_UDEV_SCRIPTS); do \
install -m 755 scripts/$$s $(SM_STAGING)$(UDEV_SCRIPTS_DIR)/$$s; \
done
# Install mpathutil and compatibility symlinks
install -D -m 755 utils/mpathutil.py $(SM_STAGING)$(BIN_DEST)/mpathutil
ln -sf $(BIN_DEST)mpathutil $(SM_STAGING)$(OPT_SM_DEST)/mpathutil.py
ln -sf $(BIN_DEST)mpathutil $(SM_STAGING)/sbin/mpathutil
# Install blktap2 and compatibility symlinks
install -D -m 755 utils/blktap2 $(SM_STAGING)$(BIN_DEST)/blktap2
ln -sf $(BIN_DEST)blktap2 $(SM_STAGING)$(OPT_BIN_DEST)/blktap2
# Install tapdisk-cache-stats and compatibility symlinks
install -D -m 755 utils/tapdisk-cache-stats $(SM_STAGING)$(BIN_DEST)/tapdisk-cache-stats
ln -sf $(BIN_DEST)tapdisk-cache-stats $(SM_STAGING)$(OPT_BIN_DEST)/tapdisk-cache-stats
$(MAKE) -C dcopy install DESTDIR=$(SM_STAGING)
.PHONY: clean
clean:
rm -rf $(SM_STAGING)