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 .PHONY
: install-global
60 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
61 $(MAKE
) -C
$$p build
; \
65 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
66 ( NOW
=$$(date
+%s
) ; \
67 $(MAKE
) -C
$$p build
> ..
/$$p.log
2>&1 \
68 && echo
"$$p(ok - $$(( $$(date +%s) - NOW ))s)" \
69 || echo
"$$p(ERROR - $$(( $$(date +%s) - NOW ))s)" ) & \
70 done
; wait
; echo
"FINISHED."
74 mkdir
-p
$(DESTDIR
)$(OMD_PHYSICAL_BASE
)
75 A
="$(OMD_PHYSICAL_BASE)" ; ln
-s
$${A
:1} $(DESTDIR
)/omd
76 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
77 $(MAKE
) -C
$$p DESTDIR
=$(DESTDIR
) install ; \
78 for hook in
$$(cd
$$p ; ls
*.hook
2>/dev
/null
) ; do \
79 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/lib
/omd
/hooks
; \
80 install -m
755 $$p/$$hook $(DESTDIR
)$(OMD_ROOT
)/lib
/omd
/hooks
/$${hook
%.hook
} ; \
84 # Repair packages that install with silly modes (such as Nagios)
85 chmod
-R o
+Xr
$(DESTDIR
)$(OMD_ROOT
)
86 $(MAKE
) install-global
88 # Install skeleton files (subdirs skel/ in packages' directories)
89 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/skel
90 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
91 if
[ -d
"$$p/skel" ] ; then \
92 tar cf
- -C
$$p/skel
--exclude
="*~" --exclude
=".gitignore" . |
tar xvf
- -C
$(DESTDIR
)$(OMD_ROOT
)/skel
; \
94 $(MAKE
) SKEL
=$(DESTDIR
)$(OMD_ROOT
)/skel
-C
$$p skel
;\
97 # Create permissions file for skel
98 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/share
/omd
99 @set
-e
; cd packages
; for p in
$(PACKAGES
) ; do \
100 if
[ -e
$$p/skel.permissions
] ; then \
102 cat
$$p/skel.permissions
; \
104 done
> $(DESTDIR
)$(OMD_ROOT
)/share
/omd
/skel.permissions
106 # Make sure, all permissions in skel are set to 0755, 0644
107 @failed
=$$(find
$(DESTDIR
)$(OMD_ROOT
)/skel
-type d
-not
-perm
0755) ; \
108 if
[ -n
"$$failed" ] ; then \
109 echo
"Invalid permissions for skeleton dirs. Must be 0755:" ; \
110 echo
"I'll fix this for you this time..." ; \
111 chmod
-c
755 $$failed ; \
114 @failed
=$$(find
$(DESTDIR
)$(OMD_ROOT
)/skel
-type f
-not
-perm
0644) ; \
115 if
[ -n
"$$failed" ] ; then \
116 echo
"Invalid permissions for skeleton files. Must be 0644:" ; \
118 echo
"I'll fix this for you this time..." ; \
119 chmod
-c
644 $$failed ; \
122 # Fix packages which did not add ###ROOT###
123 find
$(DESTDIR
)$(OMD_ROOT
)/skel
-type f | xargs
-n1 sed
-i
-e
's+$(OMD_ROOT)+###ROOT###+g'
125 # Remove site-specific directories that went under /omd/version
126 rm -rf
$(DESTDIR
)/{var
,tmp
}
128 # Pack the whole stuff into a tarball
129 tar czf
$(BIN_TGZ
) --owner
=root
--group
=root
-C
$(DESTDIR
) .
133 @for p in packages
/* ; do \
134 $(MAKE
) -C
$$p clean ; \
144 for x in
"$$@" ; do if
[ $$elem = $$x ] ; then return
0 ; fi
; done
; \
147 if
[ "$(PACKAGES)" = '*' ] ; \
151 enabled
=( $(PACKAGES
) ) ; \
154 avail
=$$(for p in
$$(cd packages
; ls
) ; do if
[ "$$enabled" = '*' ] || inarray
$$p $${enabled
[@
]} ; then en
=on
; else en
="-" ; fi
; echo
-n
"$$p - $$en " ; done
) ; \
155 if packages
=$$(dialog
--stdout
--checklist
"Package configuration" 1 0 0 $$avail ) ; \
157 echo
"PACKAGES = $$packages" | sed
's/"//g' > .config
; \
161 # Create installations files that do not lie beyond /omd/versions/$(OMD_VERSION)
162 # and files not owned by a specific package.
164 # Create link to default version
165 ln
-s
$(OMD_VERSION
) $(DESTDIR
)$(OMD_BASE
)/versions
/default
167 # Create global symbolic links. Those links are share between
168 # all installed versions and refer to the default version.
169 mkdir
-p
$(DESTDIR
)/usr
/bin
170 ln
-sfn
/omd
/versions
/default
/bin
/omd
$(DESTDIR
)/usr
/bin
/omd
171 mkdir
-p
$(DESTDIR
)/usr
/share
/man
/man8
172 ln
-sfn
/omd
/versions
/default
/share
/man
/man8
/omd
.8.gz
$(DESTDIR
)/usr
/share
/man
/man8
/omd
.8.gz
173 mkdir
-p
$(DESTDIR
)/etc
/init.d
174 ln
-sfn
/omd
/versions
/default
/share
/omd
/omd.init
$(DESTDIR
)/etc
/init.d
/omd
175 mkdir
-p
$(DESTDIR
)$(APACHE_CONF_DIR
)
176 ln
-sfn
/omd
/versions
/default
/share
/omd
/apache.conf
$(DESTDIR
)$(APACHE_CONF_DIR
)/zzz_omd.conf
178 # Base directories below /omd
179 mkdir
-p
$(DESTDIR
)$(OMD_BASE
)/sites
180 mkdir
-p
$(DESTDIR
)$(OMD_BASE
)/apache
183 # Information about distribution and OMD
184 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/share
/omd
185 install -m
644 distros
/Makefile.
$(DISTRO_NAME
)_
$(DISTRO_VERSION
) $(DESTDIR
)$(OMD_ROOT
)/share
/omd
/distro.
info
186 echo
-e
"OMD_VERSION = $(OMD_VERSION)\nOMD_PHYSICAL_BASE = $(OMD_PHYSICAL_BASE)" > $(DESTDIR
)$(OMD_ROOT
)/share
/omd
/omd.
info
188 # README files and license information
189 mkdir
-p
$(DESTDIR
)$(OMD_ROOT
)/share
/doc
190 install -m
644 README COPYING TEAM
$(DESTDIR
)$(OMD_ROOT
)/share
/doc
191 install -m
644 Changelog
$(DESTDIR
)$(OMD_ROOT
)/share
/doc
/CHANGELOG
193 # Create source tarball. This currently only works in a checked out GIT
196 rm -rf omd-
$(OMD_VERSION
)
197 mkdir
-p omd-
$(OMD_VERSION
)
198 git archive HEAD |
tar xf
- -C omd-
$(OMD_VERSION
)
199 tar czf
$(SOURCE_TGZ
) omd-
$(OMD_VERSION
)
200 rm -rf omd-
$(OMD_VERSION
)
202 # Creates source tarball. This does only work well in directories extracted
203 # from a CLEAN git archive tarball.
204 $(SOURCE_TGZ
)-snap snap
:
205 rm -rf omd-
$(OMD_VERSION
)
206 mkdir
-p omd-
$(OMD_VERSION
)
207 tar cf
- --exclude
="rpm.topdir" --exclude
="*~" --exclude
=".gitignore" --exclude
"omd-$(OMD_VERSION)" . |
tar xf
- -C omd-
$(OMD_VERSION
)
208 tar czf
$(SOURCE_TGZ
) omd-
$(OMD_VERSION
)
209 rm -rf omd-
$(OMD_VERSION
)
211 # Build RPM from source code.
212 # When called from a git repository this uses 'make dist' and thus 'git archive'
213 # to create the source rpm.
214 # The second choice is to call this form a CLEAN git archive directory which
215 # then uses 'make snap' to use that snapshot.
217 sed
-e
's/^Requires:.*/Requires: $(OS_PACKAGES)/' \
218 -e
's/%{version}/$(OMD_VERSION)/g' \
219 -e
's/^Version:.*/Version: $(DISTRO_CODE)/' \
220 -e
's/^Release:.*/Release: $(OMD_SERIAL)/' \
221 -e
's#@APACHE_CONFDIR@#$(APACHE_CONF_DIR)#g' \
222 -e
's#@APACHE_NAME@#$(APACHE_NAME)#g' \
223 omd.spec.in
> omd.spec
225 test -d .git
&& $(MAKE
) $(SOURCE_TGZ
) ||
$(MAKE
) $(SOURCE_TGZ
)-snap
226 mkdir
-p
$(RPM_TOPDIR
)/{SOURCES
,BUILD
,RPMS
,SRPMS
,SPECS
}
227 cp
$(SOURCE_TGZ
) $(RPM_TOPDIR
)/SOURCES
228 # NO_BRP_STALE_LINK_ERROR ignores errors when symlinking from skel to
229 # share,lib,bin because the link has a invalid target until the site is created
230 NO_BRP_STALE_LINK_ERROR
="yes" \
231 rpmbuild
-ba
--define "_topdir $(RPM_TOPDIR)" \
232 --buildroot
=$$(pwd
)/rpm.buildroot omd.spec
233 mv
-v
$(RPM_TOPDIR
)/RPMS
/*/*.rpm .
234 mv
-v
$(RPM_TOPDIR
)/SRPMS
/*.src.rpm .
235 rm -rf
$(RPM_TOPDIR
) rpm.buildroot
237 # Build DEB from prebuild binary. This currently needs 'make dist' and thus only
238 # works within a GIT repository.
240 @if
test -z
"$(DEBFULLNAME)" ||
test -z
"$(DEBEMAIL)"; then \
241 echo
"please read 'man dch' and set DEBFULLNAME and DEBEMAIL" ;\
245 # create a debian/changelog to build the package
246 deb-changelog
: deb-environment
248 rm -f debian
/changelog
249 dch
--create
--package omd-
$(OMD_VERSION
) \
250 --newversion
0.
$(DISTRO_CODE
) "`cat debian/changelog.tmpl`"
251 dch
--release
"releasing ...."
254 sed
-e
's/###OMD_VERSION###/$(OMD_VERSION)/' \
255 -e
's/###BUILD_PACKAGES###/$(BUILD_PACKAGES)/' \
256 -e
's/###OS_PACKAGES###/$(OS_PACKAGES)/' \
257 -e
'/Depends:/s/\> /, /g' \
258 -e
'/Depends:/s/@/ /g' \
259 `pwd`/debian
/control.in
> `pwd`/debian
/control
260 fakeroot debian
/rules
clean
261 debuild
--no-lintian
-i\.git
-I\.git \
262 -iomd-bin-
$(OMD_VERSION
).
tar.gz \
263 -Iomd-bin-
$(OMD_VERSION
).
tar.gz \
264 -i.gitignore
-I.gitignore \
266 # -- renaming deb package to DISTRO_CODE dependend name
267 # arch=`dpkg-architecture -qDEB_HOST_ARCH` ; \
268 # build=`sed -e '1s/.*(\(.*\)).*/\1/;q' debian/changelog` ; \
269 # distro=`echo $$build | sed -e 's/build/$(DISTRO_CODE)/' ` ; \
270 # echo "$$arch $$build $$distro"; \
271 # mv "../omd-$(OMD_VERSION)_$${build}_$${arch}.deb" \
272 # "../omd-$(OMD_VERSION)_$${distro}_$${arch}.deb" ;
274 deb-snap
: deb-environment
275 make
clean && git checkout
-- Makefile.omd packages
/omd
/omd
&& \
276 make VERSION
=`./get_version` version
&& make deb
&& \
277 git checkout
-- Makefile.omd packages
/omd
/omd
279 # Only to be used for developement testing setup
282 # Only for development: install tarball below /
284 tar xzf
$(BIN_TGZ
) -C
/ # HACK: Add missing suid bits if compiled as non-root
285 chmod
4755 $(OMD_ROOT
)/lib
/nagios
/plugins
/check_
{icmp
,dhcp
}
286 $(APACHE_CTL
) -k graceful
288 # On debian based systems register the alternative switches
290 @if which update-alternatives
>/dev
/null
2>&1; then \
291 update-alternatives
--install /omd
/versions
/default \
292 omd
/omd
/versions
/$(OMD_VERSION
) $(OMD_SERIAL
) \
293 --slave
/usr
/bin
/omd omd.bin
/omd
/versions
/$(OMD_VERSION
)/bin
/omd \
294 --slave
/usr
/share
/man
/man8
/omd
.8.gz omd.man8 \
295 /omd
/versions
/$(OMD_VERSION
)/share
/man
/man8
/omd
.8.gz
; \
299 @if
[ -z
"$(VERSION)" ] ; then \
300 newversion
=$$(dialog
--stdout
--inputbox
"New Version:" 0 0 "$(OMD_VERSION)") ; \
302 newversion
=$(VERSION
) ; \
304 if
[ -n
"$$newversion" ] && [ "$$newversion" != "$(OMD_VERSION)" ]; then \
305 sed
-ri
's/^(OMD_VERSION[[:space:]]*= *).*/\1'"$$newversion/" Makefile.omd
; \
306 sed
-ri
's/^(OMD_SERIAL[[:space:]]*= *).*/\1'"$(NEWSERIAL)/" Makefile.omd
; \
307 sed
-ri
's/^(OMD_VERSION[[:space:]]*= *).*/\1"'"$$newversion"'"/' packages
/omd
/omd
; \