1
0
mirror of https://github.com/limosek/zaf.git synced 2024-11-22 02:19:06 +01:00
limosek-zaf/Makefile

88 lines
3.1 KiB
Makefile
Raw Normal View History

2016-04-06 14:25:10 +02:00
# Zabbix agent framework makefile
CONTROLFILES=$(foreach p,$(PLUGINS),$(p)/control.zaf)
ZAF_EXPORT_OPTS=$(foreach o,$(ZAF_OPTIONS),$(shell echo $(o)|cut -d '=' -f 1))
DEBIAN_DIR=tmp/deb
DEBIAN_CTRL=$(DEBIAN_DIR)/DEBIAN
2016-04-12 10:36:17 +02:00
DEBIAN_PKG=$(shell . lib/zaf.lib.sh; echo out/zaf-$$ZAF_VERSION.deb)
ifeq ($(ZAF_OPTIONS),)
ZAF_OPTIONS = ZAF_GIT=0
endif
ifeq ($(IPLUGINS),)
IPLUGINS = zaf
endif
2016-04-06 14:25:10 +02:00
all: help
help:
2016-04-12 10:36:17 +02:00
@echo make '{deb|ipk|rpm}' '[PLUGINS="/dir/plg1 [/dir2]...] [IPLUGINS="plg1 [plg2]..."] [ZAF_OPTIONS="ZAF_cfg=val ..."] [AGENT_OPTIONS="Z_Server=host ..."]'
@echo PLUGINS are embedded into package. Has to be local directories accessible during build.
@echo IPLUGINS will be downloaded and installed after package is installed. Can be name or url accessible after package installation.
@echo
deb: $(DEBIAN_PKG)
2016-04-06 14:25:10 +02:00
2016-04-12 10:36:17 +02:00
$(DEBIAN_PKG): deb-clean deb-init deb-deps deb-control deb-scripts deb-cp deb-package
clean:
@rm -rf tmp/* out/*
2016-04-06 14:25:10 +02:00
deb-clean:
2016-04-07 13:14:53 +02:00
@rm -rf $(DEBIAN_DIR) $(DEBIAN_PKG)
2016-04-06 14:25:10 +02:00
deb-init:
@mkdir -p tmp out $(DEBIAN_DIR)
deb-deps: $(CONTROLFILES)
@which dpkg >/dev/null && which dpkg-buildpackage >/dev/null && which dch >/dev/null || { echo "You need essential debian developer tools. Please install them:\nsudo apt-get install build-essential devscripts debhelper"; exit 2; }
deb-control:
@mkdir -p $(DEBIAN_CTRL)
@. lib/zaf.lib.sh; \
. lib/ctrl.lib.sh; \
for p in $(PLUGINS); do \
DEPENDS="$$DEPENDS,$$(zaf_ctrl_get_global_option $$p/control.zaf Depends-dpkg | tr ' ' ',')"; \
done; \
2016-04-12 10:36:17 +02:00
zaf_far '{ZAF_VERSION}' "$$ZAF_VERSION" <files/control.template | zaf_far '{ZAF_DEPENDS}' "$$DEPENDS" >$(DEBIAN_CTRL)/control
2016-04-06 14:25:10 +02:00
2016-04-07 13:14:53 +02:00
deb-scripts:
2016-04-06 14:25:10 +02:00
@. lib/zaf.lib.sh; \
. lib/ctrl.lib.sh; \
2016-04-12 10:36:17 +02:00
cat files/postinst.template | zaf_far '{PLUGINS}' "$(PLUGINS)" | zaf_far "{IPLUGINS}" "$(IPLUGINS)" | zaf_far '{ZAF_LIB_DIR}' "/usr/lib/zaf" >$(DEBIAN_CTRL)/postinst
2016-04-06 14:25:10 +02:00
@chmod +x $(DEBIAN_CTRL)/postinst
2016-04-07 13:14:53 +02:00
@cp files/preinst.template $(DEBIAN_CTRL)/preinst
@chmod +x $(DEBIAN_CTRL)/preinst
@cp files/prerm.template $(DEBIAN_CTRL)/prerm
@chmod +x $(DEBIAN_CTRL)/prerm
2016-04-06 14:25:10 +02:00
deb-cp:
@mkdir -p $(DEBIAN_DIR)
2016-04-07 13:14:53 +02:00
@set -e; INSTALL_PREFIX=$(DEBIAN_DIR) ZAF_DEBUG=0 ./install.sh auto $(ZAF_OPTIONS) $(AGENT_OPTIONS)
2016-04-06 14:25:10 +02:00
@. lib/zaf.lib.sh; \
. lib/ctrl.lib.sh; \
for p in $(PLUGINS); do \
plugin=$$(zaf_ctrl_get_global_option $$p/control.zaf Plugin) ; \
2016-04-07 13:14:53 +02:00
mkdir -p $(DEBIAN_DIR)/usr/lib/zaf/prepackaged/$$plugin/; \
cp -R $$p/* $(DEBIAN_DIR)/usr/lib/zaf/prepackaged/$$plugin/; \
2016-04-06 14:25:10 +02:00
done
2016-04-07 13:14:53 +02:00
@cat lib/*lib.sh install.sh >$(DEBIAN_DIR)/usr/lib/zaf/install.sh
@chmod +x $(DEBIAN_DIR)/usr/lib/zaf/install.sh
2016-04-06 14:25:10 +02:00
@rm -rf $(DEBIAN_DIR)/tmp
@cp $(DEBIAN_DIR)/etc/zaf.conf tmp/zaf.conf
2016-04-07 13:14:53 +02:00
@grep -E "$$(echo $(ZAF_EXPORT_OPTS) | tr ' ' '|')=" tmp/zaf.conf >$(DEBIAN_DIR)/etc/zaf.conf
@echo "ZAF_PREPACKAGED_DIR=\"/usr/lib/zaf/prepackaged\"" >>$(DEBIAN_DIR)/etc/zaf.conf
2016-04-06 14:25:10 +02:00
ifneq ($(AGENT_OPTIONS),)
2016-04-07 13:14:53 +02:00
@echo "ZAF_AGENT_OPTIONS=\"$(AGENT_OPTIONS)\"" >>$(DEBIAN_DIR)/etc/zaf.conf
2016-04-06 14:25:10 +02:00
endif
deb-package:
2016-04-07 13:14:53 +02:00
@dpkg-deb -b $(DEBIAN_DIR) $(DEBIAN_PKG)
2016-04-07 13:20:55 +02:00
@echo "\nCheck configuration:"
@cat $(DEBIAN_DIR)/etc/zaf.conf
2016-04-12 10:36:17 +02:00
@echo PLUGINS embedded: $(PLUGINS)
@echo PLUGINS in postinst: $(IPLUGINS)
2016-04-07 13:20:55 +02:00
@echo
2016-04-06 14:25:10 +02:00