r68670 - in /branches/upstream/liblinux-distribution-perl: ./ current/ current/lib/ current/lib/Linux/ current/t/

takaki at users.alioth.debian.org takaki at users.alioth.debian.org
Tue Feb 15 04:48:30 UTC 2011


Author: takaki
Date: Tue Feb 15 04:48:19 2011
New Revision: 68670

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=68670
Log:
[svn-inject] Installing original source of liblinux-distribution-perl (0.20)

Added:
    branches/upstream/liblinux-distribution-perl/
    branches/upstream/liblinux-distribution-perl/current/
    branches/upstream/liblinux-distribution-perl/current/Build.PL
    branches/upstream/liblinux-distribution-perl/current/Changes
    branches/upstream/liblinux-distribution-perl/current/MANIFEST
    branches/upstream/liblinux-distribution-perl/current/META.yml
    branches/upstream/liblinux-distribution-perl/current/Makefile.PL
    branches/upstream/liblinux-distribution-perl/current/README
    branches/upstream/liblinux-distribution-perl/current/lib/
    branches/upstream/liblinux-distribution-perl/current/lib/Linux/
    branches/upstream/liblinux-distribution-perl/current/lib/Linux/Distribution.pm
    branches/upstream/liblinux-distribution-perl/current/t/
    branches/upstream/liblinux-distribution-perl/current/t/Linux-Distribution.t

Added: branches/upstream/liblinux-distribution-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblinux-distribution-perl/current/Build.PL?rev=68670&op=file
==============================================================================
--- branches/upstream/liblinux-distribution-perl/current/Build.PL (added)
+++ branches/upstream/liblinux-distribution-perl/current/Build.PL Tue Feb 15 04:48:19 2011
@@ -1,0 +1,26 @@
+use strict;
+use Module::Build;
+#created by eumm-migrate.pl
+
+unless (lc $^O eq "linux") {
+    die "OS unsupported\n";
+}
+
+my $build = Module::Build->new(
+  'auto_configure_requires' => 0,
+  'dist_author' => 'Alexandr Ciornii <alexchorny at gmail.com>',
+  'module_name' => 'Linux::Distribution',
+  'meta_merge' => {
+    'resources' => {
+      'repository' => 'https://github.com/chorny/Linux-Distribution'
+    }
+  },
+  'requires' => {
+    'perl' => '5.006',
+    'Test::More' => 0
+  },
+  'license' => 'perl',
+  'dist_version_from' => 'lib/Linux/Distribution.pm'
+);
+
+$build->create_build_script();

Added: branches/upstream/liblinux-distribution-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblinux-distribution-perl/current/Changes?rev=68670&op=file
==============================================================================
--- branches/upstream/liblinux-distribution-perl/current/Changes (added)
+++ branches/upstream/liblinux-distribution-perl/current/Changes Tue Feb 15 04:48:19 2011
@@ -1,0 +1,50 @@
+* 2010-12-05 version 0.20
+
+Fixed version detection for Gentoo
+CentOS detection (modified patch from XSAWYERX)
+Start writing distribution-oriented tests
+Build.PL added
+
+* 2008-11-02 version 0.14_01
+
+Remove bareword filehandles and 2-arg open
+Will not install if not on Linux
+Modernize Makefile.PL
+Fix for 5.10
+Pardus support (by BURAK, RT#27357)
+Fix Fedora recognition (reported by sagarshahATsofthome.net, RT#11996)
+
+* 2005-02-16
+
+Added support for Redflag.
+
+* 2006-01-16
+Thanks to Judith Lebzelter now the module gets advantage of the LSB's /etc/lsb-release file.
+Added support for Ubuntu and version information retrieval for gentoo, debian, suse, fedora,
+redhat and slackware.
+
+* 2005-03-10
+Added support for yoper, arch-linux and libranet.
+
+* 2005-03-09
+Cleaned code.
+
+* 2005-03-08
+Version 0.03.
+Added support for Adamantix and Trustix.
+
+* 2005-03-07
+Reduced needed perl version to 5.6.0.
+Removed copyright line from pod documentation.
+
+* 2005-03-06
+Version 0.02.
+
+* 2005-03-06
+Added support for immunix, conectiva, tinysofa and va-linux.
+
+* 2005-03-06
+Updated changelog
+
+* 2005-03-06 20:14:28 +0100
+Version 0.01.

Added: branches/upstream/liblinux-distribution-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblinux-distribution-perl/current/MANIFEST?rev=68670&op=file
==============================================================================
--- branches/upstream/liblinux-distribution-perl/current/MANIFEST (added)
+++ branches/upstream/liblinux-distribution-perl/current/MANIFEST Tue Feb 15 04:48:19 2011
@@ -1,0 +1,8 @@
+Changes
+Makefile.PL
+Build.PL
+MANIFEST
+README
+t/Linux-Distribution.t
+lib/Linux/Distribution.pm
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/liblinux-distribution-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblinux-distribution-perl/current/META.yml?rev=68670&op=file
==============================================================================
--- branches/upstream/liblinux-distribution-perl/current/META.yml (added)
+++ branches/upstream/liblinux-distribution-perl/current/META.yml Tue Feb 15 04:48:19 2011
@@ -1,0 +1,21 @@
+---
+abstract: 'Perl extension to detect on which Linux distribution we are running.'
+author:
+  - 'Alexandr Ciornii <alexchorny at gmail.com>'
+generated_by: 'Module::Build version 0.3617'
+license: perl
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: 1.4
+name: Linux-Distribution
+provides:
+  Linux::Distribution:
+    file: lib/Linux/Distribution.pm
+    version: 0.20
+requires:
+  Test::More: 0
+  perl: 5.006
+resources:
+  license: http://dev.perl.org/licenses/
+  repository: https://github.com/chorny/Linux-Distribution
+version: 0.20

Added: branches/upstream/liblinux-distribution-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblinux-distribution-perl/current/Makefile.PL?rev=68670&op=file
==============================================================================
--- branches/upstream/liblinux-distribution-perl/current/Makefile.PL (added)
+++ branches/upstream/liblinux-distribution-perl/current/Makefile.PL Tue Feb 15 04:48:19 2011
@@ -1,0 +1,17 @@
+use 5.006000;
+use ExtUtils::MakeMaker;
+unless (lc $^O eq "linux") {
+    die "OS unsupported\n";
+}
+WriteMakefile(
+    NAME              => 'Linux::Distribution',
+    VERSION_FROM      => 'lib/Linux/Distribution.pm', # finds $VERSION
+    PREREQ_PM         => {
+      'Test::More' => 0,
+    },
+    ABSTRACT_FROM  => 'lib/Linux/Distribution.pm', # retrieve abstract from module
+    AUTHOR         => 'Alexandr Ciornii <alexchorny at gmail.com>', #Alberto Re <alberto at accidia.net>
+    ($ExtUtils::MakeMaker::VERSION ge '6.48'? 
+     ('LICENSE'	=> 'perl', 'MIN_PERL_VERSION' => 5.006,) : ()),
+    PL_FILES => {},
+);

Added: branches/upstream/liblinux-distribution-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblinux-distribution-perl/current/README?rev=68670&op=file
==============================================================================
--- branches/upstream/liblinux-distribution-perl/current/README (added)
+++ branches/upstream/liblinux-distribution-perl/current/README Tue Feb 15 04:48:19 2011
@@ -1,0 +1,36 @@
+Linux-Distribution version 0.20
+===============================
+
+This is a simple module that tries to guess on what linux distribution we are running by looking
+for release's files in /etc.  It now looks for 'lsb-release' first as that should be the most cor-
+rect and adds ubuntu support.  Secondly, it will look for the distro specific files.
+
+It currently recognizes slackware, debian, suse, fedora, redhat, turbolinux, yellowdog, knoppix,
+mandrake, conectiva, immunix, tinysofa, va-linux, trustix, adamantix, yoper, arch-linux, libranet,
+gentoo, ubuntu and redflag.
+
+It has function to get the version for debian, suse, redhat, gentoo, slackware, redflag and
+ubuntu(lsb). People running unsupported distro's are greatly encouraged to submit patches :-)
+
+INSTALLATION
+
+To install this module type the following:
+
+   perl Makefile.PL
+   make
+   make test
+   make install
+
+DEPENDENCIES
+
+This module has no dependencies.
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2006 by Alberto Re <alberto at accidia.net>
+(c) 2008-2010 Alexandr Ciornii <alexchorny at gmail.com>
+
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.5 or,
+at your option, any later version of Perl 5 you may have available.

Added: branches/upstream/liblinux-distribution-perl/current/lib/Linux/Distribution.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblinux-distribution-perl/current/lib/Linux/Distribution.pm?rev=68670&op=file
==============================================================================
--- branches/upstream/liblinux-distribution-perl/current/lib/Linux/Distribution.pm (added)
+++ branches/upstream/liblinux-distribution-perl/current/lib/Linux/Distribution.pm Tue Feb 15 04:48:19 2011
@@ -1,0 +1,221 @@
+package Linux::Distribution;
+
+use 5.006000;
+use strict;
+use warnings;
+
+require Exporter;
+
+our @ISA = qw(Exporter);
+
+our @EXPORT_OK = qw( distribution_name distribution_version );
+
+our $VERSION = '0.20';
+
+our $release_files_directory='/etc';
+our $standard_release_file = 'lsb-release';
+
+our %release_files = (
+    'gentoo-release'        => 'gentoo',
+    'fedora-release'        => 'fedora',
+    'turbolinux-release'    => 'turbolinux',
+    'mandrake-release'      => 'mandrake',
+    'mandrakelinux-release' => 'mandrakelinux',
+    'debian_version'        => 'debian',
+    'debian_release'        => 'debian',
+    'SuSE-release'          => 'suse',
+    'knoppix-version'       => 'knoppix',
+    'yellowdog-release'     => 'yellowdog',
+    'slackware-version'     => 'slackware',
+    'slackware-release'     => 'slackware',
+    'redflag-release'       => 'redflag',
+    'redhat-release'        => 'redhat',
+    'redhat_version'        => 'redhat',
+    'conectiva-release'     => 'conectiva',
+    'immunix-release'       => 'immunix',
+    'tinysofa-release'      => 'tinysofa',
+    'trustix-release'       => 'trustix',
+    'adamantix_version'     => 'adamantix',
+    'yoper-release'         => 'yoper',
+    'arch-release'          => 'arch',
+    'libranet_version'      => 'libranet',
+    'va-release'            => 'va-linux',
+    'pardus-release'        => 'pardus',
+);
+
+our %version_match = (
+    'gentoo'                => 'Gentoo Base System release (.*)',
+    'debian'                => '(.+)',
+    'suse'                  => 'VERSION = (.*)',
+    'fedora'                => 'Fedora Core release (\d+) \(',
+    'redflag'               => 'Red Flag (?:Desktop|Linux) (?:release |\()(.*?)(?: \(.+)?\)',
+    'redhat'                => 'Red Hat Linux release (.*) \(',
+    'slackware'             => '^Slackware (.+)$',
+    'pardus'                => '^Pardus (.+)$',
+    'centos'                => '^CentOS release (.+)(?:\s\(Final\))',
+);
+
+
+if ($^O ne 'linux') {
+#	require Carp;
+#	Carp::croak('you are trying to use a linux specific module on a different OS');
+}
+
+sub new {
+    my %self = (
+        'DISTRIB_ID'          => '',
+        'DISTRIB_RELEASE'     => '',
+        'DISTRIB_CODENAME'    => '',
+        'DISTRIB_DESCRIPTION' => '',
+        'release_file'        => '',
+        'pattern'             => ''
+    );
+    
+    return bless \%self;
+}
+
+sub distribution_name {
+    my $self = shift || new();
+    my $distro;
+    if ($distro = $self->_get_lsb_info()){
+        return $distro if ($distro);
+    }
+
+    foreach ('fedora-release') {
+        if (-f "$release_files_directory/$_" && !-l "$release_files_directory/$_"){
+            if (-f "$release_files_directory/$_" && !-l "$release_files_directory/$_"){
+                $self->{'DISTRIB_ID'} = $release_files{$_};
+                $self->{'release_file'} = $_;
+                return $self->{'DISTRIB_ID'};
+            }
+        }
+    }
+
+    foreach (keys %release_files) {
+        if (-f "$release_files_directory/$_" && !-l "$release_files_directory/$_"){
+            if (-f "$release_files_directory/$_" && !-l "$release_files_directory/$_"){
+                if ( $release_files{$_} eq 'redhat' ) {
+                    $self->{'pattern'} = $version_match{'centos'};
+                    $self->{'release_file'}='redhat-release';
+                    if ( $self->_get_file_info() ) {
+                        $self->{'DISTRIB_ID'} = 'centos';
+                        $self->{'release_file'} = $_;
+                        return $self->{'DISTRIB_ID'};
+                    } else {
+                        $self->{'pattern'}='';
+                    }
+                }
+                $self->{'release_file'} = $_;
+                $self->{'DISTRIB_ID'} = $release_files{$_};
+                return $self->{'DISTRIB_ID'};
+            }
+        }
+    }
+    undef 
+}
+
+sub distribution_version {
+    my $self = shift || new();
+    my $release;
+    return $release if ($release = $self->_get_lsb_info('DISTRIB_RELEASE'));
+    if (! $self->{'DISTRIB_ID'}){
+         $self->distribution_name() or die 'No version because no distro.';
+    }
+    $self->{'pattern'} = $version_match{$self->{'DISTRIB_ID'}};
+    $release = $self->_get_file_info();
+    $self->{'DISTRIB_RELEASE'} = $release;
+    return $release;
+}
+
+sub _get_lsb_info {
+    my $self = shift;
+    my $field = shift || 'DISTRIB_ID';
+    my $tmp = $self->{'release_file'};
+    if ( -r "$release_files_directory/" . $standard_release_file ) {
+        $self->{'release_file'} = $standard_release_file;
+        $self->{'pattern'} = $field . '=(.+)';
+        my $info = $self->_get_file_info();
+        if ($info){
+            $self->{$field} = $info;
+            return $info
+        }
+    } 
+    $self->{'release_file'} = $tmp;
+    $self->{'pattern'} = '';
+    undef;
+}
+
+sub _get_file_info {
+    my $self = shift;
+    open my $fh, '<', "$release_files_directory/" . $self->{'release_file'} or die 'Cannot open file: '.$release_files_directory.'/' . $self->{'release_file'};
+    my $info = '';
+    local $_;
+    while (<$fh>){
+        chomp $_;
+        ($info) = $_ =~ m/$self->{'pattern'}/;
+        return "\L$info" if $info;
+    }
+    undef;
+}
+
+1;
+__END__
+
+
+=head1 NAME
+
+Linux::Distribution - Perl extension to detect on which Linux distribution we are running.
+
+=head1 SYNOPSIS
+
+  use Linux::Distribution qw(distribution_name distribution_version);
+
+  if(my $distro = distribution_name) {
+        my $version = distribution_version();
+  	print "you are running $distro, version $version\n";
+  } else {
+  	print "distribution unknown\n";
+  }
+
+  Or else do it OO:
+
+  use Linux::Distribution qw(distribution_name distribution_version);
+
+  my $linux = Linux::Distribution->new;
+  if(my $distro = $linux->distribution_name()) {
+        my $version = $linux->distribution_version();
+        print "you are running $distro, version $version\n";
+  } else {
+        print "distribution unknown\n";
+  }
+
+=head1 DESCRIPTION
+
+This is a simple module that tries to guess on what linux distribution we are running by looking for release's files in /etc.  It now looks for 'lsb-release' first as that should be the most correct and adds ubuntu support.  Secondly, it will look for the distro specific files.
+
+It currently recognizes slackware, debian, suse, fedora, redhat, turbolinux, yellowdog, knoppix, mandrake, conectiva, immunix, tinysofa, va-linux, trustix, adamantix, yoper, arch-linux, libranet, gentoo, ubuntu and redflag.
+
+It has function to get the version for debian, suse, redhat, gentoo, slackware, redflag and ubuntu(lsb). People running unsupported distro's are greatly encouraged to submit patches :-)
+
+=head2 EXPORT
+
+None by default.
+
+=head1 TODO
+
+Add the capability of recognize the version of the distribution for all recognized distributions.
+
+=head1 AUTHORS
+
+Alexandr Ciornii E<lt>alexchorny at gmail.comE<gt>, L<http://chorny.net>
+Alberto Re, E<lt>alberto at accidia.netE<gt>
+Judith Lebzelter, E<lt>judith at osdl.orgE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.8.5 or,
+at your option, any later version of Perl 5 you may have available.
+
+=cut
+

Added: branches/upstream/liblinux-distribution-perl/current/t/Linux-Distribution.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/liblinux-distribution-perl/current/t/Linux-Distribution.t?rev=68670&op=file
==============================================================================
--- branches/upstream/liblinux-distribution-perl/current/t/Linux-Distribution.t (added)
+++ branches/upstream/liblinux-distribution-perl/current/t/Linux-Distribution.t Tue Feb 15 04:48:19 2011
@@ -1,0 +1,28 @@
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl Linux-Distribution.t'
+
+#########################
+
+# change 'tests => 1' to 'tests => last_test_to_print';
+
+use Test::More tests => 2;
+BEGIN { use_ok('Linux::Distribution') };
+
+if(isnt(Linux::Distribution::distribution_name(), undef, 'Checking your distro...')) {
+  diag('It seems that we are running on '.Linux::Distribution::distribution_name.' version '.(Linux::Distribution::distribution_version || 'unknown'))
+} else {
+  diag ('Please report your Linux dist to dist maintainer');
+  if (-e '/etc/lsb-release') {
+    diag ('lsb-release exists') ;
+    open my $fh,'<','/etc/lsb-release';
+    my $content=join('',<$fh>);
+    diag($content);
+  }
+}
+
+
+#########################
+
+# Insert your test code below, the Test::More module is use()ed here so read
+# its man page ( perldoc Test::More ) for help writing this test script.
+




More information about the Pkg-perl-cvs-commits mailing list