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 \
40 # If you just want to test package building, you can reduce the
41 # number of packages to just "omd" - to speed up your tests.
44 # This file is kept by 'make config' and also may override
45 # the list of packages
48 DESTDIR ?
=$(shell pwd
)/destdir
49 RPM_TOPDIR
=$$(pwd
)/rpm.topdir
50 DPKG_TOPDIR
=$$(pwd
)/dpkg.topdir
51 SOURCE_TGZ
=omd-
$(OMD_VERSION
).
tar.gz
52 BIN_TGZ
=omd-bin-
$(OMD_VERSION
).
tar.gz
53 NEWSERIAL
=$$(($(OMD_SERIAL
) + 1))
54 APACHE_NAME
=$(APACHE_INIT_NAME
)
56 DEFAULT_BUILD
=build-cached
61 .PHONY
: install-global
66 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
67 OMD_VERSION
="$(OMD_VERSION)" BUILD_CACHE
="$(BUILD_CACHE)" ..
/build_cached
"$(MAKE)" "$$p" "$(DISTRO_NAME)/$(DISTRO_VERSION)/$(shell uname -m)"; \
72 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
73 $(MAKE
) -C
$$p build
; \
77 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
78 ( NOW
=$$(date
+%s
) ; \
79 $(MAKE
) -C
$$p build
> ..
/$$p.log
2>&1 \
80 && echo
"$$p(ok - $$(( $$(date +%s) - NOW ))s)" \
81 || echo
"$$p(ERROR - $$(( $$(date +%s) - NOW ))s)" ) & \
82 done
; wait
; echo
"FINISHED."
86 mkdir
-p
$(DESTDIR
)$(OMD_PHYSICAL_BASE
)
87 A
="$(OMD_PHYSICAL_BASE)" ; ln
-s
$${A
:1} $(DESTDIR
)/omd
88 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
89 $(MAKE
) -C
$$p DESTDIR
=$(DESTDIR
) install ; \
90 for hook in
$$(cd
$$p ; ls
*.hook
2>/dev
/null
) ; do \
91 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/lib
/omd
/hooks
; \
92 install -m
755 $$p/$$hook $(DESTDIR
)$(OMD_ROOT
)/lib
/omd
/hooks
/$${hook
%.hook
} ; \
96 # Repair packages that install with silly modes (such as Nagios)
97 chmod
-R o
+Xr
$(DESTDIR
)$(OMD_ROOT
)
98 $(MAKE
) install-global
100 # Install skeleton files (subdirs skel/ in packages' directories)
101 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/skel
102 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
103 if
[ -d
"$$p/skel" ] ; then \
104 tar cf
- -C
$$p/skel
--exclude
="*~" --exclude
=".gitignore" . |
tar xvf
- -C
$(DESTDIR
)$(OMD_ROOT
)/skel
; \
106 $(MAKE
) DESTDIR
=$(DESTDIR
) SKEL
=$(DESTDIR
)$(OMD_ROOT
)/skel
-C
$$p skel
;\
109 # Create permissions file for skel
110 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/share
/omd
111 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
112 if
[ -e
$$p/skel.permissions
] ; then \
114 cat
$$p/skel.permissions
; \
116 done
> $(DESTDIR
)$(OMD_ROOT
)/share
/omd
/skel.permissions
118 # Make sure, all permissions in skel are set to 0755, 0644
119 @failed
=$$(find
$(DESTDIR
)$(OMD_ROOT
)/skel
-type d
-not
-perm
0755) ; \
120 if
[ -n
"$$failed" ] ; then \
121 echo
"Invalid permissions for skeleton dirs. Must be 0755:" ; \
122 echo
"I'll fix this for you this time..." ; \
123 chmod
-c
755 $$failed ; \
126 @failed
=$$(find
$(DESTDIR
)$(OMD_ROOT
)/skel
-type f
-not
-perm
0644) ; \
127 if
[ -n
"$$failed" ] ; then \
128 echo
"Invalid permissions for skeleton files. Must be 0644:" ; \
130 echo
"I'll fix this for you this time..." ; \
131 chmod
-c
644 $$failed ; \
134 # Fix packages which did not add ###ROOT###
135 find
$(DESTDIR
)$(OMD_ROOT
)/skel
-type f | xargs
-n1 sed
-i
-e
's+$(OMD_ROOT)+###ROOT###+g'
137 # Remove site-specific directories that went under /omd/version
138 rm -rf
$(DESTDIR
)/{var
,tmp
}
140 # Pack the whole stuff into a tarball
141 tar czf
$(BIN_TGZ
) --owner
=root
--group
=root
-C
$(DESTDIR
) .
145 @for p in packages
/* ; do \
146 $(MAKE
) -C
$$p clean ; \
156 for x in
"$$@" ; do if
[ $$elem = $$x ] ; then return
0 ; fi
; done
; \
159 if
[ "$(PACKAGES)" = '*' ] ; \
163 enabled
=( $(PACKAGES
) ) ; \
166 avail
=$$(for p in
$$(cd packages
; ls
) ; do if
[ "$$enabled" = '*' ] || inarray
$$p $${enabled
[@
]} ; then en
=on
; else en
="-" ; fi
; echo
-n
"$$p - $$en " ; done
) ; \
167 if packages
=$$(dialog
--stdout
--checklist
"Package configuration" 1 0 0 $$avail ) ; \
169 echo
"PACKAGES = $$packages" | sed
's/"//g' > .config
; \
173 # Create installations files that do not lie beyond /omd/versions/$(OMD_VERSION)
174 # and files not owned by a specific package.
176 # Create link to default version
177 ln
-s
$(OMD_VERSION
) $(DESTDIR
)$(OMD_BASE
)/versions
/default
179 # Create global symbolic links. Those links are share between
180 # all installed versions and refer to the default version.
181 mkdir
-p
$(DESTDIR
)/usr
/bin
182 ln
-sfn
/omd
/versions
/default
/bin
/omd
$(DESTDIR
)/usr
/bin
/omd
183 mkdir
-p
$(DESTDIR
)/usr
/share
/man
/man8
184 ln
-sfn
/omd
/versions
/default
/share
/man
/man8
/omd
.8.gz
$(DESTDIR
)/usr
/share
/man
/man8
/omd
.8.gz
185 mkdir
-p
$(DESTDIR
)/etc
/init.d
186 ln
-sfn
/omd
/versions
/default
/share
/omd
/omd.init
$(DESTDIR
)/etc
/init.d
/omd
187 mkdir
-p
$(DESTDIR
)$(APACHE_CONF_DIR
)
188 ln
-sfn
/omd
/versions
/default
/share
/omd
/apache.conf
$(DESTDIR
)$(APACHE_CONF_DIR
)/zzz_omd.conf
190 # Base directories below /omd
191 mkdir
-p
$(DESTDIR
)$(OMD_BASE
)/sites
192 mkdir
-p
$(DESTDIR
)$(OMD_BASE
)/apache
195 # Information about distribution and OMD
196 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/share
/omd
197 install -m
644 distros
/Makefile.
$(DISTRO_NAME
)_
$(DISTRO_VERSION
) $(DESTDIR
)$(OMD_ROOT
)/share
/omd
/distro.
info
198 echo
-e
"OMD_VERSION = $(OMD_VERSION)\nOMD_PHYSICAL_BASE = $(OMD_PHYSICAL_BASE)" > $(DESTDIR
)$(OMD_ROOT
)/share
/omd
/omd.
info
200 # README files and license information
201 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/share
/doc
202 install -m
644 README COPYING TEAM
$(DESTDIR
)$(OMD_ROOT
)/share
/doc
203 install -m
644 Changelog
$(DESTDIR
)$(OMD_ROOT
)/share
/doc
/CHANGELOG
205 # Create source tarball. This currently only works in a checked out GIT
208 rm -rf omd-
$(OMD_VERSION
)
209 mkdir
-p omd-
$(OMD_VERSION
)
210 git archive HEAD |
tar xf
- -C omd-
$(OMD_VERSION
)
211 tar czf
$(SOURCE_TGZ
) omd-
$(OMD_VERSION
)
212 rm -rf omd-
$(OMD_VERSION
)
214 # Creates source tarball. This does only work well in directories extracted
215 # from a CLEAN git archive tarball.
216 $(SOURCE_TGZ
)-snap snap
:
217 rm -rf omd-
$(OMD_VERSION
)
218 mkdir
-p omd-
$(OMD_VERSION
)
219 tar cf
- --exclude
="rpm.topdir" --exclude
="*~" --exclude
=".gitignore" --exclude
"omd-$(OMD_VERSION)" . |
tar xf
- -C omd-
$(OMD_VERSION
)
220 tar czf
$(SOURCE_TGZ
) omd-
$(OMD_VERSION
)
221 rm -rf omd-
$(OMD_VERSION
)
223 # Build RPM from source code.
224 # When called from a git repository this uses 'make dist' and thus 'git archive'
225 # to create the source rpm.
226 # The second choice is to call this form a CLEAN git archive directory which
227 # then uses 'make snap' to use that snapshot.
229 sed
-e
's/^Requires:.*/Requires: $(OS_PACKAGES)/' \
230 -e
's/%{version}/$(OMD_VERSION)/g' \
231 -e
's/^Version:.*/Version: $(DISTRO_CODE)/' \
232 -e
's/^Release:.*/Release: $(OMD_SERIAL)/' \
233 -e
's#@APACHE_CONFDIR@#$(APACHE_CONF_DIR)#g' \
234 -e
's#@APACHE_NAME@#$(APACHE_NAME)#g' \
235 omd.spec.in
> omd.spec
237 test -d .git
&& $(MAKE
) $(SOURCE_TGZ
) ||
$(MAKE
) $(SOURCE_TGZ
)-snap
238 mkdir
-p
$(RPM_TOPDIR
)/{SOURCES
,BUILD
,RPMS
,SRPMS
,SPECS
}
239 cp
$(SOURCE_TGZ
) $(RPM_TOPDIR
)/SOURCES
240 # NO_BRP_STALE_LINK_ERROR ignores errors when symlinking from skel to
241 # share,lib,bin because the link has a invalid target until the site is created
242 # NO_BRP_CHECK_RPATH ignores errors with the compiled python2.7 binary which
243 # has a rpath hard coded to the OMD shipped libpython2.7.
244 NO_BRP_CHECK_RPATH
="yes" \
245 NO_BRP_STALE_LINK_ERROR
="yes" \
246 rpmbuild
-ba
--define "_topdir $(RPM_TOPDIR)" \
247 --buildroot
=$$(pwd
)/rpm.buildroot omd.spec
248 mv
-v
$(RPM_TOPDIR
)/RPMS
/*/*.rpm .
249 mv
-v
$(RPM_TOPDIR
)/SRPMS
/*.src.rpm .
250 rm -rf
$(RPM_TOPDIR
) rpm.buildroot
252 # Build DEB from prebuild binary. This currently needs 'make dist' and thus only
253 # works within a GIT repository.
255 @if
test -z
"$(DEBFULLNAME)" ||
test -z
"$(DEBEMAIL)"; then \
256 echo
"please read 'man dch' and set DEBFULLNAME and DEBEMAIL" ;\
260 # create a debian/changelog to build the package
261 deb-changelog
: deb-environment
263 rm -f debian
/changelog
264 dch
--create
--package omd-
$(OMD_VERSION
) \
265 --newversion
0.
$(DISTRO_CODE
) "`cat debian/changelog.tmpl`"
266 dch
--release
"releasing ...."
269 sed
-e
's/###OMD_VERSION###/$(OMD_VERSION)/' \
270 -e
's/###BUILD_PACKAGES###/$(BUILD_PACKAGES)/' \
271 -e
's/###OS_PACKAGES###/$(OS_PACKAGES)/' \
272 -e
'/Depends:/s/\> /, /g' \
273 -e
'/Depends:/s/@/ /g' \
274 `pwd`/debian
/control.in
> `pwd`/debian
/control
275 fakeroot debian
/rules
clean
276 debuild
--no-lintian
-i\.git
-I\.git \
277 -iomd-bin-
$(OMD_VERSION
).
tar.gz \
278 -Iomd-bin-
$(OMD_VERSION
).
tar.gz \
279 -i.gitignore
-I.gitignore \
281 # -- renaming deb package to DISTRO_CODE dependend name
282 # arch=`dpkg-architecture -qDEB_HOST_ARCH` ; \
283 # build=`sed -e '1s/.*(\(.*\)).*/\1/;q' debian/changelog` ; \
284 # distro=`echo $$build | sed -e 's/build/$(DISTRO_CODE)/' ` ; \
285 # echo "$$arch $$build $$distro"; \
286 # mv "../omd-$(OMD_VERSION)_$${build}_$${arch}.deb" \
287 # "../omd-$(OMD_VERSION)_$${distro}_$${arch}.deb" ;
289 deb-snap
: deb-environment
290 make
clean && git checkout
-- Makefile.omd packages
/omd
/omd
&& \
291 make VERSION
=`./get_version` version
&& make deb
&& \
292 git checkout
-- Makefile.omd packages
/omd
/omd
294 # Only to be used for developement testing setup
297 # Only for development: install tarball below /
299 tar xzf
$(BIN_TGZ
) -C
/ # HACK: Add missing suid bits if compiled as non-root
300 chmod
4755 $(OMD_ROOT
)/lib
/nagios
/plugins
/check_
{icmp
,dhcp
}
301 chmod
4775 $(OMD_ROOT
)/bin
/mkeventd_open514
302 $(APACHE_CTL
) -k graceful
304 # On debian based systems register the alternative switches
306 @if which update-alternatives
>/dev
/null
2>&1; then \
307 update-alternatives
--install /omd
/versions
/default \
308 omd
/omd
/versions
/$(OMD_VERSION
) $(OMD_SERIAL
) \
309 --slave
/usr
/bin
/omd omd.bin
/omd
/versions
/$(OMD_VERSION
)/bin
/omd \
310 --slave
/usr
/share
/man
/man8
/omd
.8.gz omd.man8 \
311 /omd
/versions
/$(OMD_VERSION
)/share
/man
/man8
/omd
.8.gz
; \
315 @if
[ -z
"$(VERSION)" ] ; then \
316 newversion
=$$(dialog
--stdout
--inputbox
"New Version:" 0 0 "$(OMD_VERSION)") ; \
318 newversion
=$(VERSION
) ; \
320 if
[ -n
"$$newversion" ] && [ "$$newversion" != "$(OMD_VERSION)" ]; then \
321 sed
-ri
's/^(OMD_VERSION[[:space:]]*= *).*/\1'"$$newversion/" Makefile.omd
; \
322 sed
-ri
's/^(OMD_SERIAL[[:space:]]*= *).*/\1'"$(NEWSERIAL)/" Makefile.omd
; \
323 sed
-ri
's/^(OMD_VERSION[[:space:]]*= *).*/\1"'"$$newversion"'"/' packages
/omd
/omd
; \