Changeset 397 in ProjectBuilder
- Timestamp:
- Apr 19, 2008, 1:03:02 AM (17 years ago)
- Location:
- devel/pb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r395 r397 12 12 use strict 'vars'; 13 13 use Getopt::Long qw(:config auto_abbrev no_ignore_case); 14 use Pod::Usage;15 14 use Data::Dumper; 16 15 use English; 17 16 use File::Basename; 18 17 use File::Copy; 19 use File::Path;20 18 use File::stat; 21 19 use File::Temp qw(tempdir); 22 20 use Date::Manip; 23 use Time::localtime qw(localtime);24 21 use POSIX qw(strftime); 25 26 27 # Global variables28 22 use lib qw (lib); 29 23 use ProjectBuilder::Distribution; … … 31 25 use ProjectBuilder::Base; 32 26 27 # Global variables 33 28 my %opts; # CLI Options 34 29 my $action; # action to realize … … 304 299 305 300 my ($projectbuilderver,$projectbuilderrev) = pb_version_init(); 301 302 # Initialize the syntax string 303 304 pb_syntax_init("pb (aka project-builder.org) Version $projectbuilderver-$projectbuilderrev\n"); 306 305 307 306 GetOptions("help|?|h" => \$opts{'h'}, … … 1637 1636 } 1638 1637 1639 sub pb_syntax {1640 1641 my $exit_status = shift || -1;1642 my $verbose_level = shift || 0;1643 1644 my $filehandle = \*STDERR;1645 1646 $filehandle = \*STDOUT if ($exit_status == 0);1647 1648 pod2usage( { -message => "pb (aka project-builder.org) Version $projectbuilderver-$projectbuilderrev\n",1649 -exitval => $exit_status ,1650 -verbose => $verbose_level,1651 -output => $filehandle } );1652 }1653 1654 1638 sub pb_env_init { 1655 1639 … … 1789 1773 1790 1774 pb_log(2,"PBBUILDDIR: $ENV{'PBBUILDDIR'}\n"); 1791 # 1792 # Set temp directory 1793 # 1794 if (not defined $ENV{'TMPDIR'}) { 1795 $ENV{'TMPDIR'}="/tmp"; 1796 } 1797 $ENV{'PBTMP'} = tempdir( "pb.XXXXXXXXXX", DIR => $ENV{'TMPDIR'}, CLEANUP => 1 ); 1775 1776 pb_temp_init(); 1798 1777 pb_log(2,"PBTMP: $ENV{'PBTMP'}\n"); 1799 1778 … … 3199 3178 # If we don't need to do it, or don't have it fake something 3200 3179 if (((not defined $chglog) || (! -f $chglog)) && ($doit ne "yes")) { 3201 my @date =(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());3180 my @date = pb_get_date(); 3202 3181 $date = strftime("%Y-%m-%d", @date); 3203 3182 $ndate = UnixDate($date,"%a", "%b", "%d", "%Y"); -
devel/pb/lib/ProjectBuilder/Base.pm
r396 r397 18 18 use Data::Dumper; 19 19 use Time::localtime qw(localtime); 20 use Pod::Usage; 20 21 use English; 21 22 … … 27 28 # any code which uses this module. 28 29 29 our $debug = 0; 30 our $LOG = \*STDOUT; 30 our $debug = 0; # Global debug level 31 our $LOG = \*STDOUT; # File descriptor of the log file 32 our $synmsg = "Error"; # Global error message 31 33 32 34 our @ISA = qw(Exporter); … … 341 343 =cut 342 344 343 # get content of a file in a variable344 345 sub pb_get_content { 345 346 … … 356 357 } 357 358 359 =item B<pb_syntax_init> 360 361 This function initializes the global variable used by the pb_syntax function. 362 363 The parameter is the message string which will be printed when calling pb_syntax 364 365 =cut 366 367 sub pb_syntax_init { 368 369 $synmsg = shift || "Error"; 370 } 371 372 =item B<pb_syntax> 373 374 This function prints the syntax expected by the application, based on pod2usage, and exits. 375 The first parameter is the return value of the exit. 376 The second parameter is the verbosity as expected by pod2usage. 377 378 Cf: man Pod::Usage 379 380 =cut 381 382 sub pb_syntax { 383 384 my $exit_status = shift || -1; 385 my $verbose_level = shift || 0; 386 387 my $filehandle = \*STDERR; 388 389 $filehandle = \*STDOUT if ($exit_status == 0); 390 391 pod2usage( { -message => $synmsg, 392 -exitval => $exit_status , 393 -verbose => $verbose_level, 394 -output => $filehandle } ); 395 } 396 397 =item B<pb_temp_init> 398 399 This function initializes the environemnt variable PBTMP to a random value. This directory can be safely used during the whole program, it will be removed at the end automatically. 400 401 =cut 402 403 sub pb_temp_init { 404 405 if (not defined $ENV{'TMPDIR'}) { 406 $ENV{'TMPDIR'}="/tmp"; 407 } 408 $ENV{'PBTMP'} = tempdir( "pb.XXXXXXXXXX", DIR => $ENV{'TMPDIR'}, CLEANUP => 1 ); 409 } 410 411 =back 412 413 =head1 WEB SITES 414 415 The main Web site of the project is available at L<http://www.project-builder.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.project-builder.org/>. 416 417 =head1 USER MAILING LIST 418 419 None exists for the moment. 420 421 =head1 AUTHORS 422 423 The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>. 424 425 =head1 COPYRIGHT 426 427 Project-Builder.org is distributed under the GPL v2.0 license 428 described in the file C<COPYING> included with the distribution. 429 430 =cut 431 358 432 1;
Note:
See TracChangeset
for help on using the changeset viewer.