2 # You can select a subset of the packages by overriding this
3 # variale, e.g. make PACKAGES='nagios rrdtool' pack
4 PACKAGES
=perl-modules \
39 # If you just want to test package building, you can reduce the
40 # number of packages to just "omd" - to speed up your tests.
43 # This file is kept by 'make config' and also may override
44 # the list of packages
47 DESTDIR ?
=$(shell pwd
)/destdir
48 RPM_TOPDIR
=$$(pwd
)/rpm.topdir
49 DPKG_TOPDIR
=$$(pwd
)/dpkg.topdir
50 SOURCE_TGZ
=omd-
$(OMD_VERSION
).
tar.gz
51 BIN_TGZ
=omd-bin-
$(OMD_VERSION
).
tar.gz
52 NEWSERIAL
=$$(($(OMD_SERIAL
) + 1))
53 APACHE_NAME
=$(APACHE_INIT_NAME
)
55 DEFAULT_BUILD
=build-cached
60 .PHONY
: install-global
65 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
66 OMD_VERSION
="$(OMD_VERSION)" BUILD_CACHE
="$(BUILD_CACHE)" ..
/build_cached
"$(MAKE)" "$$p" "$(DISTRO_NAME)/$(DISTRO_VERSION)/$(shell uname -m)"; \
71 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
72 $(MAKE
) -C
$$p build
; \
76 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
77 ( NOW
=$$(date
+%s
) ; \
78 $(MAKE
) -C
$$p build
> ..
/$$p.log
2>&1 \
79 && echo
"$$p(ok - $$(( $$(date +%s) - NOW ))s)" \
80 || echo
"$$p(ERROR - $$(( $$(date +%s) - NOW ))s)" ) & \
81 done
; wait
; echo
"FINISHED."
85 mkdir
-p
$(DESTDIR
)$(OMD_PHYSICAL_BASE
)
86 A
="$(OMD_PHYSICAL_BASE)" ; ln
-s
$${A
:1} $(DESTDIR
)/omd
87 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
88 $(MAKE
) -C
$$p DESTDIR
=$(DESTDIR
) install ; \
89 for hook in
$$(cd
$$p ; ls
*.hook
2>/dev
/null
) ; do \
90 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/lib
/omd
/hooks
; \
91 install -m
755 $$p/$$hook $(DESTDIR
)$(OMD_ROOT
)/lib
/omd
/hooks
/$${hook
%.hook
} ; \
95 # Repair packages that install with silly modes (such as Nagios)
96 chmod
-R o
+Xr
$(DESTDIR
)$(OMD_ROOT
)
97 $(MAKE
) install-global
99 # Install skeleton files (subdirs skel/ in packages' directories)
100 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/skel
101 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
102 if
[ -d
"$$p/skel" ] ; then \
103 tar cf
- -C
$$p/skel
--exclude
="*~" --exclude
=".gitignore" . |
tar xvf
- -C
$(DESTDIR
)$(OMD_ROOT
)/skel
; \
105 $(MAKE
) SKEL
=$(DESTDIR
)$(OMD_ROOT
)/skel
-C
$$p skel
;\
108 # Create permissions file for skel
109 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/share
/omd
110 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
111 if
[ -e
$$p/skel.permissions
] ; then \
113 cat
$$p/skel.permissions
; \
115 done
> $(DESTDIR
)$(OMD_ROOT
)/share
/omd
/skel.permissions
117 # Make sure, all permissions in skel are set to 0755, 0644
118 @failed
=$$(find
$(DESTDIR
)$(OMD_ROOT
)/skel
-type d
-not
-perm
0755) ; \
119 if
[ -n
"$$failed" ] ; then \
120 echo
"Invalid permissions for skeleton dirs. Must be 0755:" ; \
121 echo
"I'll fix this for you this time..." ; \
122 chmod
-c
755 $$failed ; \
125 @failed
=$$(find
$(DESTDIR
)$(OMD_ROOT
)/skel
-type f
-not
-perm
0644) ; \
126 if
[ -n
"$$failed" ] ; then \
127 echo
"Invalid permissions for skeleton files. Must be 0644:" ; \
129 echo
"I'll fix this for you this time..." ; \
130 chmod
-c
644 $$failed ; \
133 # Fix packages which did not add ###ROOT###
134 find
$(DESTDIR
)$(OMD_ROOT
)/skel
-type f | xargs
-n1 sed
-i
-e
's+$(OMD_ROOT)+###ROOT###+g'
136 # Remove site-specific directories that went under /omd/version
137 rm -rf
$(DESTDIR
)/{var
,tmp
}
139 # Pack the whole stuff into a tarball
140 tar czf
$(BIN_TGZ
) --owner
=root
--group
=root
-C
$(DESTDIR
) .
144 @for p in packages
/* ; do \
145 $(MAKE
) -C
$$p clean ; \
155 for x in
"$$@" ; do if
[ $$elem = $$x ] ; then return
0 ; fi
; done
; \
158 if
[ "$(PACKAGES)" = '*' ] ; \
162 enabled
=( $(PACKAGES
) ) ; \
165 avail
=$$(for p in
$$(cd packages
; ls
) ; do if
[ "$$enabled" = '*' ] || inarray
$$p $${enabled
[@
]} ; then en
=on
; else en
="-" ; fi
; echo
-n
"$$p - $$en " ; done
) ; \
166 if packages
=$$(dialog
--stdout
--checklist
"Package configuration" 1 0 0 $$avail ) ; \
168 echo
"PACKAGES = $$packages" | sed
's/"//g' > .config
; \
172 # Create installations files that do not lie beyond /omd/versions/$(OMD_VERSION)
173 # and files not owned by a specific package.
175 # Create link to default version
176 ln
-s
$(OMD_VERSION
) $(DESTDIR
)$(OMD_BASE
)/versions
/default
178 # Create global symbolic links. Those links are share between
179 # all installed versions and refer to the default version.
180 mkdir
-p
$(DESTDIR
)/usr
/bin
181 ln
-sfn
/omd
/versions
/default
/bin
/omd
$(DESTDIR
)/usr
/bin
/omd
182 mkdir
-p
$(DESTDIR
)/usr
/share
/man
/man8
183 ln
-sfn
/omd
/versions
/default
/share
/man
/man8
/omd
.8.gz
$(DESTDIR
)/usr
/share
/man
/man8
/omd
.8.gz
184 mkdir
-p
$(DESTDIR
)/etc
/init.d
185 ln
-sfn
/omd
/versions
/default
/share
/omd
/omd.init
$(DESTDIR
)/etc
/init.d
/omd
186 mkdir
-p
$(DESTDIR
)$(APACHE_CONF_DIR
)
187 ln
-sfn
/omd
/versions
/default
/share
/omd
/apache.conf
$(DESTDIR
)$(APACHE_CONF_DIR
)/zzz_omd.conf
189 # Base directories below /omd
190 mkdir
-p
$(DESTDIR
)$(OMD_BASE
)/sites
191 mkdir
-p
$(DESTDIR
)$(OMD_BASE
)/apache
194 # Information about distribution and OMD
195 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/share
/omd
196 install -m
644 distros
/Makefile.
$(DISTRO_NAME
)_
$(DISTRO_VERSION
) $(DESTDIR
)$(OMD_ROOT
)/share
/omd
/distro.
info
197 echo
-e
"OMD_VERSION = $(OMD_VERSION)\nOMD_PHYSICAL_BASE = $(OMD_PHYSICAL_BASE)" > $(DESTDIR
)$(OMD_ROOT
)/share
/omd
/omd.
info
199 # README files and license information
200 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/share
/doc
201 install -m
644 README COPYING TEAM
$(DESTDIR
)$(OMD_ROOT
)/share
/doc
202 install -m
644 Changelog
$(DESTDIR
)$(OMD_ROOT
)/share
/doc
/CHANGELOG
204 # Create source tarball. This currently only works in a checked out GIT
207 rm -rf omd-
$(OMD_VERSION
)
208 mkdir
-p omd-
$(OMD_VERSION
)
209 git archive HEAD |
tar xf
- -C omd-
$(OMD_VERSION
)
210 tar czf
$(SOURCE_TGZ
) omd-
$(OMD_VERSION
)
211 rm -rf omd-
$(OMD_VERSION
)
213 # Creates source tarball. This does only work well in directories extracted
214 # from a CLEAN git archive tarball.
215 $(SOURCE_TGZ
)-snap snap
:
216 rm -rf omd-
$(OMD_VERSION
)
217 mkdir
-p omd-
$(OMD_VERSION
)
218 tar cf
- --exclude
="rpm.topdir" --exclude
="*~" --exclude
=".gitignore" --exclude
"omd-$(OMD_VERSION)" . |
tar xf
- -C omd-
$(OMD_VERSION
)
219 tar czf
$(SOURCE_TGZ
) omd-
$(OMD_VERSION
)
220 rm -rf omd-
$(OMD_VERSION
)
222 # Build RPM from source code.
223 # When called from a git repository this uses 'make dist' and thus 'git archive'
224 # to create the source rpm.
225 # The second choice is to call this form a CLEAN git archive directory which
226 # then uses 'make snap' to use that snapshot.
228 sed
-e
's/^Requires:.*/Requires: $(OS_PACKAGES)/' \
229 -e
's/%{version}/$(OMD_VERSION)/g' \
230 -e
's/^Version:.*/Version: $(DISTRO_CODE)/' \
231 -e
's/^Release:.*/Release: $(OMD_SERIAL)/' \
232 -e
's#@APACHE_CONFDIR@#$(APACHE_CONF_DIR)#g' \
233 -e
's#@APACHE_NAME@#$(APACHE_NAME)#g' \
234 omd.spec.in
> omd.spec
236 test -d .git
&& $(MAKE
) $(SOURCE_TGZ
) ||
$(MAKE
) $(SOURCE_TGZ
)-snap
237 mkdir
-p
$(RPM_TOPDIR
)/{SOURCES
,BUILD
,RPMS
,SRPMS
,SPECS
}
238 cp
$(SOURCE_TGZ
) $(RPM_TOPDIR
)/SOURCES
239 # NO_BRP_STALE_LINK_ERROR ignores errors when symlinking from skel to
240 # share,lib,bin because the link has a invalid target until the site is created
241 NO_BRP_STALE_LINK_ERROR
="yes" \
242 rpmbuild
-ba
--define "_topdir $(RPM_TOPDIR)" \
243 --buildroot
=$$(pwd
)/rpm.buildroot omd.spec
244 mv
-v
$(RPM_TOPDIR
)/RPMS
/*/*.rpm .
245 mv
-v
$(RPM_TOPDIR
)/SRPMS
/*.src.rpm .
246 rm -rf
$(RPM_TOPDIR
) rpm.buildroot
248 # Build DEB from prebuild binary. This currently needs 'make dist' and thus only
249 # works within a GIT repository.
251 @if
test -z
"$(DEBFULLNAME)" ||
test -z
"$(DEBEMAIL)"; then \
252 echo
"please read 'man dch' and set DEBFULLNAME and DEBEMAIL" ;\
256 # create a debian/changelog to build the package
257 deb-changelog
: deb-environment
259 rm -f debian
/changelog
260 dch
--create
--package omd-
$(OMD_VERSION
) \
261 --newversion
0.
$(DISTRO_CODE
) "`cat debian/changelog.tmpl`"
262 dch
--release
"releasing ...."
265 sed
-e
's/###OMD_VERSION###/$(OMD_VERSION)/' \
266 -e
's/###BUILD_PACKAGES###/$(BUILD_PACKAGES)/' \
267 -e
's/###OS_PACKAGES###/$(OS_PACKAGES)/' \
268 -e
'/Depends:/s/\> /, /g' \
269 -e
'/Depends:/s/@/ /g' \
270 `pwd`/debian
/control.in
> `pwd`/debian
/control
271 fakeroot debian
/rules
clean
272 debuild
--no-lintian
-i\.git
-I\.git \
273 -iomd-bin-
$(OMD_VERSION
).
tar.gz \
274 -Iomd-bin-
$(OMD_VERSION
).
tar.gz \
275 -i.gitignore
-I.gitignore \
277 # -- renaming deb package to DISTRO_CODE dependend name
278 # arch=`dpkg-architecture -qDEB_HOST_ARCH` ; \
279 # build=`sed -e '1s/.*(\(.*\)).*/\1/;q' debian/changelog` ; \
280 # distro=`echo $$build | sed -e 's/build/$(DISTRO_CODE)/' ` ; \
281 # echo "$$arch $$build $$distro"; \
282 # mv "../omd-$(OMD_VERSION)_$${build}_$${arch}.deb" \
283 # "../omd-$(OMD_VERSION)_$${distro}_$${arch}.deb" ;
285 deb-snap
: deb-environment
286 make
clean && git checkout
-- Makefile.omd packages
/omd
/omd
&& \
287 make VERSION
=`./get_version` version
&& make deb
&& \
288 git checkout
-- Makefile.omd packages
/omd
/omd
290 # Only to be used for developement testing setup
293 # Only for development: install tarball below /
295 tar xzf
$(BIN_TGZ
) -C
/ # HACK: Add missing suid bits if compiled as non-root
296 chmod
4755 $(OMD_ROOT
)/lib
/nagios
/plugins
/check_
{icmp
,dhcp
}
297 chmod
4775 $(OMD_ROOT
)/bin
/mkeventd_open514
298 $(APACHE_CTL
) -k graceful
300 # On debian based systems register the alternative switches
302 @if which update-alternatives
>/dev
/null
2>&1; then \
303 update-alternatives
--install /omd
/versions
/default \
304 omd
/omd
/versions
/$(OMD_VERSION
) $(OMD_SERIAL
) \
305 --slave
/usr
/bin
/omd omd.bin
/omd
/versions
/$(OMD_VERSION
)/bin
/omd \
306 --slave
/usr
/share
/man
/man8
/omd
.8.gz omd.man8 \
307 /omd
/versions
/$(OMD_VERSION
)/share
/man
/man8
/omd
.8.gz
; \
311 @if
[ -z
"$(VERSION)" ] ; then \
312 newversion
=$$(dialog
--stdout
--inputbox
"New Version:" 0 0 "$(OMD_VERSION)") ; \
314 newversion
=$(VERSION
) ; \
316 if
[ -n
"$$newversion" ] && [ "$$newversion" != "$(OMD_VERSION)" ]; then \
317 sed
-ri
's/^(OMD_VERSION[[:space:]]*= *).*/\1'"$$newversion/" Makefile.omd
; \
318 sed
-ri
's/^(OMD_SERIAL[[:space:]]*= *).*/\1'"$(NEWSERIAL)/" Makefile.omd
; \
319 sed
-ri
's/^(OMD_VERSION[[:space:]]*= *).*/\1"'"$$newversion"'"/' packages
/omd
/omd
; \