[DRE-commits] [ruby-packetfu] 06/10: Add a patch to use Ruby 2.1+ new API instead of the unpackaged network_interface library

Jérémy Bobbio lunar at moszumanska.debian.org
Thu Sep 10 14:59:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository ruby-packetfu.

commit 940ca34ec0294952a84ed6f27fe6f9c7e6352c07
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Thu Sep 10 16:30:37 2015 +0200

    Add a patch to use Ruby 2.1+ new API instead of the unpackaged network_interface library
---
 ...work_interface-by-Ruby-2.1-Socket.getifad.patch | 90 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 2 files changed, 91 insertions(+)

diff --git a/debian/patches/0006-Replace-network_interface-by-Ruby-2.1-Socket.getifad.patch b/debian/patches/0006-Replace-network_interface-by-Ruby-2.1-Socket.getifad.patch
new file mode 100644
index 0000000..5959f87
--- /dev/null
+++ b/debian/patches/0006-Replace-network_interface-by-Ruby-2.1-Socket.getifad.patch
@@ -0,0 +1,90 @@
+Description: Replace network_interface by Ruby 2.1+ Socket.getifaddrs
+ Instead of introducing a new package in Debian, we replace the dependency
+ on network_interface by taking advantage of a similar feature introduced
+ in Ruby 2.1: Socket.getifaddrs.
+Author: Jérémy Bobbio <lunar at debian.org>
+Last-Update: 2015-09-10
+
+Thanks to Lance Sanchez for the pointer!
+---
+ lib/packetfu/utils.rb | 12 +++---------
+ metadata.yml          | 14 --------------
+ packetfu.gemspec      |  3 ++-
+ 3 files changed, 5 insertions(+), 24 deletions(-)
+
+diff --git a/lib/packetfu/utils.rb b/lib/packetfu/utils.rb
+index a7df644..460d262 100644
+--- a/lib/packetfu/utils.rb
++++ b/lib/packetfu/utils.rb
+@@ -1,7 +1,6 @@
+ # -*- coding: binary -*-
+ require 'singleton'
+ require 'timeout'
+-require 'network_interface'
+ 
+ module PacketFu
+ 
+@@ -166,13 +165,8 @@ module PacketFu
+     def self.default_int
+       ip = default_ip
+ 
+-      NetworkInterface.interfaces.each do |interface|
+-        NetworkInterface.addresses(interface).values.each do |addresses|
+-          addresses.each do |address|
+-            next if address["addr"].nil?
+-            return interface if address["addr"] == ip
+-          end
+-        end
++      Socket.getifaddrs.each do |ifaddr|
++        return ifaddr.name if ifaddr.addr.inspect_sockaddr == ip
+       end
+ 
+       # Fall back to libpcap as last resort
+@@ -182,7 +176,7 @@ module PacketFu
+     # Determine the ifconfig data string for a given interface
+     def self.ifconfig_data_string(iface=default_int)
+       # Make sure to only get interface data for a real interface
+-      unless NetworkInterface.interfaces.include?(iface)
++      if Socket.getifaddrs.select { |ifaddr| ifaddr.name == iface }.empty?
+         raise ArgumentError, "#{iface} interface does not exist"
+       end
+       return %x[ifconfig #{iface}]
+diff --git a/metadata.yml b/metadata.yml
+index 0cee60d..26bfe25 100644
+--- a/metadata.yml
++++ b/metadata.yml
+@@ -33,20 +33,6 @@ cert_chain:
+ date: 2015-08-25 00:00:00.000000000 Z
+ dependencies:
+ - !ruby/object:Gem::Dependency
+-  name: network_interface
+-  requirement: !ruby/object:Gem::Requirement
+-    requirements:
+-    - - "~>"
+-      - !ruby/object:Gem::Version
+-        version: '0.0'
+-  type: :runtime
+-  prerelease: false
+-  version_requirements: !ruby/object:Gem::Requirement
+-    requirements:
+-    - - "~>"
+-      - !ruby/object:Gem::Version
+-        version: '0.0'
+-- !ruby/object:Gem::Dependency
+   name: pcaprub
+   requirement: !ruby/object:Gem::Requirement
+     requirements:
+diff --git a/packetfu.gemspec b/packetfu.gemspec
+index 1fceb61..ff61916 100644
+--- a/packetfu.gemspec
++++ b/packetfu.gemspec
+@@ -12,7 +12,8 @@ Gem::Specification.new do |s|
+   s.files       = `git ls-files`.split($/)
+   s.license     = 'BSD'
+ 
+-  s.add_dependency('network_interface', '~> 0.0')
++  s.required_ruby_version '=> 2.1'
++
+   s.add_dependency('pcaprub', '~> 0.12')
+   s.add_development_dependency('rake', '~> 10.3')
+   s.add_development_dependency('rspec', '~> 3.0')
diff --git a/debian/patches/series b/debian/patches/series
index 529075e..7fba54f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 0005-Require-rspec-its.patch
+0006-Replace-network_interface-by-Ruby-2.1-Socket.getifad.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-packetfu.git



More information about the Pkg-ruby-extras-commits mailing list