Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / bin / cpan
CommitLineData
920dae64
AT
1#!/import/archperf/ws/devtools/4/amd64/bin/perl
2 eval 'exec /import/archperf/ws/devtools/4/amd64/bin/perl -S $0 ${1+"$@"}'
3 if $running_under_some_shell;
4#!/usr/bin/perl
5# $Id: cpan,v 1.3 2002/08/30 08:55:15 k Exp $
6use strict;
7
8=head1 NAME
9
10cpan - easily interact with CPAN from the command line
11
12=head1 SYNOPSIS
13
14 # with arguments, installs specified modules
15 cpan module_name [ module_name ... ]
16
17 # with switches, installs modules with extra behavior
18 cpan [-cimt] module_name [ module_name ... ]
19
20 # without arguments, starts CPAN shell
21 cpan
22
23 # without arguments, but some switches
24 cpan [-ahrv]
25
26=head1 DESCRIPTION
27
28This script provides a command interface (not a shell) to CPAN.pm.
29
30=head2 Meta Options
31
32These options are mutually exclusive, and the script processes
33them in this order: [ahvr]. Once the script finds one, it ignores
34the others, and then exits after it finishes the task. The script
35ignores any other command line options.
36
37=over 4
38
39=item -a
40
41Creates the CPAN.pm autobundle with CPAN::Shell->autobundle.
42
43=item -h
44
45Prints a help message.
46
47=item -r
48
49Recompiles dynamically loaded modules with CPAN::Shell->recompile.
50
51=item -v
52
53Print the script version and CPAN.pm version.
54
55=back
56
57=head2 Module options
58
59These options are mutually exclusive, and the script processes
60them in alphabetical order.
61
62=over 4
63
64=item c
65
66Runs a `make clean` in the specified module's directories.
67
68=item i
69
70Installed the specified modules.
71
72=item m
73
74Makes the specified modules.
75
76=item t
77
78Runs a `make test` on the specified modules.
79
80=back
81
82=head2 Examples
83
84 # print a help message
85 cpan -h
86
87 # print the version numbers
88 cpan -v
89
90 # create an autobundle
91 cpan -a
92
93 # recompile modules
94 cpan -r
95
96 # install modules
97 cpan -i Netscape::Booksmarks Business::ISBN
98
99=head1 TO DO
100
101* add options for other CPAN::Shell functions
102autobundle, clean, make, recompile, test
103
104=head1 BUGS
105
106* none noted
107
108=head1 SEE ALSO
109
110Most behaviour, including environment variables and configuration,
111comes directly from CPAN.pm.
112
113=head1 AUTHOR
114
115brian d foy <bdfoy@cpan.org>
116
117=cut
118
119use CPAN ();
120use Getopt::Std;
121
122my $VERSION =
123 sprintf "%d.%02d", q$Revision: 1.3 $ =~ m/ (\d+) \. (\d+) /xg;
124
125my $Default = 'default';
126
127my $META_OPTIONS = 'ahvr';
128
129my %CPAN_METHODS = (
130 $Default => 'install',
131 'c' => 'clean',
132 'i' => 'install',
133 'm' => 'make',
134 't' => 'test',
135 );
136
137my @cpan_options = grep { $_ ne $Default } sort keys %CPAN_METHODS;
138
139my $arg_count = @ARGV;
140my %options;
141
142Getopt::Std::getopts(
143 join( '', @cpan_options, $META_OPTIONS ), \%options );
144
145if( $options{h} )
146 {
147 print STDERR "Printing help message -- ignoring other arguments\n"
148 if $arg_count > 1;
149
150 print STDERR "Use perldoc to read the documentation\n";
151 exit 0;
152 }
153elsif( $options{v} )
154 {
155 print STDERR "Printing version message -- ignoring other arguments\n"
156
157 if $arg_count > 1;
158
159 my $CPAN_VERSION = CPAN->VERSION;
160 print STDERR "cpan script version $VERSION\n" .
161 "CPAN.pm version $CPAN_VERSION\n";
162 exit 0;
163 }
164elsif( $options{a} )
165 {
166 print "Creating autobundle in ", $CPAN::Config->{cpan_home},
167 "/Bundle\n";
168 print STDERR "Creating autobundle -- ignoring other arguments\n"
169 if $arg_count > 1;
170
171 CPAN::Shell->autobundle;
172 exit 0;
173 }
174elsif( $options{r} )
175 {
176 print STDERR "Creating autobundle -- ignoring other arguments\n"
177 if $arg_count > 1;
178
179 CPAN::Shell->recompile;
180 }
181else
182 {
183 my $switch = '';
184
185 foreach my $option ( @cpan_options )
186 {
187 next unless $options{$option};
188 $switch = $option;
189 last;
190 }
191
192 if( not $switch and @ARGV ) { $switch = $Default; }
193 elsif( not $switch and not @ARGV ) { CPAN::shell(); exit 0; }
194 elsif( $switch and not @ARGV )
195 { die "Nothing to $CPAN_METHODS{$switch}!\n"; }
196
197 my $method = $CPAN_METHODS{$switch};
198 die "CPAN.pm cannot $method!\n" unless CPAN::Shell->can( $method );
199
200 foreach my $arg ( @ARGV )
201 {
202 CPAN::Shell->$method( $arg );
203 }
204 }
205
2061;