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

Commits

burak  committed 3e239fe

Quick patch Debian

  • Participants
  • Parent commits 1597817
  • Branches default

Comments (0)

Files changed (1)

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

View file
 use warnings;
 use constant STD_RELEASE     => 'lsb-release';
 use constant STD_RELEASE_DIR => 'lsb-release.d';
+use constant DEBIAN_RELEASE  => 'os-release';
 use constant STD_ETC_DIR     => '/etc';
 
 use base qw( Sys::Info::Base );
     my $field = shift || 'DISTRIB_ID';
     my $tmp   = $self->{release_file};
 
-    if ( -r File::Spec->catfile( $self->{etc_dir}, STD_RELEASE ) ) {
-        $self->{release_file} = STD_RELEASE;
+    my($rfile) = grep { -r $_->[1] }
+                map  {
+                    [ $_ => File::Spec->catfile( $self->{etc_dir}, $_ ) ]
+                }
+                STD_RELEASE,
+                DEBIAN_RELEASE
+                ;
+
+    if ( $rfile ) {
+        $self->{release_file} = $rfile->[0];
         $self->{pattern}      = $field . '=(.+)';
         my $info = $self->_get_file_info;
         return $self->{$field} = $info if $info;
     my $file = File::Spec->catfile( $self->{etc_dir}, $self->{release_file} );
     require IO::File;
     my $FH = IO::File->new;
-    $FH->open( $file, '<' ) || croak "Cannot open $file: $!";
+    $FH->open( $file, '<' ) || croak "Can't open $file: $!";
     my @raw = <$FH>;
     $FH->close || croak "Can't close FH($file): $!";
     my $rv;