Change 19065 by [EMAIL PROTECTED] on 2003/03/26 19:55:20
Add a file utils/cpan.PL to generate the "cpan" utility,
also separately maintained on CPAN, and now moved as
lib/CPAN/bin/cpan. Tweak installperl to avoid installing
this last file.
Affected files ...
... //depot/perl/MANIFEST#996 edit
... //depot/perl/installperl#105 edit
... //depot/perl/lib/CPAN/bin/cpan#1 branch
... //depot/perl/utils/Makefile#23 edit
... //depot/perl/utils/cpan#2 delete
... //depot/perl/utils/cpan.PL#1 add
Differences ...
==== //depot/perl/MANIFEST#996 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST#995~19051~ Sun Mar 23 20:27:55 2003
+++ perl/MANIFEST Wed Mar 26 11:55:20 2003
@@ -1036,6 +1036,7 @@
lib/CPAN/t/mirroredby.t See if CPAN::Mirrored::By works
lib/CPAN/t/Nox.t See if CPAN::Nox works
lib/CPAN/t/vcmp.t See if CPAN the module works
+lib/CPAN/bin/cpan easily interact with CPAN from the command line
lib/ctime.pl A ctime workalike
lib/Cwd.pm Various cwd routines (getcwd, fastcwd, chdir)
lib/DB.pm Debugger API (draft)
@@ -2748,7 +2749,7 @@
util.c Utility routines
util.h Dummy header
utils.lst Lists utilities bundled with Perl
-utils/cpan easily interact with CPAN from the command line
+utils/cpan.PL easily interact with CPAN from the command line
utils/c2ph.PL program to translate dbx stabs to perl
utils/dprofpp.PL Perl code profile post-processor
utils/enc2xs.PL Encode module generator
@@ -2760,7 +2761,7 @@
utils/perlcc.PL Front-end for compiler
utils/perldoc.PL A simple tool to find & display perl's documentation
utils/perlivp.PL installation verification procedure
-utils/piconv.PL A pl to pm translator
+utils/piconv.PL iconv(1), reinvented in perl
utils/pl2pm.PL A pl to pm translator
utils/splain.PL Stand-alone version of diagnostics.pm
uts/sprintf_wrap.c sprintf wrapper for UTS
==== //depot/perl/installperl#105 (xtext) ====
Index: perl/installperl
--- perl/installperl#104~18030~ Sat Oct 19 07:10:21 2002
+++ perl/installperl Wed Mar 26 11:55:20 2003
@@ -747,16 +747,18 @@
my $name = $_;
- # Ignore RCS and CVS directories.
- if (($name eq 'CVS' or $name eq 'RCS') and -d $name) {
+ # Ignore version control directories.
+ if (($name eq 'CVS' or $name eq 'RCS' or $name eq '.svn') and -d $name) {
$File::Find::prune = 1;
return;
}
# ignore patch backups, RCS files, emacs backup & temp files and the
# .exists files, .PL files, and .t files.
- return if $name =~ m{\.orig$|~$|^#.+#$|,v$|^\.exists|\.PL$|\.t$} ||
+ return if $name =~ m{\.orig$|\.rej$|~$|^#.+#$|,v$|^\.exists|\.PL$|\.t$} ||
$dir =~ m{/t(?:/|$)};
+ # ignore the cpan script in lib/CPAN/bin (installed later with other utils)
+ return if $name eq 'cpan';
# ignore the test extensions
return if $dir =~ m{ext/XS/(?:APItest|Typemap)/};
==== //depot/perl/lib/CPAN/bin/cpan#1 (text) ====
Index: perl/lib/CPAN/bin/cpan
--- /dev/null Tue May 5 13:32:27 1998
+++ perl/lib/CPAN/bin/cpan Wed Mar 26 11:55:20 2003
@@ -0,0 +1,203 @@
+#!/usr/bin/perl
+# $Id: cpan,v 1.3 2002/08/30 08:55:15 k Exp $
+use strict;
+
+=head1 NAME
+
+cpan - easily interact with CPAN from the command line
+
+=head1 SYNOPSIS
+
+ # with arguments, installs specified modules
+ cpan module_name [ module_name ... ]
+
+ # with switches, installs modules with extra behavior
+ cpan [-cimt] module_name [ module_name ... ]
+
+ # without arguments, starts CPAN shell
+ cpan
+
+ # without arguments, but some switches
+ cpan [-ahrv]
+
+=head1 DESCRIPTION
+
+This script provides a command interface (not a shell) to CPAN.pm.
+
+=head2 Meta Options
+
+These options are mutually exclusive, and the script processes
+them in this order: [ahvr]. Once the script finds one, it ignores
+the others, and then exits after it finishes the task. The script
+ignores any other command line options.
+
+=over 4
+
+=item -a
+
+Creates the CPAN.pm autobundle with CPAN::Shell->autobundle.
+
+=item -h
+
+Prints a help message.
+
+=item -r
+
+Recompiles dynamically loaded modules with CPAN::Shell->recompile.
+
+=item -v
+
+Print the script version and CPAN.pm version.
+
+=back
+
+=head2 Module options
+
+These options are mutually exclusive, and the script processes
+them in alphabetical order.
+
+=over 4
+
+=item c
+
+Runs a `make clean` in the specified module's directories.
+
+=item i
+
+Installed the specified modules.
+
+=item m
+
+Makes the specified modules.
+
+=item t
+
+Runs a `make test` on the specified modules.
+
+=back
+
+=head2 Examples
+
+ # print a help message
+ cpan -h
+
+ # print the version numbers
+ cpan -v
+
+ # create an autobundle
+ cpan -a
+
+ # recompile modules
+ cpan -r
+
+ # install modules
+ cpan -i Netscape::Booksmarks Business::ISBN
+
+=head1 TO DO
+
+* add options for other CPAN::Shell functions
+autobundle, clean, make, recompile, test
+
+=head1 BUGS
+
+* none noted
+
+=head1 SEE ALSO
+
+Most behaviour, including environment variables and configuration,
+comes directly from CPAN.pm.
+
+=head1 AUTHOR
+
+brian d foy <[EMAIL PROTECTED]>
+
+=cut
+
+use CPAN ();
+use Getopt::Std;
+
+my $VERSION =
+ sprintf "%d.%02d", q$Revision: 1.3 $ =~ m/ (\d+) \. (\d+) /xg;
+
+my $Default = 'default';
+
+my $META_OPTIONS = 'ahvr';
+
+my %CPAN_METHODS = (
+ $Default => 'install',
+ 'c' => 'clean',
+ 'i' => 'install',
+ 'm' => 'make',
+ 't' => 'test',
+ );
+
+my @cpan_options = grep { $_ ne $Default } sort keys %CPAN_METHODS;
+
+my $arg_count = @ARGV;
+my %options;
+
+Getopt::Std::getopts(
+ join( '', @cpan_options, $META_OPTIONS ), \%options );
+
+if( $options{h} )
+ {
+ print STDERR "Printing help message -- ignoring other arguments\n"
+ if $arg_count > 1;
+
+ print STDERR "Use perldoc to read the documentation\n";
+ exit 0;
+ }
+elsif( $options{v} )
+ {
+ print STDERR "Printing version message -- ignoring other arguments\n"
+
+ if $arg_count > 1;
+
+ my $CPAN_VERSION = CPAN->VERSION;
+ print STDERR "cpan script version $VERSION\n" .
+ "CPAN.pm version $CPAN_VERSION\n";
+ exit 0;
+ }
+elsif( $options{a} )
+ {
+ print "Creating autobundle in ", $CPAN::Config->{cpan_home},
+ "/Bundle\n";
+ print STDERR "Creating autobundle -- ignoring other arguments\n"
+ if $arg_count > 1;
+
+ CPAN::Shell->autobundle;
+ exit 0;
+ }
+elsif( $options{r} )
+ {
+ print STDERR "Creating autobundle -- ignoring other arguments\n"
+ if $arg_count > 1;
+
+ CPAN::Shell->recompile;
+ }
+else
+ {
+ my $switch = '';
+
+ foreach my $option ( @cpan_options )
+ {
+ next unless $options{$option};
+ $switch = $option;
+ last;
+ }
+
+ if( not $switch and @ARGV ) { $switch = $Default; }
+ elsif( not $switch and not @ARGV ) { CPAN::shell(); exit 0; }
+ elsif( $switch and not @ARGV )
+ { die "Nothing to $CPAN_METHODS{$switch}!\n"; }
+
+ my $method = $CPAN_METHODS{$switch};
+ die "CPAN.pm cannot $method!\n" unless CPAN::Shell->can( $method );
+
+ foreach my $arg ( @ARGV )
+ {
+ CPAN::Shell->$method( $arg );
+ }
+ }
+
+1;
==== //depot/perl/utils/Makefile#23 (text) ====
Index: perl/utils/Makefile
--- perl/utils/Makefile#22~15658~ Mon Apr 1 07:08:02 2002
+++ perl/utils/Makefile Wed Mar 26 11:55:20 2003
@@ -5,9 +5,9 @@
# Files to be built with variable substitution after miniperl is
# available. Dependencies handled manually below (for now).
-pl = c2ph.PL h2ph.PL h2xs.PL perlbug.PL perldoc.PL perlivp.PL pl2pm.PL splain.PL
perlcc.PL dprofpp.PL libnetcfg.PL piconv.PL enc2xs.PL
-plextract = c2ph h2ph h2xs perlbug perldoc perlivp pl2pm splain perlcc dprofpp
libnetcfg piconv enc2xs
-plextractexe = ./c2ph ./h2ph ./h2xs ./perlbug ./perldoc ./perlivp ./pl2pm ./splain
./perlcc ./dprofpp ./libnetcfg ./piconv ./enc2xs
+pl = c2ph.PL cpan.PL h2ph.PL h2xs.PL perlbug.PL perldoc.PL perlivp.PL pl2pm.PL
splain.PL perlcc.PL dprofpp.PL libnetcfg.PL piconv.PL enc2xs.PL
+plextract = c2ph cpan h2ph h2xs perlbug perldoc perlivp pl2pm splain perlcc dprofpp
libnetcfg piconv enc2xs
+plextractexe = ./c2ph ./cpan ./h2ph ./h2xs ./perlbug ./perldoc ./perlivp ./pl2pm
./splain ./perlcc ./dprofpp ./libnetcfg ./piconv ./enc2xs
all: $(plextract)
@@ -28,6 +28,8 @@
$(PERL) -I../lib [EMAIL PROTECTED]
c2ph: c2ph.PL ../config.sh
+
+cpan: cpan.PL ../config.sh
h2ph: h2ph.PL ../config.sh
==== //depot/perl/utils/cpan.PL#1 (text) ====
Index: perl/utils/cpan.PL
--- /dev/null Tue May 5 13:32:27 1998
+++ perl/utils/cpan.PL Wed Mar 26 11:55:20 2003
@@ -0,0 +1,48 @@
+#!/usr/local/bin/perl
+
+use Config;
+use File::Basename qw(&basename &dirname);
+use Cwd;
+
+# List explicitly here the variables you want Configure to
+# generate. Metaconfig only looks for shell variables, so you
+# have to mention them as if they were shell variables, not
+# %Config entries. Thus you write
+# $startperl
+# to ensure Configure will look for $Config{startperl}.
+
+# This forces PL files to create target in same directory as PL file.
+# This is so that make depend always knows where to find PL derivatives.
+my $origdir = cwd;
+chdir dirname($0);
+my $file = basename($0, '.PL');
+$file .= '.com' if $^O eq 'VMS';
+
+open OUT,">$file" or die "Can't create $file: $!";
+
+print "Extracting $file (with variable substitutions)\n";
+
+# In this section, perl variables will be expanded during extraction.
+# You can use $Config{...} to use Configure variables.
+
+print OUT <<"!GROK!THIS!";
+$Config{startperl}
+ eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
+ if \$running_under_some_shell;
+!GROK!THIS!
+
+use File::Spec;
+
+my $cpan = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "lib", "CPAN",
"bin"), "cpan");
+
+if (open(CPAN, $cpan)) {
+ print OUT <CPAN>;
+ close CPAN;
+} else {
+ die "$0: cannot find '$cpan'\n";
+}
+
+close OUT or die "Can't close $file: $!";
+chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
+exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
+chdir $origdir;
End of Patch.