Skip to content

Commit

Permalink
update packaging scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Jun 5, 2018
1 parent e238805 commit b9661c2
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 52 deletions.
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: thruk
Section: net
Priority: extra
Maintainer: Sven Nierlein <[email protected]>
Build-Depends: debhelper (>= 7), libthruk (>=2.20)
Build-Depends: debhelper (>= 7), libthruk (>=2.20), lsb-release
Standards-Version: 3.7.3
Homepage: http://www.thruk.org
Bugs: https://github.com/sni/Thruk/issues
Expand Down Expand Up @@ -40,7 +40,7 @@ Description: Monitoring Webinterface for Nagios/Icinga and Shinken

Package: thruk-plugin-reporting
Architecture: any
Depends: ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends},
Depends: ${misc:Depends}, ${perl:Depends}, ${shlibs:Depends}, phantomjs,
thruk-base (= ${source:Version})
Description: This package contains the reporting addon for thruk useful for sla
and event reporting.
15 changes: 11 additions & 4 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ HTTPDCONF=$(shell if [ -d "/etc/apache2/conf-available" ]; then echo "/etc/apach
SHELL=bash
DIST := $(shell lsb_release -i | awk '{print tolower($$3)}')
RELEASE := $(shell lsb_release -r | awk '{print $$2}')
export PERL5LIB = /usr/lib/thruk/perl5:/usr/lib64/thruk/perl5
FIXPHANTOMJS=$(shell if [ -f script/phantomjs ]; then echo "fix_phantomjs_location"; else echo ""; fi )

override_dh_auto_configure:
dh_auto_configure -- --prefix=/usr \
Expand All @@ -30,7 +32,9 @@ override_dh_auto_configure:
echo $(HTTPDCONF)/thruk.conf >> debian/thruk-base.install
echo $(HTTPDCONF)/thruk_cookie_auth_vhost.conf >> debian/thruk-base.install

override_dh_auto_install:
override_dh_auto_install: local_auto_install $(FIXPHANTOMJS)

local_auto_install:
dh_auto_install
# enable su logrotate directive if required
if [[ ${DIST} == debian ]] ; then \
Expand All @@ -42,19 +46,22 @@ override_dh_auto_install:
sed -i -e 's/^.*#su/ su/' debian/tmp/etc/logrotate.d/thruk-base; \
fi ; \
fi
echo "debian/thruk-plugin-reporting.lintian-overrides" >> MANIFEST

fix_phantomjs_location:
# fix location of phantomjs
mkdir -p debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/thruk
mv debian/tmp/usr/share/thruk/script/phantomjs debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/thruk/
sed -e 's|/usr/share/thruk/script/phantomjs|/usr/lib/'$(DEB_HOST_MULTIARCH)'/thruk/phantomjs|' \
-i debian/tmp/etc/thruk/thruk.conf \
-i debian/thruk-plugin-reporting.install
-i debian/tmp/etc/thruk/thruk.conf
echo "/usr/lib/$(DEB_HOST_MULTIARCH)/thruk/phantomjs" >> debian/thruk-plugin-reporting.install
echo "thruk-plugin-reporting: embedded-library usr/lib/$(DEB_HOST_MULTIARCH)/thruk/phantomjs: sqlite" > debian/thruk-plugin-reporting.lintian-overrides
echo "thruk-plugin-reporting: embedded-library usr/lib/$(DEB_HOST_MULTIARCH)/thruk/phantomjs: libpng" >> debian/thruk-plugin-reporting.lintian-overrides
echo "thruk-plugin-reporting: embedded-library usr/lib/$(DEB_HOST_MULTIARCH)/thruk/phantomjs: zlib" >> debian/thruk-plugin-reporting.lintian-overrides
echo "thruk-plugin-reporting: embedded-library usr/lib/$(DEB_HOST_MULTIARCH)/thruk/phantomjs: libjpeg" >> debian/thruk-plugin-reporting.lintian-overrides
echo "thruk-plugin-reporting: embedded-library usr/lib/$(DEB_HOST_MULTIARCH)/thruk/phantomjs: openssl" >> debian/thruk-plugin-reporting.lintian-overrides
echo "thruk-plugin-reporting: hardening-no-relro usr/lib/$(DEB_HOST_MULTIARCH)/thruk/phantomjs" >> debian/thruk-plugin-reporting.lintian-overrides
echo "debian/thruk-plugin-reporting.lintian-overrides" >> MANIFEST
sed -e 's|phantomjs,||' -i debian/control

override_dh_gencontrol:
dh_gencontrol -- -Vextra:Depends=perlapi-$(PERLVER)
Expand Down
1 change: 0 additions & 1 deletion debian/thruk-plugin-reporting.install
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/usr/share/thruk/plugins/plugins-available/reports2
/etc/thruk/plugins/plugins-available/reports2
/usr/share/thruk/script/phantomjs
14 changes: 14 additions & 0 deletions debian/thruk.dsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Format: 1.0
Source: thruk
Binary: thruk
Architecture: any
Version:
Maintainer: Thruk Development Team <[email protected]>
Homepage: http://www.thruk.org
Bugs: https://github.com/sni/Thruk/issues
Vcs-Browser: https://github.com/sni/Thruk
Vcs-Git: git://github.com/sni/Thruk.git
Build-Depends: debhelper (>= 7), libthruk (>=2.20), lsb-release
Files:
00000000000000000000000000000000 0000 thruk_1.0.0.orig.tar.gz
00000000000000000000000000000000 0000 thruk_1.0.0-1.diff.tar.gz
163 changes: 118 additions & 45 deletions support/thruk.spec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Requires: thruk-plugin-reporting = %{version}-%{release}
%if 0%{?suse_version} < 1315
Requires(pre): shadow-utils
%endif
%if 0%{?systemd_requires}
%systemd_requires
%endif

%description
Thruk is a multibackend monitoring webinterface which currently
Expand All @@ -57,8 +60,13 @@ AutoReqProv: no

#sles and opensuse
%if %{defined suse_version}
%if 0%{?suse_version} >= 1315
Requires: apache2 apache2-mod_fcgid cronie
%endif
%if 0%{?suse_version} < 1315
Requires: apache2 apache2-mod_fcgid cron
%endif
%endif

# >=rhel7 and fedora
%if 0%{?el7}%{?fedora}
Expand Down Expand Up @@ -90,6 +98,7 @@ and event reporting.
%setup -q -n %{fullname}

%build
export PERL5LIB=/usr/lib/thruk/perl5:/usr/lib64/thruk/perl5
%configure \
--bindir="%{_bindir}" \
--datadir="%{_datadir}/thruk" \
Expand Down Expand Up @@ -131,6 +140,15 @@ mkdir -p %{buildroot}%{_localstatedir}/lib/thruk
%if 0%{?fedora} >= 16 || 0%{?rhel} >= 7 || 0%{?sles_version} >= 12
sed -i -e 's/^.*#su/ su/' %{buildroot}/%{_sysconfdir}/logrotate.d/thruk-base
%endif
touch plugin-reporting.files
if test -e %{buildroot}%{_datadir}/thruk/script/phantomjs; then
echo "%{_datadir}/thruk/script/phantomjs" >> plugin-reporting.files
fi

%if %{?_unitdir:1}0
rm %{buildroot}%{_initrddir}/thruk
%endif


%clean
%{__rm} -rf %{buildroot}
Expand All @@ -154,47 +172,72 @@ fi
exit 0

%post base
chkconfig --add thruk
mkdir -p /var/cache/thruk/reports \
/var/log/thruk \
/etc/thruk/bp \
/etc/thruk/panorama \
/var/lib/thruk \
/etc/thruk/thruk_local.d
touch /var/log/thruk/thruk.log
chown -R %{apacheuser}:%{apachegroup} \
/var/lib/thruk \
/var/cache/thruk \
/var/log/thruk \
/etc/thruk/plugins/plugins-enabled \
/etc/thruk/thruk_local.conf \
/etc/thruk/bp \
/etc/thruk/panorama \
/etc/thruk/thruk_local.d
/usr/bin/crontab -l -u %{apacheuser} 2>/dev/null | /usr/bin/crontab -u %{apacheuser} -
%if %{defined suse_version}
a2enmod alias
a2enmod fcgid
a2enmod auth_basic
a2enmod rewrite
%if 0%{?suse_version} < 1315
/etc/init.d/apache2 restart || /etc/init.d/apache2 start
%else
systemctl restart apache2.service
%endif
%else
service httpd condrestart
case "$*" in
2)
# Upgrading, restart apache webserver
%if %{defined suse_version}
%if %{?_unitdir:1}0
systemctl daemon-reload &>/dev/null || true
systemctl condrestart apache2.service &>/dev/null || true
%else
/etc/init.d/apache2 restart &>/dev/null || true
%endif
%else
%if %{?_unitdir:1}0
systemctl daemon-reload &>/dev/null || true
systemctl condrestart httpd.service &>/dev/null || true
%else
/etc/init.d/httpd condrestart &>/dev/null || true
%endif
%endif

rm -f /var/cache/thruk/thruk.cache
/usr/bin/thruk -a clearcache,installcron --local > /dev/null
;;
1)
# Installing
mkdir -p /var/cache/thruk/reports \
/var/log/thruk \
/etc/thruk/bp \
/etc/thruk/panorama \
/var/lib/thruk \
/etc/thruk/thruk_local.d
touch /var/log/thruk/thruk.log
chown -R %{apacheuser}:%{apachegroup} \
/var/lib/thruk \
/var/cache/thruk \
/var/log/thruk \
/etc/thruk/plugins/plugins-enabled \
/etc/thruk/thruk_local.conf \
/etc/thruk/bp \
/etc/thruk/panorama \
/etc/thruk/thruk_local.d
/usr/bin/crontab -l -u %{apacheuser} 2>/dev/null | /usr/bin/crontab -u %{apacheuser} -
%if %{defined suse_version}
/usr/sbin/a2enmod alias
/usr/sbin/a2enmod fcgid
/usr/sbin/a2enmod auth_basic
/usr/sbin/a2enmod rewrite
%endif
%if %{?_unitdir:1}0
#%systemd_post thruk.service
%else
chkconfig --add thruk
%endif

echo "Thruk have been configured for http://$(hostname)/thruk/."
echo "The default user is 'thrukadmin' with password 'thrukadmin'. You can usually change that by 'htpasswd /etc/thruk/htpasswd thrukadmin'"
;;
*) echo case "$*" not handled in post
esac

if [ "$(getenforce 2>/dev/null)" = "Enforcing" ]; then
echo "******************************************";
echo "Thruk will not work when SELinux is enabled";
echo "SELinux: "$(getenforce);
echo "******************************************";
fi
%endif
rm -f /var/cache/thruk/thruk.cache
/usr/bin/thruk -a clearcache,installcron --local > /dev/null
echo "Thruk have been configured for http://$(hostname)/thruk/."
echo "The default user is 'thrukadmin' with password 'thrukadmin'. You can usually change that by 'htpasswd /etc/thruk/htpasswd thrukadmin'"

exit 0


Expand All @@ -217,19 +260,28 @@ if [ -d /tmp/thruk_update/ssi/. ]; then
cp -rp /tmp/thruk_update/ssi/* /etc/thruk/ssi/
fi
rm -rf /tmp/thruk_update
exit 0

%preun base
set -x
if [ $1 = 0 ]; then
case "$*" in
1)
# Upgrade, don't do anything
;;
0)
# Uninstall, go ahead and stop before removing
# last version will be deinstalled
/usr/bin/thruk -a uninstallcron --local
fi
/etc/init.d/thruk stop
chkconfig --del thruk 2>/dev/null
%if %{?_unitdir:1}0
%else
/etc/init.d/thruk stop
chkconfig --del thruk 2>/dev/null
%endif
;;
*) echo case "$*" not handled in preun
esac
exit 0

%postun base
set -x
case "$*" in
0)
# POSTUN
Expand Down Expand Up @@ -270,13 +322,19 @@ exit 0
%post plugin-reporting
rm -f /etc/thruk/plugins/plugins-enabled/reports2
ln -s ../plugins-available/reports2 /etc/thruk/plugins/plugins-enabled/reports2
/etc/init.d/thruk condrestart &>/dev/null || :
%if %{?_unitdir:1}0
%else
/etc/init.d/thruk condrestart &>/dev/null || :
%endif
exit 0

%preun plugin-reporting
if [ -e /etc/thruk/plugins/plugins-enabled/reports2 ]; then
rm -f /etc/thruk/plugins/plugins-enabled/reports2
/etc/init.d/thruk condrestart &>/dev/null || :
%if %{?_unitdir:1}0
%else
/etc/init.d/thruk condrestart &>/dev/null || :
%endif
fi
exit 0

Expand Down Expand Up @@ -309,7 +367,10 @@ exit 0
%attr(0755,root,root) %{_bindir}/thruk
%attr(0755,root,root) %{_bindir}/naglint
%attr(0755,root,root) %{_bindir}/nagexp
%if %{?_unitdir:1}0
%else
%attr(0755,root,root) %{_initrddir}/thruk
%endif
%config %{_sysconfdir}/thruk/ssi
%config %{_sysconfdir}/thruk/action_menus
%config %{_sysconfdir}/thruk/thruk.conf
Expand Down Expand Up @@ -379,12 +440,24 @@ exit 0
%doc %{_mandir}/man3/thruk.3
%doc %{_mandir}/man8/thruk.8
%docdir %{_defaultdocdir}
%if 0%{?suse_version} >= 1315
%attr(0755,root,root) %dir %{_sysconfdir}/apache2
%attr(0755,root,root) %dir %{_sysconfdir}/apache2/conf.d
%attr(0755,root,root) %dir %{_sysconfdir}/thruk
%attr(0755,root,root) %dir %{_sysconfdir}/thruk/bp
%attr(0755,root,root) %dir %{_sysconfdir}/thruk/plugins
%attr(0755,root,root) %dir %{_sysconfdir}/thruk/plugins/plugins-available
%attr(0755,root,root) %dir %{_sysconfdir}/thruk/plugins/plugins-enabled
%attr(0755,root,root) %dir %{_datadir}/thruk
%attr(0755,root,root) %dir %{_datadir}/thruk/plugins
%attr(0755,root,root) %dir %{_datadir}/thruk/script
%attr(0755,root,root) %dir %{_datadir}/thruk/plugins/plugins-available
%endif


%files plugin-reporting
%files plugin-reporting -f plugin-reporting.files
%{_sysconfdir}/thruk/plugins/plugins-available/reports2
%{_datadir}/thruk/plugins/plugins-available/reports2
%{_datadir}/thruk/script/phantomjs



Expand Down

0 comments on commit b9661c2

Please sign in to comment.