r25095 - in /branches/upstream/libprobe-perl-perl: ./ current/ current/lib/ current/lib/Probe/ current/t/

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Sun Sep 14 06:30:57 UTC 2008


Author: dmn
Date: Sun Sep 14 06:30:51 2008
New Revision: 25095

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=25095
Log:
[svn-inject] Installing original source of libprobe-perl-perl

Added:
    branches/upstream/libprobe-perl-perl/
    branches/upstream/libprobe-perl-perl/current/
    branches/upstream/libprobe-perl-perl/current/Build.PL
    branches/upstream/libprobe-perl-perl/current/Changes
    branches/upstream/libprobe-perl-perl/current/MANIFEST
    branches/upstream/libprobe-perl-perl/current/META.yml
    branches/upstream/libprobe-perl-perl/current/Makefile.PL
    branches/upstream/libprobe-perl-perl/current/README
    branches/upstream/libprobe-perl-perl/current/SIGNATURE
    branches/upstream/libprobe-perl-perl/current/lib/
    branches/upstream/libprobe-perl-perl/current/lib/Probe/
    branches/upstream/libprobe-perl-perl/current/lib/Probe/Perl.pm
    branches/upstream/libprobe-perl-perl/current/t/
    branches/upstream/libprobe-perl-perl/current/t/basic.t

Added: branches/upstream/libprobe-perl-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libprobe-perl-perl/current/Build.PL?rev=25095&op=file
==============================================================================
--- branches/upstream/libprobe-perl-perl/current/Build.PL (added)
+++ branches/upstream/libprobe-perl-perl/current/Build.PL Sun Sep 14 06:30:51 2008
@@ -1,0 +1,18 @@
+use strict;
+use Module::Build;
+
+my $build = Module::Build->new
+  (
+   module_name => 'Probe::Perl',
+   license     => 'perl',
+   requires => {
+		'Config' => 0,
+	       },
+   build_requires => {
+		      'Test' => 0,
+		     },
+   create_makefile_pl => 'traditional',
+   sign => 1,
+  );
+
+$build->create_build_script();

Added: branches/upstream/libprobe-perl-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libprobe-perl-perl/current/Changes?rev=25095&op=file
==============================================================================
--- branches/upstream/libprobe-perl-perl/current/Changes (added)
+++ branches/upstream/libprobe-perl-perl/current/Changes Sun Sep 14 06:30:51 2008
@@ -1,0 +1,6 @@
+Revision history for ExtUtils-MyPerlConfig
+
+0.01  Tue Apr  5 22:42:26 CDT 2005
+
+  -  First version, released on an unsuspecting world.
+

Added: branches/upstream/libprobe-perl-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libprobe-perl-perl/current/MANIFEST?rev=25095&op=file
==============================================================================
--- branches/upstream/libprobe-perl-perl/current/MANIFEST (added)
+++ branches/upstream/libprobe-perl-perl/current/MANIFEST Sun Sep 14 06:30:51 2008
@@ -1,0 +1,9 @@
+Build.PL
+Changes
+lib/Probe/Perl.pm
+Makefile.PL
+MANIFEST			This list of files
+META.yml
+README
+t/basic.t
+SIGNATURE    Added here by Module::Build

Added: branches/upstream/libprobe-perl-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libprobe-perl-perl/current/META.yml?rev=25095&op=file
==============================================================================
--- branches/upstream/libprobe-perl-perl/current/META.yml (added)
+++ branches/upstream/libprobe-perl-perl/current/META.yml Sun Sep 14 06:30:51 2008
@@ -1,0 +1,19 @@
+--- #YAML:1.0
+name: Probe-Perl
+version: 0.01
+author:
+  - Randy W. Sims <randys at thepierianspring.org>
+  - |-
+    Based partly on code from the Module::Build project, by Ken Williams
+    <kwilliams at cpan.org> and others.
+abstract: Information about the currently running perl
+license: perl
+requires:
+  Config: 0
+build_requires:
+  Test: 0
+provides:
+  Probe::Perl:
+    file: lib/Probe/Perl.pm
+    version: 0.01
+generated_by: Module::Build version 0.2608

Added: branches/upstream/libprobe-perl-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libprobe-perl-perl/current/Makefile.PL?rev=25095&op=file
==============================================================================
--- branches/upstream/libprobe-perl-perl/current/Makefile.PL (added)
+++ branches/upstream/libprobe-perl-perl/current/Makefile.PL Sun Sep 14 06:30:51 2008
@@ -1,0 +1,14 @@
+# Note: this file was auto-generated by Module::Build::Compat version 0.03
+use ExtUtils::MakeMaker;
+WriteMakefile
+(
+          'NAME' => 'Probe::Perl',
+          'VERSION_FROM' => 'lib/Probe/Perl.pm',
+          'PREREQ_PM' => {
+                           'Config' => '0',
+                           'Test' => '0'
+                         },
+          'INSTALLDIRS' => 'site',
+          'PL_FILES' => {}
+        )
+;

Added: branches/upstream/libprobe-perl-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libprobe-perl-perl/current/README?rev=25095&op=file
==============================================================================
--- branches/upstream/libprobe-perl-perl/current/README (added)
+++ branches/upstream/libprobe-perl-perl/current/README Sun Sep 14 06:30:51 2008
@@ -1,0 +1,47 @@
+ExtUtils-MyPerlConfig
+
+The README is used to introduce the module and provide instructions on
+how to install the module, any machine dependencies it may have (for
+example C compilers and installed libraries) and any other information
+that should be provided before the module is installed.
+
+A README file is required for CPAN modules since CPAN extracts the README
+file from a module distribution so that people browsing the archive
+can use it get an idea of the modules uses. It is usually a good idea
+to provide version information here so that people can decide whether
+fixes for the module are worth downloading.
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+    perl Build.PL
+    ./Build
+    ./Build test
+    ./Build install
+
+
+Alternatively, to install with ExtUtils::MakeMaker, you can use the following commands:
+
+    perl Makefile.PL
+    make
+    make test
+    make install
+
+
+Alternatively, to install with Module::Build, you can use the following commands:
+
+    perl Build.PL
+    ./Build
+    ./Build test
+    ./Build install
+
+
+COPYRIGHT AND LICENCE
+
+Put the correct copyright and licence information here.
+
+Copyright (C) 2005 Randy W. Sims
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.

Added: branches/upstream/libprobe-perl-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libprobe-perl-perl/current/SIGNATURE?rev=25095&op=file
==============================================================================
--- branches/upstream/libprobe-perl-perl/current/SIGNATURE (added)
+++ branches/upstream/libprobe-perl-perl/current/SIGNATURE Sun Sep 14 06:30:51 2008
@@ -1,0 +1,31 @@
+This file contains message digests of all files listed in MANIFEST,
+signed via the Module::Signature module, version 0.38.
+
+To verify the content in this distribution, first make sure you have
+Module::Signature installed, then type:
+
+    % cpansign -v
+
+It would check each file's integrity, as well as the signature's
+validity.  If "==> Signature verified OK! <==" is not displayed,
+the distribution may already have been compromised, and you should
+not run its Makefile.PL or Build.PL.
+
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+SHA1 ccb41e7dd212313fe78767b52e7035739959e154 Build.PL
+SHA1 34694127ea22f622334b4fe58c33d1205b0033f5 Changes
+SHA1 540f2d8bf0bbc0814269cfb676fca65b3037d35c MANIFEST
+SHA1 def80c3d96ed6bbd119f02abdd5eaa830d0eb031 META.yml
+SHA1 b246af60178bb0a6138a91f993c22a779b288bf4 Makefile.PL
+SHA1 b1aa88e0bbf0eeb0b1f52419c4ebe4ddc383541a README
+SHA1 b02e203863a52d88cd8cd88a0abc50d383af0f20 lib/Probe/Perl.pm
+SHA1 9dd79c4cf103b5d6a887fe09851cafe8baa83702 t/basic.t
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.2.4 (Darwin)
+
+iD8DBQFCU1u8grvMBLfvlHYRAvgvAKCe0T2/X9JSNiSlGjSEDAf1clYduACgzW6D
+Ptbzc2VfTK5d2/xyLMfqGs8=
+=oUqL
+-----END PGP SIGNATURE-----

Added: branches/upstream/libprobe-perl-perl/current/lib/Probe/Perl.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libprobe-perl-perl/current/lib/Probe/Perl.pm?rev=25095&op=file
==============================================================================
--- branches/upstream/libprobe-perl-perl/current/lib/Probe/Perl.pm (added)
+++ branches/upstream/libprobe-perl-perl/current/lib/Probe/Perl.pm Sun Sep 14 06:30:51 2008
@@ -1,0 +1,272 @@
+package Probe::Perl;
+
+use vars qw( $VERSION );
+$VERSION = '0.01';
+
+use strict;
+
+# TODO: cache values derived from launching an external perl process
+# TODO: docs refer to Config.pm and $self->{config}
+
+
+use Config;
+use File::Spec;
+
+sub new {
+  my $class = shift;
+  my $data  = shift || {};
+  return bless( $data, $class );
+}
+
+sub config {
+  my ($self, $key) = (shift, shift);
+  if (@_) {
+    unless (ref $self) {
+      die "Can't set config values via $self->config().  Use $self->new() to create a local view";
+    }
+    $self->{$key} = shift;
+  }
+  return ref($self) && exists $self->{$key} ? $self->{$key} : $Config{$key};
+}
+
+sub config_revert {
+  my $self = shift;
+  die "Can't use config_revert() as a class method" unless ref($self);
+  
+  delete $self->{$_} foreach @_;
+}
+
+sub perl_version {
+  my $self = shift;
+  # Check the current perl interpreter
+  # It's much more convenient to use $] here than $^V, but 'man
+  # perlvar' says I'm not supposed to.  Bloody tyrant.
+  return $^V ? $self->perl_version_to_float(sprintf( "%vd", $^V )) : $];
+}
+
+sub perl_version_to_float {
+  my ($self, $version) = @_;
+  $version =~ s/\./../;  # Double up the first dot so the output has one dot remaining
+  $version =~ s/\.(\d+)/sprintf( '%03d', $1 )/eg;
+  return $version;
+}
+
+sub perl_is_same {
+  my ($self, $perl) = @_;
+  return `$perl -MConfig=myconfig -e print -e myconfig` eq Config->myconfig;
+}
+
+sub find_perl_interpreter {
+  my $self = shift;
+
+  return $^X if File::Spec->file_name_is_absolute($^X);
+
+  my $exe = $self->config('exe_ext');
+
+  my $thisperl = $^X;
+  if ($self->os_type eq 'VMS') {
+    # VMS might have a file version at the end
+    $thisperl .= $exe unless $thisperl =~ m/$exe(;\d+)?$/i;
+  } elsif (defined $exe) {
+    $thisperl .= $exe unless $thisperl =~ m/$exe$/i;
+  }
+
+  foreach my $perl ( $self->config('perlpath'),
+		     map( File::Spec->catfile($_, $thisperl),
+			  File::Spec->path() )
+		   ) {
+    return $perl if -f $perl and $self->perl_is_same($perl);
+  }
+  return;
+}
+
+# Determine the default @INC for this Perl
+sub perl_inc {
+  my $self = shift;
+
+  local $ENV{PERL5LIB};  # this is not considered part of the default.
+
+  my $perl = $self->find_perl_interpreter();
+
+  my @inc = `$perl -l -e print -e for -e \@INC`;
+  chomp @inc;
+
+  return @inc;
+}
+
+
+{
+  my %OSTYPES = qw(
+		   aix       Unix
+		   bsdos     Unix
+		   dgux      Unix
+		   dynixptx  Unix
+		   freebsd   Unix
+		   linux     Unix
+		   hpux      Unix
+		   irix      Unix
+		   darwin    Unix
+		   machten   Unix
+		   next      Unix
+		   openbsd   Unix
+		   netbsd    Unix
+		   dec_osf   Unix
+		   svr4      Unix
+		   svr5      Unix
+		   sco_sv    Unix
+		   unicos    Unix
+		   unicosmk  Unix
+		   solaris   Unix
+		   sunos     Unix
+		   cygwin    Unix
+		   os2       Unix
+
+		   dos       Windows
+		   MSWin32   Windows
+
+		   os390     EBCDIC
+		   os400     EBCDIC
+		   posix-bc  EBCDIC
+		   vmesa     EBCDIC
+
+		   MacOS     MacOS
+		   VMS       VMS
+		   VOS       VOS
+		   riscos    RiscOS
+		   amigaos   Amiga
+		   mpeix     MPEiX
+		  );
+
+
+  sub os_type {
+    my $class  = shift;
+    return $OSTYPES{shift || $^O};
+  }
+}
+
+
+1;
+
+__END__
+
+
+=head1 NAME
+
+Probe::Perl - Information about the currently running perl
+
+=head1 SYNOPSIS
+
+ use Probe::Perl;
+ $p = Probe::Perl->new();
+ 
+ # Version of this perl as a floating point number
+ $ver = $p->perl_version();
+ $ver = Probe::Perl->perl_version();
+ 
+ # Convert a multi-dotted string to a floating point number
+ $ver = $p->perl_version_to_float($ver);
+ $ver = Probe::Perl->perl_version_to_float($ver);
+ 
+ # Check if the given perl is the same as the one currently running
+ $bool = $p->perl_is_same($perl_path);
+ $bool = Probe::Perl->perl_is_same($perl_path);
+ 
+ # Find a path to the currently-running perl
+ $path = $p->find_perl_interpreter();
+ $path = Probe::Perl->find_perl_interpreter();
+ 
+ # Get @INC before run-time additions
+ @paths = $p->perl_inc();
+ @paths = Probe::Perl->perl_inc();
+ 
+ # Get the general type of operating system
+ $type = $p->os_type();
+ $type = Probe::Perl->os_type();
+ 
+ # Access Config.pm values
+ $val = $p->config('foo');
+ $val = Probe::Perl->config('foo');
+ $p->config('foo' => 'bar');  # Set locally
+ $p->config_revert('foo');  # Revert
+
+=head1 DESCRIPTION
+
+This module provides methods for obtaining information about the
+currently running perl interpreter.  It originally began life as code
+in the C<Module::Build> project, but has been externalized here for
+general use.
+
+=head1 METHODS
+
+=over 4
+
+=item new()
+
+Creates a new Probe::Perl object and returns it.  Most methods in
+the Probe::Perl packages are available as class methods, so you
+don't always need to create a new object.  But if you want to create a
+mutable view of the C<Config.pm> data, it's necessary to create an
+object to store the values in.
+
+=item config( $key [, $value] )
+
+Returns the C<Config.pm> value associated with C<$key>.  If C<$value>
+is also specified, then the value is set to C<$value> for this view of
+the data.  In this case, C<config()> must be called as an object
+method, not a class method.
+
+=item config_revert( $key )
+
+Removes any user-assigned value in this view of the C<Config.pm> data.
+
+=item find_perl_interpreter( )
+
+Returns the absolute path of this perl interpreter.  This is actually
+sort of a tricky thing to discover sometimes - in these cases we use
+C<perl_is_same()> to verify.
+
+=item perl_version( )
+
+Returns the version of this perl interpreter as a perl-styled version
+number using C<perl_version_to_float()>.  Uses C<$^V> if your perl is
+recent enough, otherwise uses C<$]>.
+
+=item perl_version_to_float( $version )
+
+Formats C<$version> as a perl-styled version number like C<5.008001>.
+
+=item perl_is_same( $perl )
+
+Given the name of a perl interpreter, this method determines if it has
+the same configuration as the one represented by the current perl
+instance.  Usually this means it's exactly the same
+
+=item perl_inc( )
+
+Returns a list of directories in this perl's C<@INC> path, I<before>
+any entries from C<use lib>, C<$ENV{PERL5LIB}>, or C<-I> switches are
+added.
+
+=item os_type( [$osname] )
+
+Returns a generic OS type (e.g. "Unix", "Windows", "MacOS") for the
+given OS name. If no OS name is given it uses the value in $^O, which
+is the same as $Config{osname}.
+
+=back
+
+=head1 AUTHOR
+
+Randy W. Sims <randys at thepierianspring.org>
+
+Based partly on code from the Module::Build project, by Ken Williams
+<kwilliams at cpan.org> and others.
+
+=head1 COPYRIGHT
+
+Copyright 2005 Ken Williams and Randy Sims.  All rights reserved.
+
+This library is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=cut

Added: branches/upstream/libprobe-perl-perl/current/t/basic.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libprobe-perl-perl/current/t/basic.t?rev=25095&op=file
==============================================================================
--- branches/upstream/libprobe-perl-perl/current/t/basic.t (added)
+++ branches/upstream/libprobe-perl-perl/current/t/basic.t Sun Sep 14 06:30:51 2008
@@ -1,0 +1,68 @@
+
+use strict;
+use Test;
+BEGIN { plan tests => 19 }
+
+use Probe::Perl;
+ok 1;
+
+my $pp = new Probe::Perl();
+ok defined $pp;
+
+use Config;
+ok $Config{version}, $pp->config('version');
+
+# returns undef for non-existent keys
+ok defined( $pp->config( 'foobarbaz' ) ), '';
+
+# basic config test
+$pp->config( foo => 'bar' );
+ok $pp->config( 'foo' ), 'bar';
+
+# override $Config value
+my $perl = $pp->config( 'perl' );
+$pp->config( perl => 'otherperl' );
+ok $pp->config( 'perl' ), 'otherperl';
+
+# undo override
+$pp->config_revert( 'perl' );
+ok $pp->config( 'perl' ), $perl;
+
+ok( Probe::Perl->os_type( 'linux' ), 'Unix');
+ok( Probe::Perl->os_type( 'MSWin32' ), 'Windows');
+
+
+# both object and class method return same value
+my $perl1 = $pp->find_perl_interpreter();
+ok $perl1;
+my $perl2 = Probe::Perl->find_perl_interpreter();
+ok $perl2;
+ok $perl1, $perl2;
+
+ok $pp->perl_is_same( $perl1 );
+
+
+# both object and class method return same value
+my $perl_vers1 = $pp->perl_version();
+ok $perl_vers1;
+my $perl_vers2 = Probe::Perl->perl_version();
+ok $perl_vers2;
+ok $perl_vers1, $perl_vers2;
+
+
+my @perl_inc1 = $pp->perl_inc();
+ok @perl_inc1;
+
+my @perl_inc2 = Probe::Perl->perl_inc();
+ok @perl_inc2;
+
+ok compare_array( \@perl_inc1, \@perl_inc2 );
+
+sub compare_array {
+  my( $a1, $a2 ) = @_;
+  return 0 unless @$a1 == @$a2;
+  foreach my $i ( 0..$#$a1 ) {
+    return 0 unless $a1->[$i] eq $a2->[$i];
+  }
+  return 1;
+}




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