Changeset 74 in ProjectBuilder for devel/pb/bin/pb


Ignore:
Timestamp:
Sep 1, 2007, 1:56:48 AM (17 years ago)
Author:
Bruno Cornec
Message:

Big renaming to be more perlish
Single module Base contains all routines except when detaching makes sense

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r73 r74  
    2121
    2222# Global variables
    23 use vars qw (%defpkgdir %extpkgdir %version %confparam %filteredfiles %pbrc $debug $LOG $projectbuilderver $projectbuilderrev);
     23use vars qw (%defpkgdir %extpkgdir %filteredfiles %pbrc $debug $LOG);
    2424
    2525$debug = 0;                 # Debug level
    2626$LOG = *STDOUT;             # Where to log
    2727use lib qw (lib);
    28 use ProjectBuilder::common qw (env_init);
    29 use ProjectBuilder::distro qw (distro_init);
    30 use ProjectBuilder::cms;
    31 use ProjectBuilder::changelog qw (changelog);
    32 use ProjectBuilder::Version qw (version_init);
    33 use ProjectBuilder::pb qw (pb_init);
     28use ProjectBuilder::Distribution qw (pb_distro_init);
     29use ProjectBuilder::Changelog qw (pb_changelog);
     30use ProjectBuilder::Version qw (pb_version_init);
     31use ProjectBuilder::Base qw (pb_conf_read pb_cms_init pb_mkdir_p pb_system pb_rm_rf);
    3432
    3533my %opts;                   # CLI Options
     
    4644getopts('hl:p:qr:tv',\%opts);
    4745
    48 version_init();
     46my ($projectbuilderver,$projectbuilderrev) = ("0.5","1"); #pb_version_init();
    4947if (defined $opts{'h'}) {
    50     syntax();
     48    pb_syntax();
    5149    exit(0);
    5250}
     
    7169# Get Action
    7270$action = shift @ARGV;
    73 die syntax() if (not defined $action);
     71die pb_syntax() if (not defined $action);
    7472
    7573# Handle root of the project if defined
     
    7977# Handles project name if any
    8078if (defined $opts{'p'}) {
    81     $ENV{'PBPROJ'} = env_init($opts{'p'});
     79    $ENV{'PBPROJ'} = pb_env_init($opts{'p'});
    8280} else {
    83     $ENV{'PBPROJ'} = env_init();
     81    $ENV{'PBPROJ'} = pb_env_init();
    8482}
    8583
     
    9189    my $ptr = get_pkg();
    9290    @pkgs = @$ptr;
    93     cms_init();
     91    pb_cms_init($ENV{'PBPROJ'});
    9492
    9593    foreach my $pbpkg (@pkgs) {
     
    117115        # Clean up dest if necessary. The export will recreate it
    118116        my $dest = "$ENV{'PBDESTDIR'}/$pbpkg-$pbver";
    119         pbrm_rf($dest) if (-d $dest);
     117        pb_rm_rf($dest) if (-d $dest);
    120118
    121119        # Export CMS tree for the concerned package to dest
     
    126124        my $dir = $defpkgdir{$pbpkg};
    127125        $dir = $extpkgdir{$pbpkg} if (not defined $dir);
    128         pbsystem("$ENV{'PBCMSEXP'} $option $ENV{'PBROOT'}/$dir $dest 1>/dev/null", "Exporting $ENV{'PBROOT'}/$dir");
     126        pb_system("$ENV{'PBCMSEXP'} $option $ENV{'PBROOT'}/$dir $dest 1>/dev/null", "Exporting $ENV{'PBROOT'}/$dir");
    129127
    130128        # Creates a REVISION file
     
    134132
    135133        # Extract cms log history and store it
    136         pbsystem("$ENV{'PBCMSLOG'} $option $ENV{'PBROOT'}/$dir > $dest/$ENV{'PBCMSLOGFILE'}", "Extracting log info");
     134        pb_system("$ENV{'PBCMSLOG'} $option $ENV{'PBROOT'}/$dir > $dest/$ENV{'PBCMSLOGFILE'}", "Extracting log info");
    137135
    138136        my %build;
     
    142140            my ($ndir,$ver) = split(/_/,$d);
    143141            chomp($ver);
    144             my ($ddir, $dver, $dfam, $dtype, $dsuf) = distro_init($ndir,$ver);
     142            my ($ddir, $dver, $dfam, $dtype, $dsuf) = pb_distro_init($ndir,$ver);
    145143            print $LOG "DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $dsuf)."\n" if ($debug >= 1);
    146144            print $LOG "DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n" if ($debug >= 1);
     
    251249        # Prepare the dest directory for archive
    252250        if (-x "$ENV{'PBCONF'}/$pbpkg/pbinit") {
    253             pbsystem("cd $dest ; $ENV{'PBCONF'}/$pbpkg/pbinit","Executing init script $ENV{'PBCONF'}/$pbpkg/pbinit");
     251            pb_system("cd $dest ; $ENV{'PBCONF'}/$pbpkg/pbinit","Executing init script $ENV{'PBCONF'}/$pbpkg/pbinit");
    254252        }
    255253
     
    257255        chdir "$ENV{'PBDESTDIR'}" || die "Unable to change dir to $ENV{'PBDESTDIR'}";
    258256        # Possibility to look at PBSRC to guess more the filename
    259         pbsystem("tar cfpz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed");
     257        pb_system("tar cfpz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed");
    260258        print $LOG "Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n" if ($debug >= 0);
    261259        # Keep track of what is generated for default
     
    269267    if (not defined $vertag) {
    270268        if (-f $pbrc{$ENV{'PBPROJ'}}) {
    271             my $pbroot = pb_init($pbrc{$ENV{'PBPROJ'}},"pbroot");
     269            my $pbroot = pb_conf_read($pbrc{$ENV{'PBPROJ'}},"pbroot");
    272270            # There is only one line normaly
    273             $vertag = (keys %$pbroot)[0]
    274             $ENV{'PBROOT'} = (values %$pbroot)[0]
     271            $vertag = (keys %$pbroot)[0];
     272            $ENV{'PBROOT'} = (values %$pbroot)[0];
    275273        } else {
    276274            die "Unable to open $pbrc{$ENV{'PBPROJ'}}\nYou may want to precise as parameter version-tag";
     
    284282
    285283    # Get the running distro to build on
    286     my ($ddir, $dver, $dfam, $dtype, $dsuf) = distro_init();
     284    my ($ddir, $dver, $dfam, $dtype, $dsuf) = pb_distro_init();
    287285    print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $dsuf))."\n" if ($debug >= 1);
    288286
     
    300298            foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
    301299                if (! -d "$ENV{'PBBUILDDIR'}/$d") {
    302                 pbmkdir_p("$ENV{'PBBUILDDIR'}/$d") || die "Please ensure that you can write into $ENV{'PBBUILDDIR'} to create $d\nSolution: setup _topdir in your ~/.rpmmacros or\nchown the $ENV{'PBBUILDDIR'} directory to your uid";
     300                pb_mkdir_p("$ENV{'PBBUILDDIR'}/$d") || die "Please ensure that you can write into $ENV{'PBBUILDDIR'} to create $d\nSolution: setup _topdir in your ~/.rpmmacros or\nchown the $ENV{'PBBUILDDIR'} directory to your uid";
    303301                }
    304302            }
     
    315313            foreach my $f (@specfile) {
    316314                if ($f =~ /\.spec$/) {
    317                     pbsystem("rpmbuild -ba $f","Building package with $f");
     315                    pb_system("rpmbuild -ba $f","Building package with $f");
    318316                    last;
    319317                }
    320318            }
    321319        } elsif ($dtype eq "tgz") {
    322             pbmkdir_p("$ENV{'PBBUILDDIR'}/install") if (! -d "$ENV{'PBBUILDDIR'}/install");
     320            pb_mkdir_p("$ENV{'PBBUILDDIR'}/install") if (! -d "$ENV{'PBBUILDDIR'}/install");
    323321        } elsif ($dtype eq "ebuild") {
    324             pbmkdir_p("$ENV{'PBBUILDDIR'}/portage") if (! -d "$ENV{'PBBUILDDIR'}/portage");
     322            pb_mkdir_p("$ENV{'PBBUILDDIR'}/portage") if (! -d "$ENV{'PBBUILDDIR'}/portage");
    325323        } else {
    326324        }
     
    328326} else {
    329327    print $LOG "'$action' is not available\n";
    330     syntax();
     328    pb_syntax();
    331329}
    332330
     
    343341
    344342print $LOG "DEBUG: From $f to $destfile\n" if ($debug >= 1);
    345 pbmkdir_p(dirname($destfile)) if (! -d dirname($destfile));
     343pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));
    346344open(DEST,"> $destfile") || die "Unable to create $destfile";
    347345open(FILE,"$f") || die "Unable to open $f: $!";
     
    360358            my $p = $defpkgdir{$pbpkg};
    361359            $p = $extpkgdir{$pbpkg} if (not defined $p);
    362             changelog($dtype, $pbpkg, $pbtag, $dsuf, $p, \*DEST);
     360            pb_changelog($dtype, $pbpkg, $pbtag, $dsuf, $p, \*DEST);
    363361            $tmp = "";
    364362        }
     
    400398my @files;
    401399
    402 pbsystem("tar xfpz $src $dir >/dev/null","Extracting build files");
     400pb_system("tar xfpz $src $dir >/dev/null","Extracting build files");
    403401opendir(DIR,"$dir") || die "Unable to open directory $dir";
    404402foreach my $f (readdir(DIR)) {
     
    410408closedir(DIR);
    411409# Not enough but still a first cleanup
    412 pbrm_rf("$dir");
     410pb_rm_rf("$dir");
    413411return(@files);
    414412}
    415413
    416 sub syntax {
     414sub pb_syntax {
    417415
    418416    print "pb (aka project-builder) Version $projectbuilderver-$projectbuilderrev\n";
Note: See TracChangeset for help on using the changeset viewer.