From 92e4ee464e1f253be77f32721fc78b85df0e309a Mon Sep 17 00:00:00 2001 From: Otheus Date: Wed, 17 Mar 2021 00:41:49 +0100 Subject: [PATCH 1/4] rpmbuild spec file generalized for other environments; query.conf is now treated as an additional source --- rpmbuild/libzbxpgsql.spec | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/rpmbuild/libzbxpgsql.spec b/rpmbuild/libzbxpgsql.spec index 7be554b..52819f9 100644 --- a/rpmbuild/libzbxpgsql.spec +++ b/rpmbuild/libzbxpgsql.spec @@ -32,12 +32,30 @@ libzbxpgsql is a comprehensive PostgreSQL discovery and monitoring module for th # Extract and configure sources into $RPM_BUILD_ROOT %setup0 -q -n %{name}-%{version} +err=0 + +if ! type -p pg_config && [[ -z "$PG_CONFIG" ]] ; then + echo >&2 "pg_config must be in your path or set in $PG_CONFIG" + err=1 +fi + +if ! test -d /usr/src/zabbix/include ; then + if [[ -z "$ZABBIX_SOURCE" ]] || ! test -d "$ZABBIX_SOURCE" ;then + echo >&2 "set ZABBIX_SOURCE to the location where we can find zabbix .h files (eg /usr/src/zabbix)" + err=1 + fi +fi + +[[ $err = 0 ]] || exit $err + +test -f configure || ./autogen.sh + # fix up some lib64 issues sed -i.orig -e 's|_LIBDIR=/usr/lib|_LIBDIR=%{_libdir}|g' configure %build # Configure and compile sources into $RPM_BUILD_ROOT -%configure --enable-dependency-tracking +%configure --enable-dependency-tracking --with-zabbix="$ZABBIX_SOURCE" make %{?_smp_mflags} %install From 71940c8b1e2716696635b7b60c334cdc213902f6 Mon Sep 17 00:00:00 2001 From: Otheus Date: Wed, 17 Mar 2021 01:03:27 +0100 Subject: [PATCH 2/4] query.conf promoted to source per spec guidelines. correct error in libzbxpgsql.conf file (pg_query. -> pg.query) --- rpmbuild/libzbxpgsql.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rpmbuild/libzbxpgsql.spec b/rpmbuild/libzbxpgsql.spec index 52819f9..3cfccf4 100644 --- a/rpmbuild/libzbxpgsql.spec +++ b/rpmbuild/libzbxpgsql.spec @@ -10,6 +10,7 @@ URL : https://github.com/cavaliercoder/libzbxpgsql # Zabbix sources (Customized) Source0 : %{name}-%{version}.tar.gz +Source1 : query.conf Buildroot : %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -53,6 +54,9 @@ test -f configure || ./autogen.sh # fix up some lib64 issues sed -i.orig -e 's|_LIBDIR=/usr/lib|_LIBDIR=%{_libdir}|g' configure +# fix up errant documentation in config file (easier than patching) +sed -i.orig -e 's|pg_query\.|pg.query.|' conf/libzbxpgsql.conf + %build # Configure and compile sources into $RPM_BUILD_ROOT %configure --enable-dependency-tracking --with-zabbix="$ZABBIX_SOURCE" @@ -72,7 +76,7 @@ mv $RPM_BUILD_ROOT%{_libdir}/%{name}.so $RPM_BUILD_ROOT%{moddir}/modules/%{name} install -dm 755 $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/zabbix_agentd.d echo "LoadModule=libzbxpgsql.so" > $RPM_BUILD_ROOT%{_sysconfdir}/zabbix/zabbix_agentd.d/%{name}.conf install -dm 755 $RPM_BUILD_ROOT%{_sysconfdir}/%{name}.d -install -m 644 query.conf $RPM_BUILD_ROOT%{_sysconfdir}/%{name}.d/ +install -m 644 %{S:1} $RPM_BUILD_ROOT%{_sysconfdir}/%{name}.d/ %clean # Clean out the build root From 119fdedaf7242cbd00ab1991aff7f74a0aef58d1 Mon Sep 17 00:00:00 2001 From: Otheus Date: Wed, 17 Mar 2021 00:58:50 +0100 Subject: [PATCH 3/4] changelog update --- rpmbuild/libzbxpgsql.spec | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rpmbuild/libzbxpgsql.spec b/rpmbuild/libzbxpgsql.spec index 3cfccf4..aa52171 100644 --- a/rpmbuild/libzbxpgsql.spec +++ b/rpmbuild/libzbxpgsql.spec @@ -88,6 +88,11 @@ rm -rf $RPM_BUILD_ROOT %{_sysconfdir}/%{name}.d/query.conf %changelog +* Wed Mar 17 2021 Otheus 1.1.0-2 +- Check for Zabbix source directory and pg_config variables +- Require query.conf to be in source tree. It's not clear which + directory this file should be pulled from, since a spec file + should define all sources within itself. * Sat Aug 20 2016 Ryan Armstrong 1.1.0-1 - Added configuration file for long custom queries - Rob Brucks From 9bbd7b82732c8fc62d8d6b261553b6067301829e Mon Sep 17 00:00:00 2001 From: Otheus Date: Wed, 17 Mar 2021 00:59:38 +0100 Subject: [PATCH 4/4] package release bump --- rpmbuild/libzbxpgsql.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpmbuild/libzbxpgsql.spec b/rpmbuild/libzbxpgsql.spec index aa52171..949f0dc 100644 --- a/rpmbuild/libzbxpgsql.spec +++ b/rpmbuild/libzbxpgsql.spec @@ -1,7 +1,7 @@ Name : libzbxpgsql Vendor : cavaliercoder Version : 1.1.0 -Release : 1 +Release : 2 Summary : PostgreSQL monitoring module for Zabbix Group : Applications/Internet