1. Burak Gürsoy
  2. CPAN-Sys-Info-Driver-Linux

Commits

burak  committed 3d11985

Use full path to ifconfig.
Fixes for ::Distribution

  • Participants
  • Parent commits b7c6e1d
  • Branches default

Comments (0)

Files changed (5)

File Changes

View file
 Revision history for Perl extension Sys::Info::Driver::Linux.
 
+0.7902 Mon Nov 26 04:08:14 2012
+    => Use full path to ifconfig.
+    => Fixes for ::Distribution
+
 0.7901 Sun Jul 15 23:45:45 2012
     => Workaround for the missing /etc/lsb-release and existing /etc/lsb-release.d/ (CentOS)
     => Attach " Linux" to the name only if it doesn't have that already (RHEL).

File lib/Sys/Info/Driver/Linux.pm

View file
 use vars qw( $VERSION @ISA @EXPORT );
 use base qw( Exporter );
 
-$VERSION = '0.7901';
+$VERSION = '0.7902';
 @EXPORT  = qw( proc );
 
 use constant proc => { ## no critic (NamingConventions::Capitalization)

File lib/Sys/Info/Driver/Linux/OS.pm

View file
 
 sub _ip {
     my $self = shift;
-    my $raw  = qx(ifconfig);
+    my $cmd  = q{/sbin/ifconfig};
+    return if ! -e $cmd || ! -x _;
+    my $raw = qx($cmd);
     return if not $raw;
     my @raw = split /inet addr/xms, $raw;
     return if ! @raw || @raw < 2 || ! $raw[1];

File lib/Sys/Info/Driver/Linux/OS/Distribution.pm

View file
 use constant STD_RELEASE     => 'lsb-release';
 use constant STD_RELEASE_DIR => 'lsb-release.d';
 use constant STD_ETC_DIR     => '/etc';
+
 use base qw( Sys::Info::Base );
 use Carp qw( croak );
 use Sys::Info::Driver::Linux;
                 keys %uniq;
             }
         };
+
         return if ! $release; # huh?
+
         my($rname) = split m{\-}xms, $self->{release_file};
         my($distrib_id, @rest)  = split m{release}xms, $release, 2;
         my($version, $codename) = split m{ \s+   }xms, $self->trim( join ' ', @rest ), 2;
-        $codename   =~ s{[()]}{}xmsg;
+        $codename   =~ s{[()]}{}xmsg if $codename;
         $distrib_id = $self->trim( $distrib_id );
         $self->{DISTRIB_DESCRIPTION} = $release;
         $self->{DISTRIB_ID}          = $rname || $distrib_id;
         $self->{DISTRIB_NAME}        = $distrib_id;
         $self->{DISTRIB_RELEASE}     = $version;
-        $self->{DISTRIB_CODENAME}    = $codename;
+        $self->{DISTRIB_CODENAME}    = $codename || q{};
 
         # fix stupidity
         if (   $self->{DISTRIB_ID}

File t/04-distribution.t

View file
 use warnings;
 use Carp       qw( croak   );
 use Test::More qw( no_plan );
+use Data::Dumper;
 
-BEGIN {
-    use_ok('Sys::Info::Driver::Linux::OS::Distribution');
-};
+use Sys::Info::Driver::Linux::OS::Distribution;
 
 ok( my $distro  = Sys::Info::Driver::Linux::OS::Distribution->new, 'Got the object' );
 ok( my $name    = $distro->name,    'Got a name'    );
 ok( my $version = $distro->version, 'Got a version' );
 
+diag Dumper {
+    distro  => $distro,
+    name    => $name,
+    version => $version,
+};
+
 dump_if_exists( '/etc/lsb-release' );
 
 sub dump_if_exists {