[nut/f16] do not depend on devel files (#838139)

Michal Hlavinka mhlavink at fedoraproject.org
Thu Sep 6 12:12:30 UTC 2012


commit 612ab8612e70977eec9283d8e26188eb838cf802
Author: Michal Hlavinka <mhlavink at redhat.com>
Date:   Thu Sep 6 14:12:23 2012 +0200

    do not depend on devel files (#838139)

 libs.sh                    |   32 +++++++++++
 nut-2.6.5-dlfix.patch      |  126 ++++++++++++++++++++++++++++++++++++++++++++
 nut-2.6.5-pthreadfix.patch |   32 +++++++++++
 nut.spec                   |   11 ++++
 4 files changed, 201 insertions(+), 0 deletions(-)
---
diff --git a/libs.sh b/libs.sh
new file mode 100644
index 0000000..a6ca8a8
--- /dev/null
+++ b/libs.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+for l in libavahi-client libfreeipmi libusb libnetsnmp libneon
+do
+  rp=""
+  for p in /usr/lib64 /lib64 /usr/lib /lib
+  do
+    if [ -f ${p}/${l}.so ]
+    then
+      fn=$( readlink ${p}/${l}.so )
+      mfn=${fn%.so.*}.so
+      sfn=${fn##*.so.}
+      tfn=$mfn
+      while [ $tfn = ${l}.so ] || [ ! -f ${p}/${tfn} -a -n "$sfn" ]
+      do
+        tfn=${tfn}.${sfn%%.*}
+        sfn=${sfn#*.}
+      done
+      if [ -f ${p}/${tfn} ]
+      then
+        rp=${tfn}
+      else
+        rp=${fn}
+      fi
+      break
+    fi
+  done
+  echo "#define $( echo "$l" | tr '[a-z]-' '[A-Z]_')_PATH \"$rp\""
+done
+
+VINFO=$(sed -e '/version-info/!d' -e 's/#.*$//' -e 's/^.*-version-info//' -e 's/[[:space:]]//g' clients/Makefile)
+echo "#define LIBUPSCLIENT_PATH \"libupsclient.so.$(( ${VINFO%%:*}-${VINFO##*:} ))\""
diff --git a/nut-2.6.5-dlfix.patch b/nut-2.6.5-dlfix.patch
new file mode 100644
index 0000000..9198f65
--- /dev/null
+++ b/nut-2.6.5-dlfix.patch
@@ -0,0 +1,126 @@
+diff -up nut-2.6.5/tools/nut-scanner/scan_avahi.c.dlfix nut-2.6.5/tools/nut-scanner/scan_avahi.c
+--- nut-2.6.5/tools/nut-scanner/scan_avahi.c.dlfix	2012-07-31 19:38:58.000000000 +0200
++++ nut-2.6.5/tools/nut-scanner/scan_avahi.c	2012-09-06 12:56:45.383206759 +0200
+@@ -36,7 +36,7 @@
+ #include <ltdl.h>
+ 
+ /* dynamic link library stuff */
+-static char * libname = "libavahi-client";
++static char * libname = LIBAVAHI_CLIENT_PATH;
+ static lt_dlhandle dl_handle = NULL;
+ static const char *dl_error = NULL;
+ 
+@@ -99,7 +99,7 @@ int nutscan_load_avahi_library()
+                 return 0;
+         }
+ 
+-        dl_handle = lt_dlopenext(libname);
++        dl_handle = lt_dlopen(libname);
+         if (!dl_handle) {
+                 dl_error = lt_dlerror();
+                 goto err;
+diff -up nut-2.6.5/tools/nut-scanner/scan_ipmi.c.dlfix nut-2.6.5/tools/nut-scanner/scan_ipmi.c
+--- nut-2.6.5/tools/nut-scanner/scan_ipmi.c.dlfix	2012-07-31 19:38:58.000000000 +0200
++++ nut-2.6.5/tools/nut-scanner/scan_ipmi.c	2012-09-06 12:56:55.760402197 +0200
+@@ -30,7 +30,7 @@
+ #define NUT_IPMI_DRV_NAME	"nut-ipmipsu"
+ 
+ /* dynamic link library stuff */
+-static char * libname = "libfreeipmi";
++static char * libname = LIBFREEIPMI_PATH;
+ static lt_dlhandle dl_handle = NULL;
+ static const char *dl_error = NULL;
+ 
+@@ -83,7 +83,7 @@ int nutscan_load_ipmi_library()
+ 		return 0;
+ 	}
+ 
+-	dl_handle = lt_dlopenext(libname);
++	dl_handle = lt_dlopen(libname);
+ 	if (!dl_handle) {
+ 		dl_error = lt_dlerror();
+ 		goto err;
+diff -up nut-2.6.5/tools/nut-scanner/scan_nut.c.dlfix nut-2.6.5/tools/nut-scanner/scan_nut.c
+--- nut-2.6.5/tools/nut-scanner/scan_nut.c.dlfix	2012-07-31 19:38:58.000000000 +0200
++++ nut-2.6.5/tools/nut-scanner/scan_nut.c	2012-09-06 12:54:59.308897430 +0200
+@@ -26,7 +26,7 @@
+ #include <ltdl.h>
+ 
+ /* dynamic link library stuff */
+-static char * libname = "libupsclient";
++static char * libname = LIBUPSCLIENT_PATH;
+ static lt_dlhandle dl_handle = NULL;
+ static const char *dl_error = NULL;
+ 
+@@ -66,7 +66,7 @@ int nutscan_load_upsclient_library()
+                 return 0;
+         }
+ 
+-        dl_handle = lt_dlopenext(libname);
++        dl_handle = lt_dlopen(libname);
+         if (!dl_handle) {
+                 dl_error = lt_dlerror();
+                 goto err;
+diff -up nut-2.6.5/tools/nut-scanner/scan_snmp.c.dlfix nut-2.6.5/tools/nut-scanner/scan_snmp.c
+--- nut-2.6.5/tools/nut-scanner/scan_snmp.c.dlfix	2012-07-31 19:38:58.000000000 +0200
++++ nut-2.6.5/tools/nut-scanner/scan_snmp.c	2012-09-06 12:57:16.250774817 +0200
+@@ -74,7 +74,7 @@ static int thread_count = 0;
+ long g_usec_timeout ;
+ 
+ /* dynamic link library stuff */
+-static char * libname = "libnetsnmp";
++static char * libname = LIBNETSNMP_PATH;
+ static lt_dlhandle dl_handle = NULL;
+ static const char *dl_error = NULL;
+ 
+@@ -119,7 +119,7 @@ int nutscan_load_snmp_library()
+                 return 0;
+         }
+ 
+-	dl_handle = lt_dlopenext(libname);
++	dl_handle = lt_dlopen(libname);
+ 	if (!dl_handle) {
+ 		dl_error = lt_dlerror();
+ 		goto err;
+diff -up nut-2.6.5/tools/nut-scanner/scan_usb.c.dlfix nut-2.6.5/tools/nut-scanner/scan_usb.c
+--- nut-2.6.5/tools/nut-scanner/scan_usb.c.dlfix	2012-07-31 19:38:58.000000000 +0200
++++ nut-2.6.5/tools/nut-scanner/scan_usb.c	2012-09-06 12:56:34.007987045 +0200
+@@ -28,7 +28,7 @@
+ #include <ltdl.h>
+ 
+ /* dynamic link library stuff */
+-static char * libname = "libusb";
++static char * libname = LIBUSB_PATH;
+ static lt_dlhandle dl_handle = NULL;
+ static const char *dl_error = NULL;
+ static int (*nut_usb_close)(usb_dev_handle *dev);
+@@ -58,7 +58,7 @@ int nutscan_load_usb_library()
+ 		return 0;
+ 	}
+ 
+-        dl_handle = lt_dlopenext(libname);
++        dl_handle = lt_dlopen(libname);
+         if (!dl_handle) {
+                 dl_error = lt_dlerror();
+                 goto err;
+diff -up nut-2.6.5/tools/nut-scanner/scan_xml_http.c.dlfix nut-2.6.5/tools/nut-scanner/scan_xml_http.c
+--- nut-2.6.5/tools/nut-scanner/scan_xml_http.c.dlfix	2012-07-31 19:38:58.000000000 +0200
++++ nut-2.6.5/tools/nut-scanner/scan_xml_http.c	2012-09-06 12:57:28.617991656 +0200
+@@ -33,7 +33,7 @@
+ #include <ltdl.h>
+ 
+ /* dynamic link library stuff */
+-static char * libname = "libneon";
++static char * libname = LIBNEON_PATH;
+ static lt_dlhandle dl_handle = NULL;
+ static const char *dl_error = NULL;
+ 
+@@ -64,7 +64,7 @@ int nutscan_load_neon_library()
+                 return 0;
+         }
+ 
+-        dl_handle = lt_dlopenext(libname);
++        dl_handle = lt_dlopen(libname);
+         if (!dl_handle) {
+                 dl_error = lt_dlerror();
+                 goto err;
diff --git a/nut-2.6.5-pthreadfix.patch b/nut-2.6.5-pthreadfix.patch
new file mode 100644
index 0000000..9aca92b
--- /dev/null
+++ b/nut-2.6.5-pthreadfix.patch
@@ -0,0 +1,32 @@
+diff -up nut-2.6.5/tools/nut-scanner/nut-scanner.c.pthreadfix nut-2.6.5/tools/nut-scanner/nut-scanner.c
+--- nut-2.6.5/tools/nut-scanner/nut-scanner.c.pthreadfix	2012-09-06 13:25:03.856936357 +0200
++++ nut-2.6.5/tools/nut-scanner/nut-scanner.c	2012-09-06 13:25:03.881936493 +0200
+@@ -434,22 +434,22 @@ display_help:
+ 	}
+ 
+ #ifdef HAVE_PTHREAD
+-	if( allow_usb && nutscan_avail_usb ) {
++	if( allow_usb && nutscan_avail_usb && thread[TYPE_USB]) {
+ 		pthread_join(thread[TYPE_USB],NULL);
+ 	}
+-	if( allow_snmp && nutscan_avail_snmp ) {
++	if( allow_snmp && nutscan_avail_snmp && thread[TYPE_SNMP]) {
+ 		pthread_join(thread[TYPE_SNMP],NULL);
+ 	}
+-	if( allow_xml && nutscan_avail_xml_http ) {
++	if( allow_xml && nutscan_avail_xml_http && thread[TYPE_XML]) {
+ 		pthread_join(thread[TYPE_XML],NULL);
+ 	}
+-	if( allow_oldnut && nutscan_avail_nut ) {
++	if( allow_oldnut && nutscan_avail_nut && thread[TYPE_NUT]) {
+ 		pthread_join(thread[TYPE_NUT],NULL);
+ 	}
+-	if( allow_avahi && nutscan_avail_avahi ) {
++	if( allow_avahi && nutscan_avail_avahi && thread[TYPE_AVAHI]) {
+ 		pthread_join(thread[TYPE_AVAHI],NULL);
+ 	}
+-	if( allow_ipmi && nutscan_avail_ipmi ) {
++	if( allow_ipmi && nutscan_avail_ipmi && thread[TYPE_IPMI]) {
+ 		pthread_join(thread[TYPE_IPMI],NULL);
+ 	}
+ #endif /* HAVE_PTHREAD */
diff --git a/nut.spec b/nut.spec
index a8d3ab5..69b1b4a 100644
--- a/nut.spec
+++ b/nut.spec
@@ -21,12 +21,15 @@ Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Url: http://www.networkupstools.org/
 Source: http://www.networkupstools.org/source/2.6/%{name}-%{version}.tar.gz
 Source3: nut-client.tmpfiles
+Source4: libs.sh
 
 Patch1: nut-2.6.3-fixbuild.patch
 Patch2: nut-2.6.3-tmpfiles.patch
 
 #quick fix. TODO: fix it properly
 Patch3: nut-2.6.5-quickfix.patch
+Patch5: nut-2.6.5-dlfix.patch
+Patch6: nut-2.6.5-pthreadfix.patch
 
 Requires(pre): shadow-utils udev
 Requires(post): fileutils chkconfig 
@@ -117,6 +120,9 @@ necessary to develop NUT client applications.
 %patch1 -p1 -b .fixbuild
 %patch2 -p1 -b .tmpfiles
 %patch3 -p1 -b .quickfix
+%patch5 -p1 -b .dlfix
+%patch6 -p1 -b .pthreadfix
+
 sed -i 's|=NUT-Monitor|=nut-monitor|'  scripts/python/app/nut-monitor.desktop
 sed -i "s|sys.argv\[0\]|'%{_datadir}/%{name}/nut-monitor/nut-monitor'|" scripts/python/app/NUT-Monitor
 sed -i 's|LIBSSL_LDFLAGS|LIBSSL_LIBS|' lib/libupsclient-config.in
@@ -148,6 +154,8 @@ autoreconf -i
     --libdir=%{_libdir}
 #    --with-doc \ asciidoc >= 8.6.3 is required
 
+sh %{SOURCE4} >>include/config.h
+
 #remove rpath
 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
@@ -483,6 +491,9 @@ rm -rf %{buildroot}
 %{_libdir}/pkgconfig/libupsclient.pc
 
 %changelog
+* Thu Sep 06 2012 Michal Hlavinka <mhlavink at redhat.com> - 2.6.5-1
+- do not depend on devel files (#838139)
+
 * Fri Aug 10 2012 Michal Hlavinka <mhlavink at redhat.com> - 2.6.5-1
 - nut updated to 2.6.5
 


More information about the scm-commits mailing list