diff -urN pcap.orig/debian/control pcap/debian/control --- pcap.orig/debian/control 2007-12-20 10:01:04.000000000 -0500 +++ pcap/debian/control 2007-12-20 09:14:00.000000000 -0500 @@ -2,7 +2,7 @@ Section: interpreters Priority: optional Maintainer: Debian Ruby Extras Maintainers -Build-Depends: debhelper (>> 5), cdbs, ruby-pkg-tools,libpcap-dev, ruby1.8, ruby1.8-dev +Build-Depends: debhelper (>> 5), cdbs, ruby-pkg-tools,libpcap-dev, dpatch, ruby1.8, ruby1.8-dev Standards-Version: 3.7.3 Homepage: http://www.goto.info.waseda.ac.jp/~fukusima/ruby/pcap-e.html Vcs-Browser: http://svn.debian.org/wsvn/pkg-ruby-extras/packages/libpcap-ruby/ diff -urN pcap.orig/debian/patches/00list pcap/debian/patches/00list --- pcap.orig/debian/patches/00list 1969-12-31 19:00:00.000000000 -0500 +++ pcap/debian/patches/00list 2007-12-20 09:57:13.000000000 -0500 @@ -0,0 +1,4 @@ +01_examples_ruby_path.dpatch +02_optparse.dpatch +03_debug_print.dpatch +04_findalldevs.dpatch diff -urN pcap.orig/debian/patches/01_examples_ruby_path.dpatch pcap/debian/patches/01_examples_ruby_path.dpatch --- pcap.orig/debian/patches/01_examples_ruby_path.dpatch 1969-12-31 19:00:00.000000000 -0500 +++ pcap/debian/patches/01_examples_ruby_path.dpatch 2007-12-20 09:16:59.000000000 -0500 @@ -0,0 +1,34 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 01_examples_ruby_path.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Use /usr/bin/ruby, not /usr/local/bin/ruby + +@DPATCH@ +diff -urNad pcap~/examples/httpdump.rb pcap/examples/httpdump.rb +--- pcap~/examples/httpdump.rb 2000-08-13 01:41:14.000000000 -0400 ++++ pcap/examples/httpdump.rb 2007-12-20 09:15:27.000000000 -0500 +@@ -1,4 +1,4 @@ +-#!/usr/local/bin/ruby ++#!/usr/bin/ruby + require 'pcaplet' + httpdump = Pcaplet.new('-s 1500') + +diff -urNad pcap~/examples/tcpdump.rb pcap/examples/tcpdump.rb +--- pcap~/examples/tcpdump.rb 1999-10-27 05:54:39.000000000 -0400 ++++ pcap/examples/tcpdump.rb 2007-12-20 09:15:39.000000000 -0500 +@@ -1,4 +1,4 @@ +-#!/usr/local/bin/ruby ++#!/usr/bin/ruby + require 'pcaplet' + include Pcap + +diff -urNad pcap~/examples/test.rb pcap/examples/test.rb +--- pcap~/examples/test.rb 1999-11-01 03:22:54.000000000 -0500 ++++ pcap/examples/test.rb 2007-12-20 09:15:14.000000000 -0500 +@@ -1,4 +1,4 @@ +-#!/usr/local/bin/ruby ++#!/usr/bin/ruby + require 'pcap' + + dev = Pcap.lookupdev diff -urN pcap.orig/debian/patches/02_optparse.dpatch pcap/debian/patches/02_optparse.dpatch --- pcap.orig/debian/patches/02_optparse.dpatch 1969-12-31 19:00:00.000000000 -0500 +++ pcap/debian/patches/02_optparse.dpatch 2007-12-20 09:24:50.000000000 -0500 @@ -0,0 +1,51 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 02_optparse.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Use optparse instead of getopts + +@DPATCH@ +diff -urNad pcap~/lib/pcaplet.rb pcap/lib/pcaplet.rb +--- pcap~/lib/pcaplet.rb 2000-08-13 01:22:14.000000000 -0400 ++++ pcap/lib/pcaplet.rb 2007-12-20 09:24:15.000000000 -0500 +@@ -1,5 +1,5 @@ + require 'pcap' +-require 'getopts' ++require 'optparse' + + def pcaplet_usage() + $stderr.print < +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Loop through stderr on DEBUG_PRINT + +@DPATCH@ +diff -urNad pcap~/ruby_pcap.h pcap/ruby_pcap.h +--- pcap~/ruby_pcap.h 2000-08-13 02:56:15.000000000 -0400 ++++ pcap/ruby_pcap.h 2007-12-20 09:30:38.000000000 -0500 +@@ -29,11 +29,12 @@ + #include + + #ifdef DEBUG +-# define DEBUG_PRINT(x) \ ++# define DEBUG_PRINT(x) do {\ + ((RTEST(ruby_debug) && RTEST(ruby_verbose))?\ +- (fprintf(stderr, "%s\n", x),fflush(stderr)) : 0) ++ (fprintf(stderr, "%s\n", x),fflush(stderr)) : 0)\ ++} while (0) + #else +-# define DEBUG_PRINT(x) (0) ++# define DEBUG_PRINT(x) do {} while (0) + #endif + + #define UINT32_2_NUM(i) rb_uint2inum(i) diff -urN pcap.orig/debian/patches/04_findalldevs.dpatch pcap/debian/patches/04_findalldevs.dpatch --- pcap.orig/debian/patches/04_findalldevs.dpatch 1969-12-31 19:00:00.000000000 -0500 +++ pcap/debian/patches/04_findalldevs.dpatch 2007-12-20 09:55:59.000000000 -0500 @@ -0,0 +1,61 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 04_findalldevs.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Add support for the findalldevs function of libpcap. + +@DPATCH@ +diff -urNad pcap~/Pcap.c pcap/Pcap.c +--- pcap~/Pcap.c 2000-08-13 01:56:31.000000000 -0400 ++++ pcap/Pcap.c 2007-12-20 09:53:39.000000000 -0500 +@@ -54,6 +54,29 @@ + } + + static VALUE ++pcap_s_findalldevs(self) ++ VALUE self; ++{ ++ pcap_if_t *alldevsp; ++ VALUE return_ary; ++ char pcap_errbuf[PCAP_ERRBUF_SIZE]; ++ ++ return_ary = rb_ary_new(); ++ ++ pcap_findalldevs(&alldevsp, pcap_errbuf); ++ ++ if (alldevsp == NULL) // List is empty, probably an error ++ rb_raise(ePcapError, "%s", pcap_errbuf); ++ ++ for (; alldevsp->next != NULL; alldevsp = alldevsp->next) ++ rb_ary_push(return_ary, rb_str_new2(alldevsp->name)); ++ ++ pcap_freealldevs(alldevsp); ++ ++ return return_ary; ++} ++ ++static VALUE + pcap_s_lookupnet(self, dev) + VALUE self; + VALUE dev; +@@ -723,6 +746,7 @@ + /* define module Pcap */ + mPcap = rb_define_module("Pcap"); + rb_define_module_function(mPcap, "lookupdev", pcap_s_lookupdev, 0); ++ rb_define_module_function(mPcap, "findalldevs", pcap_s_findalldevs, 0); + rb_define_module_function(mPcap, "lookupnet", pcap_s_lookupnet, 1); + rb_global_variable(&rbpcap_convert); + rb_define_singleton_method(mPcap, "convert?", pcap_s_convert, 0); +@@ -780,11 +804,7 @@ + /*rb_define_method(cFilter, "&", filter_and, 1);*/ + + /* define class PcapStat */ +- cPcapStat = rb_funcall(rb_cStruct, rb_intern("new"), 4, +- Qnil, +- INT2NUM(rb_intern("recv")), +- INT2NUM(rb_intern("drop")), +- INT2NUM(rb_intern("ifdrop"))); ++ cPcapStat = rb_struct_define(NULL, "recv", "drop", "ifdrop", NULL); + rb_define_const(mPcap, "Stat", cPcapStat); + + /* define exception classes */ diff -urN pcap.orig/debian/rules pcap/debian/rules --- pcap.orig/debian/rules 2007-12-20 10:01:04.000000000 -0500 +++ pcap/debian/rules 2007-12-20 09:14:00.000000000 -0500 @@ -2,6 +2,8 @@ # -*- mode: makefile; -*- include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/rules/dpatch.mk include /usr/share/ruby-pkg-tools/1/class/ruby-extconf-rb.mk +DEB_MAKE_CLEAN_TARGET = DEB_RUBY_INSTALL_ARGS = sitelibdir=$(CURDIR)/debian/libpcap-ruby1.8$(shell ruby1.8 -rrbconfig -e 'print Config::CONFIG["rubylibdir"]')