Gentoo Archives: gentoo-perl

From: antoine.raillon@××××××.net
To: gentoo-perl@l.g.o
Subject: [gentoo-perl] r33 - in trunk: bin extra-docs
Date: Mon, 16 May 2005 12:39:09
Message-Id: 20050516123828.419638280DF@gredin.dragou.net
1 Author: mcummings
2 Date: 2005-05-16 14:38:27 +0200 (Mon, 16 May 2005)
3 New Revision: 33
4
5 Modified:
6 trunk/bin/g-cpan.pl
7 trunk/extra-docs/Changes
8 trunk/extra-docs/g-cpan.pl.1
9 Log:
10 updates and cleaning
11
12 Modified: trunk/bin/g-cpan.pl
13 ===================================================================
14 --- trunk/bin/g-cpan.pl 2005-05-15 18:16:39 UTC (rev 32)
15 +++ trunk/bin/g-cpan.pl 2005-05-16 12:38:27 UTC (rev 33)
16 @@ -7,10 +7,10 @@
17 # modules to use - these will need to be marked as
18 # dependencies, and installable by portage
19 use strict;
20 -use diagnostics;
21 use File::Spec;
22 use File::Path;
23 use File::Basename;
24 +use File::Copy;
25 use Term::ANSIColor;
26 use Digest::MD5;
27
28 @@ -57,7 +57,7 @@
29 Getopt::Long::Configure("bundling");
30
31 # Init all options (has to be done to perform the 'sum test' later)
32 -my ( $verbose, $search, $install, $upgrade, $list, $pretend, $ask, $noclean ) = ( 0, 0, 0, 0, 0, 0, 0, 0 );
33 +my ( $verbose, $search, $install, $upgrade, $list, $pretend, $ask ) = ( 0, 0, 0, 0, 0, 0, 0 );
34
35 #Get & Parse them
36 GetOptions(
37 @@ -68,7 +68,6 @@
38 'list|l' => \$list,
39 'pretend|p' => \$pretend,
40 'ask|a' => \$ask,
41 - 'noclean|n' => \$noclean,
42 'help|h' => sub { exit_usage(); }
43 )
44 or exit_usage();
45 @@ -129,7 +128,7 @@
46 CPAN::Shell->m("/$expr/");
47 }
48
49 - clean_the_mess() unless $noclean;
50 + clean_up();
51 exit;
52 }
53
54 @@ -164,15 +163,31 @@
55 }
56
57 # Create the ebuild in PORTDIR_OVERLAY, if it is defined and exists
58 -if ( $OVERLAYS[0] ) {
59 - $tmp_overlay_dir = $OVERLAYS[0];
60 - if ($verbose) {
61 - print_info ("Setting $tmp_overlay_dir as the PORTDIR_OVERLAY for this session.");
62 +# Part of this is to find an overlay the user running this session can actually write to
63 +
64 +# o_reset will be used to catch if went through all of the overlay dirs successfully -
65 +# open to better ways :) mcummings
66 +my $o_reset = 1;
67 +
68 +foreach my $o_dir (@OVERLAYS) {
69 + # See if we can create a file
70 + if (open (TMP,">$o_dir/g-cpan-test") ) {
71 + close(TMP);
72 + unlink("$o_dir/g-cpan-test");
73 + $tmp_overlay_dir = $o_dir;
74 + $o_reset = 0;
75 + if ($verbose) { print_info ("Setting $tmp_overlay_dir as the PORTDIR_OVERLAY for this session.") }
76 + last;
77 }
78 }
79 +if ($o_reset > 0) {
80 + print_err("You don't have permission to work in any of the list overlays.");
81 + print_err("Please run $prog as a user with sufficient permissions.");
82 + exit();
83 +}
84
85 # Grab the whole available arches list, to include them later in ebuilds
86 -print "Grabbing arch list" if $verbose;
87 +print_info ("Grabbing arch list") if $verbose;
88 my $arches = do {
89 open my $tmp, "<$PORTAGE_DIR/profiles/arch.list"
90 or fatal(ERR_OPEN_READ, "$PORTAGE_DIR/profiles/arch.list", $!);
91 @@ -221,7 +236,7 @@
92 }
93
94 if($install or $upgrade) {
95 - clean_up() unless $noclean;
96 + clean_up();
97 }
98
99 exit;
100 @@ -277,10 +292,6 @@
101 sub get_gcpans {
102 my @g_list;
103 foreach my $sdir ( grep { -d $_ } ( @PORTAGE_DEV_PERL, @OVERLAY_PERLS ) ) {
104 - # FIXME Sniper
105 - # Do we really need regexp here ?
106 - # Yes - this is potentially a large list of dirs, and we only want the ones containing the tail perl-gcpan
107 - # - mcummings
108 if ( basename($sdir) eq "perl-gcpan" ) {
109 print_info ("OVERLAY: $sdir") if $list;
110 # FIXME Sniper
111 @@ -503,7 +514,7 @@
112 # FIXME Sniper
113 # OH MY GOD !
114 unless ( -f "$PORTAGE_DISTDIR/$localfile" ) {
115 - system( '/bin/mv', '-f', $localfile, $PORTAGE_DISTDIR );
116 + move("$localfile", "$PORTAGE_DISTDIR");
117 }
118
119 push @ebuild_list, "perl-gcpan/$dir";
120 @@ -587,7 +598,7 @@
121
122 create_ebuild( $obj, $dir, $file, $build_dir, $prereq_pm, $md5string );
123 unless ( -f "$PORTAGE_DISTDIR/$localfile" ) {
124 - system( '/bin/mv', '-f', $localfile, $PORTAGE_DISTDIR );
125 + move("$localfile", "$PORTAGE_DISTDIR");
126 }
127 push @ebuild_list, "perl-gcpan/$dir";
128 }
129 @@ -793,18 +804,16 @@
130
131 # cab - Simple useful sub. returns md5 hexdigest of the given argument.
132 # awaits a file name.
133 -# FIXME cab : add a test (if -f $file) ?
134 sub file_md5sum {
135 - my ($file) = @_;;
136 + my ($file) = @_;
137 + if (-f $file) {
138 print_info ("Computing MD5 Sum of $file") if $verbose;
139
140 open DIGIFILE, $file or fatal(ERR_OPEN_READ, $file, $!);
141 my $md5digest = Digest::MD5->new->addfile(*DIGIFILE)->hexdigest;
142 - # FIXME Sniper
143 - # here, check the md5sum
144 close DIGIFILE;
145 -
146 - return $md5digest;
147 + return $md5digest if $md5digest;
148 + }
149 }
150
151 # In order to parse strange but allowed constructions,
152 @@ -831,28 +840,15 @@
153
154 # cab - Takes care of system's sanity
155 # should try to see if it can be merged with clean_up()
156 -sub clean_the_mess {
157 - if ($verbose) {
158 - print_info ("Now cleaning up the system of all the junk we put in !");
159 - }
160 - if ($needs_cpan_stub) {
161 - unlink "$ENV{HOME}/.cpan/CPAN/MyConfig.pm";
162 -
163 - #add something here to take care of the .cpan dir, if not empty
164 - }
165 -}
166 -
167 # TODO Sniper
168 # maybee put this in END {} block
169 sub clean_up {
170
171 - #Probably don't need to do this, but for sanity's sake, we reset this var
172 - # $ENV{'PORTDIR_OVERLAY'} = $OVERLAYS[0];
173 -
174 - if ($needs_cpan_stub) { unlink "$ENV{HOME}/.cpan/CPAN/MyConfig.pm" }
175 -
176 #Clean out the /tmp tree we were using
177 - rmtree( ["$tmp_overlay_dir"] ) if ( !$OVERLAYS[0] );
178 + #I know this looks weird, but since clean_up is invoked on a search, where OVERLAYS isn't ever defined,
179 + # we first need to see if it exists, then need to remove only if it has content (the old exists vs. defined)
180 + if (@OVERLAYS) { rmtree( ["$tmp_overlay_dir"] ) if ( scalar(@OVERLAYS) > 0 ) }
181 + rmtree( ["$ENV{HOME}/.cpan/build"]) if ( -d "$ENV{HOME}/.cpan/build" );
182 }
183
184 # cab - nice help message ! ;)
185 @@ -877,9 +873,6 @@
186 This command generates a list of the Perl modules and ebuilds
187 handled by $prog.
188
189 -${green}--noclean,-n${reset}
190 - Don't clean up temporary areas after running install or upgrade.
191 -
192 ${green}--pretend,-p${reset}
193 Pretend (show actions, but don't emerge). This still generates
194 new ebuilds.
195
196 Modified: trunk/extra-docs/Changes
197 ===================================================================
198 --- trunk/extra-docs/Changes 2005-05-15 18:16:39 UTC (rev 32)
199 +++ trunk/extra-docs/Changes 2005-05-16 12:38:27 UTC (rev 33)
200 @@ -1,3 +1,9 @@
201 +16/05/2005 - mcummings
202 +
203 +- Checks for write privs in overlays and choosing the correct overlay based on that
204 +- cleaned up the multiple cleanup blocks
205 +- Updated the man pages. Left out cab's and sniper's email in case they didn't want them published (so fill it in if you do :) )
206 +
207 15/05/2005 - mcummings
208
209 - Added check to make sure @ebuild_list had contents before trying to run emerge - less chance of emerge just junking out on us.
210
211 Modified: trunk/extra-docs/g-cpan.pl.1
212 ===================================================================
213 --- trunk/extra-docs/g-cpan.pl.1 2005-05-15 18:16:39 UTC (rev 32)
214 +++ trunk/extra-docs/g-cpan.pl.1 2005-05-16 12:38:27 UTC (rev 33)
215 @@ -1,33 +1,106 @@
216 .TH "G-CPAN.PL" "1" "Feb 2004" "Portage 2.0.51" "Portage"
217 .SH NAME
218 -g-cpan.pl \- install CPAN-provided Perl modules using Gentoo's Portage
219 +g-cpan \- install CPAN-provided Perl modules using Gentoo's Portage
220 .SH SYNOPSIS
221 -\fBg-cpan.pl\fR [\ \fB\-v\fR\ ] <\fImodule-name\fR>
222 +\fBg-cpan.pl\fR
223 +[\ \fB\-a\fR\ | \fB\--ask\fR\ ]
224 +[\ \fB\-i\fR\ | \fB\--install\fR\ ]
225 +[\ \fB\-l\fR\ | \fB\--list \fR\ ]
226 +[\ \fB\-p\fR\ | \fB\--pretend \fR\ ]
227 +[\ \fB\-s\fR\ | \fB\--search \fR\ ]
228 +[\ \fB\-u\fR\ | \fB\--upgrade \fR\ ]
229 +[\ \fB\-v\fR\ | \fB\--verbose\fR\ ]
230 +<\fImodule-name\fR>
231 .SH "DESCRIPTION"
232 -.B g-cpan.pl
233 +.IX HEADER "DESCRIPTION"
234 +.B g-cpan
235 is a perl script that installs a CPAN module (including its
236 dependencies) using Gentoo's Portage. It saves dependency information and
237 -stored files as if they were installed through a regular ebuild.
238 +stored files as if they were installed through a regular ebuild.
239
240 -The first time you run \fBg-cpan.pl\fR, it will ask you to setup your CPAN
241 -environment. Most users can agree with the defaults asked.
242 +.SH "CPAN CONFIGURATION"
243 +.IX HEADER "CPAN CONFIGURATION"
244 +
245 +\fB~/.cpan/CPAN/MyConfig.pm\fR
246 +
247 +\fB/path/to/perl/CPAN/Config.pm\fR
248 +
249 +When you run \fBg-cpan\fR, it will check for two configuration files. If you are root, it will check for the presense of an already configured CPAN under your perl install path. If CPAN is not configured, or you are not root, g-cpan will create a generic configuration for CPAN in ~/.cpan/CPAN/ called MyConfig.pm. You can modify this file as needed at any time.
250 +
251 +The CPAN configuration file is used for interacting with CPAN, determining what modules are available, what modules are needed, and performing all basic CPAN functions.
252 +
253 +.SH "G-CPAN AND OVERLAYS"
254 +.IX HEADER "G-CPAN AND OVERLAYS"
255 +
256 +\fBg-cpan\fR is now overlay "friendly." \fBg-cpan\fR will scan both the overlays provided in your make.conf
257 +as well as any you have set via environment variables, to help determine its course of action. If you have
258 +defined overlays, \fBg-cpan\fR will use the first overlay in your list that the user running it can write to.
259 +Any ebuilds generated by \fBg-cpan\fR will be stored in this overlay for future use (such as upgrading).
260 +
261 +If no overlays are defined, or the user operating \fBg-cpan\fR cannot write to an overlay, then anything generated will be written to a temporary space and wiped on exit.
262 +
263 .SH "ARGUMENTS"
264 -.B -v
265 +.IX HEADER "ARGUMENTS"
266 +
267 +.IP "\fB\-a,\-\-ask\fR" 4
268 +.IX Item "-a,--ask"
269 +Pass the "ask" argument to portage. This will cause portage to prompt you to confirm your installation prior to issuing an emerge
270 +
271 +.IP "\fB\-i,\-\-install\fR" 4
272 +.IX Item "-i,--install"
273 +Install the (list of) modules provided.
274 +
275 +.IP "\fB\-l,\-\-list\fR" 4
276 +.IX Item "-l,--list"
277 +List ebuilds that have been generated by g-cpan and reside in your overlay.
278 +
279 +.IP "\fB\-p,\-\-pretend\fR" 4
280 +.IX Item "-p,--pretend"
281 +Create ebuilds as needed for the (list of) modules provided, but don't perform the actual emerge.
282 +
283 +.IP "\fB\-s,\-\-search\fR" 4
284 +.IX Item "-s,--search"
285 +Search CPAN for the provided module.
286 +
287 +.IP "\fB\-u,\-\-upgrade\fR" 4
288 +.IX Item "-u,--upgrade"
289 +Attempt to upgrade any ebuilds generated by g-cpan to newer versions. This option will create new ebuilds for those that exist in your overlay already. If a module name is given, it will attempt to only upgrade the requested module. If no arguments are given, all modules in your g-cpan overlay will be checked.
290 +
291 +.IP "\fB\-v,\-\-verbose\fR" 4
292 +.IX Item "-v,--verbose"
293 Enable verbose mode for more feedback on the step by step processes that
294 g-cpan is running
295 -.SH "EXAMPLES"
296 -Here we install Jabber::RPC
297
298 -# \fBg-cpan.pl Jabber::RPC\fR
299 +.SH "USAGE"
300 +.IX HEADER "USAGE"
301 +
302 +.IP "Here we install Jabber::RPC" 4
303 +# \fBg-cpan -i Jabber::RPC\fR
304 +
305 +.IP "Performing a search" 4
306 +# \fBg-cpan -s Clone::Any\fR
307 +
308 +.IP "Upgrading overlay from g-cpan" 4
309 +# \fBg-cpan -u\fR
310 +
311 +.IP "Upgrading specifc ebuild in overlay from g-cpan" 4
312 +# \fBg-cpan -u Mickey-Mouse\fR
313 +
314 .SH "AUTHORS"
315 +mcummings <mcummings@g.o>
316 +.br
317 +cab
318 +.br
319 +sniper
320 +.br
321 +beu <beu@g.o>
322 +.br
323 J Robert Ray <jrray@g.o> (g-cpan.pl)
324 .br
325 RAC <rac@g.o>
326 .br
327 -mcummings <mcummings@g.o>
328 -.br
329 -Sven Vermeulen <swift@g.o> (manpage)
330 +Sven Vermeulen <swift@g.o> (Original manpage)
331 .SH "REPORTING BUGS"
332 -Please report bugs via http://bugs.gentoo.org/
333 +Please report bugs via http://bugs.gentoo.org/ or https://bugs.gentoo.org/
334 .SH "CVS HEADER"
335 -$Header: /var/cvsroot/gentoo/users/mcummings/g-cpan/g-cpan-0.12/man/g-cpan.pl.1,v 1.1 2005/04/30 21:44:15 mcummings Exp $
336 +$Header: $
337
338
339 --
340 gentoo-perl@g.o mailing list

Replies

Subject Author
Réf. : [gentoo-perl] r33 - in trunk: bin extra-docs antoine.raillon@××××.com