Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 liboping (1.6.2-6) unstable; urgency=medium
 .
   * build dependency on pkg-config (closes: 749058)
Author: Barak A. Pearlmutter <bap@debian.org>
Bug-Debian: http://bugs.debian.org/749058

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- /dev/null
+++ liboping-1.6.2/autogen.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+set -e
+
+autoreconf --warnings=all --install
+echo "autoconfiguration done, to build: ./configure ; make"
--- liboping-1.6.2.orig/configure.ac
+++ liboping-1.6.2/configure.ac
@@ -1,7 +1,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.65])
-AC_INIT([liboping],[1.6.2])
+AC_INIT([liboping],[1.6.2],[ff@octo.it],,[http://github.com/octo/liboping/])
 AC_CONFIG_SRCDIR([src/liboping.c])
 AC_CONFIG_HEADERS([src/config.h])
 AC_CONFIG_MACRO_DIR([m4])
@@ -45,6 +45,9 @@ AC_ARG_VAR(PERL, [Perl interpreter comma
 # configure libtool
 LT_INIT([dlopen])
 
+# pkg-config interface
+PKG_INSTALLDIR
+
 # Checks for header files.
 AC_HEADER_STDC
 AC_HEADER_TIME
--- /dev/null
+++ liboping-1.6.2/contrib/liboping.spec
@@ -0,0 +1,120 @@
+#
+# SPEC file for liboping
+#
+# This SPEC file is provided as a starting point for your own package of
+# liboping. It may use distribution specific commands or tags and may not be
+# suited for your distribution in its verbatim form. If at all possible, please
+# use a source-RPM (SRPM) provided by your distributor.
+#
+# That being said, bug reports concerning this SPEC file are welcome, of
+# course. Please report any bugs you find to liboping's mailing list at
+# <liboping at verplant.org>. Thanks to Benjamin Petrin for providing this
+# file.  --octo
+#
+Name:           liboping
+Version:        1.3.4 
+Release:        1%{?dist}
+Summary:        Ping library intended for use in network monitoring applications
+
+Group:          System Environment/Libraries
+License:        GPLv2
+URL:            http://verplant.org/liboping/
+Source0:        http://verplant.org/liboping/files/liboping-%{version}.tar.gz 
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+#TODO - find all build requirements using a clean system
+#BuildRequires:         
+
+%description
+The %{name} package is a C library to generate ICMP echo requests, better known 
+as “ping packets”. It is intended for use in network monitoring applications or
+applications that would otherwise need to fork ping(1) frequently. It is like 
+ping, ping6, and fping rolled into one.
+
+%package        devel
+Summary:        Development files for %{name}
+Group:          Development/Libraries
+Requires:       %{name} = %{version}-%{release}
+
+%description    devel
+The %{name}-devel package contains libraries and header files for
+developing applications that use %{name}.
+
+%package        perl
+Summary:        Perl bindings for %{name}
+Group:          Development/Libraries
+Requires:       %{name} = %{version}-%{release}
+Requires:       perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
+
+%description    perl
+The %{name}-perl package contains a perl module for perl programs
+that use %{name}.
+
+
+%prep
+%setup -q
+
+
+%build
+#Install perl bindings to vendor_perl instead of site_perl
+%configure --disable-static --with-perl-bindings='INSTALLDIRS=vendor OPTIMIZE="%{optflags}"'
+#The application uses a local copy of libtool, we need to remove rpath with the
+#following two lines (see https://fedoraproject.org/wiki/Packaging/Guidelines#Beware_of_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
+make %{?_smp_mflags}
+
+
+%install
+rm -rf %{buildroot}
+make install DESTDIR=%{buildroot}
+chmod -R u+w %{buildroot}/*
+find %{buildroot} -name '*.la' -exec rm -f {} ';'
+find %{buildroot} -type f -name .packlist -exec rm -f {} ';'
+find %{buildroot} -type f -name '*.bs' -a -size 0 -exec rm -f {} ';'
+find %{buildroot} -depth -type d -exec rmdir {} 2>/dev/null ';'
+find %{buildroot} -type f -name perllocal.pod -exec rm -f {} ';'
+
+%clean
+rm -rf %{buildroot}
+
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%defattr(-,root,root,-)
+%doc AUTHORS COPYING NEWS README ChangeLog
+%{_libdir}/*.so.*
+%{_bindir}/oping
+%{_mandir}/man8/oping.8*
+
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/*
+%{_libdir}/*.so
+%{_mandir}/man3/liboping.3*
+%{_mandir}/man3/ping_construct.3*
+%{_mandir}/man3/ping_get_error.3*
+%{_mandir}/man3/ping_host_add.3*
+%{_mandir}/man3/ping_iterator_get.3*
+%{_mandir}/man3/ping_iterator_get_context.3*
+%{_mandir}/man3/ping_iterator_get_info.3*
+%{_mandir}/man3/ping_send.3*
+%{_mandir}/man3/ping_setopt.3*
+
+%files perl
+%defattr(-,root,root,-)
+%doc bindings/perl/README bindings/perl/Changes
+# For arch-specific packages: vendorarch
+%{perl_vendorarch}/*
+%exclude %dir %{perl_vendorarch}/auto/
+%{_mandir}/man3/Net::Oping.3pm*
+
+
+%changelog
+* Fri Jan 22 2010 Benjamin Petrin <b.petrin@wpi.edu> - 1.3.4-1
+- Initial package
--- liboping-1.6.2.orig/src/Makefile.am
+++ liboping-1.6.2/src/Makefile.am
@@ -33,6 +33,24 @@ if BUILD_WITH_LIBXNET
 liboping_la_LIBADD += -lxnet
 endif
 
+oping.pc:
+	echo 'prefix=$(prefix)'			>  $@
+	echo 'exec_prefix=$(exec_prefix)'	>> $@
+	echo 'includedir=$(includedir)'		>> $@
+	echo 'libdir=$(libdir)'			>> $@
+	echo					>> $@
+	echo 'Name: $(PACKAGE_TARNAME)'		>> $@
+	echo 'Description: $(PACKAGE_NAME)'	>> $@
+	echo 'URL: $(PACKAGE_URL)'		>> $@
+	echo 'Version: $(PACKAGE_VERSION)'	>> $@
+	echo 'Cflags: -I${includedir}'		>> $@
+	echo 'Libs: -L${libdir} -loping'	>> $@
+	echo 'Libs.private: $(AM_LDFLAGS) $(LIBS) $(liboping_la_LIBADD)'	>> $@
+
+pkgconfig_DATA = oping.pc
+
+MOSTLYCLEANFILES = $(pkgconfig_DATA)
+
 bin_PROGRAMS = oping
 
 oping_SOURCES = oping.c
--- liboping-1.6.2.orig/src/liboping.c
+++ liboping-1.6.2/src/liboping.c
@@ -637,6 +637,9 @@ static int ping_receive_one (pingobj_t *
 	return (0);
 }
 
+/* Blocks until a packet was received from all hosts or the timeout is reached.
+ * When interrupted, (-EINTR) is returned. On error, -1 is returned. On
+ * success, returns zero. */
 static int ping_receive_all (pingobj_t *obj)
 {
 	fd_set read_fds;
@@ -726,7 +729,8 @@ static int ping_receive_all (pingobj_t *
 		if ((status == -1) && (errno == EINTR))
 		{
 			dprintf ("select was interrupted by signal..\n");
-			continue;
+			ping_set_errno (obj, EINTR);
+			return (-EINTR);
 		}
 		else if (status < 0)
 		{
@@ -764,7 +768,7 @@ static int ping_receive_all (pingobj_t *
 	} /* while (1) */
 	
 	return (ret);
-}
+} /* int ping_receive_all */
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * Sending functions:                                                        *
@@ -1328,18 +1332,13 @@ int ping_setopt (pingobj_t *obj, int opt
 
 int ping_send (pingobj_t *obj)
 {
-	int ret;
-
 	if (obj == NULL)
 		return (-1);
 
 	if (ping_send_all (obj) < 0)
 		return (-1);
 
-	if ((ret = ping_receive_all (obj)) < 0)
-		return (-2);
-
-	return (ret);
+	return (ping_receive_all (obj));
 }
 
 static pinghost_t *ping_host_search (pinghost_t *ph, const char *host)
--- liboping-1.6.2.orig/src/oping.c
+++ liboping-1.6.2/src/oping.c
@@ -123,6 +123,10 @@ static size_t const hist_colors_num = si
 # define _POSIX_SAVED_IDS 0
 #endif
 
+#ifndef IPTOS_MINCOST
+# define IPTOS_MINCOST 0x02
+#endif
+
 /* Remove GNU specific __attribute__ settings when using another compiler */
 #if !__GNUC__
 # define __attribute__(x) /**/
@@ -1426,7 +1430,12 @@ int main (int argc, char **argv) /* {{{
 			return (1);
 		}
 
-		if (ping_send (ping) < 0)
+		status = ping_send (ping);
+		if (status == -EINTR)
+		{
+			continue;
+		}
+		else if (status < 0)
 		{
 			fprintf (stderr, "ping_send failed: %s\n",
 					ping_get_error (ping));
@@ -1459,14 +1468,13 @@ int main (int argc, char **argv) /* {{{
 		/* printf ("Sleeping for %i.%09li seconds\n", (int) ts_wait.tv_sec, ts_wait.tv_nsec); */
 		while ((status = nanosleep (&ts_wait, &ts_wait)) != 0)
 		{
-			if (errno != EINTR)
+			if (errno == EINTR)
 			{
-				perror ("nanosleep");
-				break;
+				continue;
 			}
-			else if (opt_count == 0)
+			else
 			{
-				/* sigint */
+				perror ("nanosleep");
 				break;
 			}
 		}
