Changeset 315


Ignore:
Timestamp:
Feb 10, 2008, 6:40:37 AM (12 years ago)
Author:
bruno
Message:

Backup of local dev. cms2pkg compiles but doesn't work and even remove the SVN :-(
pb_log added

Location:
devel/pb
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r314 r315  
    2323use ProjectBuilder::Distribution qw (pb_distro_init);
    2424use ProjectBuilder::Version qw (pb_version_init);
    25 use ProjectBuilder::Base qw (pb_conf_read pb_conf_get pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout);
     25use ProjectBuilder::Base qw (pb_conf_read pb_conf_get pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_filter_file_inplace pb_cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout pb_get_date pb_log pb_log_init);
    2626
    2727my %opts;                   # CLI Options
     
    3636my %pbtag;                  # per package
    3737my $pbrev;                  # Global REVISION variable
    38 my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
     38my @date=pb_get_date();
    3939my $pbdate = strftime("%Y-%m-%d", @date);
    40 my $pbdatecvs = strftime("%Y-%m-%d %H:%M:%S", @date);
    4140my $debug = 0;
    4241my $pbaccount;              # Login to use to connect to the VM
     
    6463    $debug = 0  if ($debug == -1);
    6564    }
     65pb_log_init($debug, $LOG);
     66
    6667# Handles test option
    6768if (defined $opts{'t'}) {
     
    106107# And get global params
    107108if (defined $opts{'p'}) {
    108     ($debug,$LOG, $filteredfiles, $supfiles, $defpkgdir, $extpkgdir)
     109    ($filteredfiles, $supfiles, $defpkgdir, $extpkgdir)
    109110    = pb_env_init($opts{'p'},$pbinit);
    110111} else {
    111     ($debug,$LOG, $filteredfiles, $supfiles, $defpkgdir, $extpkgdir)
     112    ($filteredfiles, $supfiles, $defpkgdir, $extpkgdir)
    112113    = pb_env_init(undef,$pbinit);
    113114}
    114115
    115 print $LOG "Project: $ENV{'PBPROJ'}\n" if ($debug >= 0);
    116 print $LOG "Action: $action\n" if ($debug >= 0);
     116pb_log(0,"Project: $ENV{'PBPROJ'}\n");
     117pb_log(0,"Action: $action\n");
    117118
    118119# Keep those project values to store them at the end each time
     
    154155} elsif ($action =~ /^clean$/) {
    155156} else {
    156     print $LOG "'$action' is not available\n";
     157    pb_log(0,"\'$action\' is not available\n");
    157158    pb_syntax();
    158159}
     
    162163    my $ptr = pb_get_pkg($defpkgdir,$extpkgdir);
    163164    @pkgs = @$ptr;
    164     my $cms=pb_cms_init($ENV{'PBPROJ'});
     165    my ($scheme,$uri)=pb_cms_init($ENV{'PBPROJ'});
    165166
    166167    my ($pkgv, $pkgt) = pb_conf_get_if("pkgver","pkgtag");
     
    188189
    189190        $pbrev = $ENV{'PBREVISION'};
    190         print $LOG "\n";
    191         print $LOG "Management of $pbpkg $pbver-$pbtag (rev $pbrev)\n";
     191        pb_log(2,"\n");
     192        pb_log(2,"Management of $pbpkg $pbver-$pbtag (rev $pbrev)\n");
    192193        die "Unable to get env var PBDESTDIR" if (not defined $ENV{'PBDESTDIR'});
    193194        # Clean up dest if necessary. The export will recreate it
     
    202203        my $dir = $defpkgdir->{$pbpkg};
    203204        $dir = $extpkgdir->{$pbpkg} if (not defined $dir);
    204         print "def:".Dumper($defpkgdir)." ext: ".Dumper($extpkgdir)." \n" if ($debug >= 1);
    205         pb_cms_export($cms,$pbdatecvs,"$ENV{'PBROOT'}/$dir",$dest);
     205        pb_log(2,"def:".Dumper($defpkgdir)." ext: ".Dumper($extpkgdir)." \n");
     206
     207        # If it isn't a flat CMS, then we have the choice to export subdir
     208        $dir = "$uri/$dir" if ($ENV{'PBREVISION'} ne "flat");
     209        pb_cms_export($scheme,"$dir",$dest);
    206210
    207211        # Get project info on authors and log file
     
    216220        # Extract cms log history and store it
    217221        if ((defined $chglog) && (! -f "$dest/NEWS")) {
    218             print $LOG "Generating NEWS file from $chglog\n";
     222            pb_log(2,"Generating NEWS file from $chglog\n");
    219223            copy($chglog,"$dest/NEWS") || die "Unable to create $dest/NEWS";
    220224        }
    221         pb_cms_log($cms,"$ENV{'PBROOT'}/$dir",$dest,$chglog,$authors);
     225        pb_cms_log($scheme,$dir,$dest,$chglog,$authors);
    222226
    223227        my %build;
    224228
    225         my ($ptr) = pb_conf_get("vmlist");
     229        my ($ptr) = pb_conf_get_if("vmlist","chrootlist");
    226230        foreach my $d (split(/,/,$ptr->{$ENV{'PBPROJ'}})) {
    227             my ($name,$ver) = split(/_/,$d);
    228             chomp($ver);
     231            my ($name,$ver,$arch) = split(/-/,$d);
     232            chomp($arch);
    229233            my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($name,$ver);
    230             print $LOG "DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf)."\n" if ($debug >= 1);
    231             print $LOG "DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n" if ($debug >= 1);
     234            pb_log(2,"DEBUG: distro tuple: ".Dumper($ddir, $dver, $dfam, $dtype, $pbsuf)."\n");
     235            pb_log(2,"DEBUG Filtering PBDATE => $pbdate, PBTAG => $pbtag, PBVER => $pbver\n");
    232236
    233237            # Filter build files from the less precise up to the most with overloading
     
    236240            # Find all build files first relatively to PBROOT
    237241            # Find also all specific files referenced in the .pb conf file
    238             my %bfiles;
    239             my %pkgfiles;
    240             print $LOG "DEBUG dir: $ENV{'PBCONF'}/$pbpkg\n" if ($debug >= 1);
     242            my %bfiles = {};
     243            my %pkgfiles = {};
     244            pb_log(2,"DEBUG dir: $ENV{'PBCONF'}/$pbpkg\n");
    241245            $build{"$ddir-$dver"} = "yes";
    242             if (-d "$ENV{'PBCONF'}/$pbpkg/$dtype") {
    243                 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dtype") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dtype: $!";
    244                 foreach my $f (readdir(BDIR)) {
    245                     next if ($f =~ /^\./);
    246                     $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dtype/$f";
    247                     $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    248                     if (defined $supfiles->{$pbpkg}) {
    249                         $pkgfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dtype/$f" if ($f =~ /$supfiles->{$pbpkg}/);
    250                     }
    251                 }
    252                 closedir(BDIR);
    253             } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$dfam") {
    254                 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$dfam") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$dfam: $!";
    255                 foreach my $f (readdir(BDIR)) {
    256                     next if ($f =~ /^\./);
    257                     $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dfam/$f";
    258                     $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    259                     if (defined $supfiles->{$pbpkg}) {
    260                         $pkgfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$dfam/$f" if ($f =~ /$supfiles->{$pbpkg}/);
    261                     }
    262                 }
    263                 closedir(BDIR);
    264             } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir") {
    265                 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir: $!";
    266                 foreach my $f (readdir(BDIR)) {
    267                     next if ($f =~ /^\./);
    268                     $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir/$f";
    269                     $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    270                     if (defined $supfiles->{$pbpkg}) {
    271                         $pkgfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir/$f" if ($f =~ /$supfiles->{$pbpkg}/);
    272                     }
    273                 }
    274                 closedir(BDIR);
    275             } elsif (-d "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") {
    276                 opendir(BDIR,"$ENV{'PBCONF'}/$pbpkg/$ddir-$dver") || die "Unable to open dir $ENV{'PBCONF'}/$pbpkg/$ddir-$dver: $!";
    277                 foreach my $f (readdir(BDIR)) {
    278                     next if ($f =~ /^\./);
    279                     $bfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver/$f";
    280                     $bfiles{$f} =~ s~$ENV{'PBROOT'}~~;
    281                     if (defined $supfiles->{$pbpkg}) {
    282                         $pkgfiles{$f} = "$ENV{'PBCONF'}/$pbpkg/$ddir-$dver/$f" if ($f =~ /$supfiles->{$pbpkg}/);
    283                     }
    284                 }
    285                 closedir(BDIR);
     246
     247            if (-d "$ENV{'PBROOT'}/$pbpkg/$dtype") {
     248                pb_list_bfiles("$ENV{'PBROOT'}/$pbpkg/$dtype",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
     249            } elsif (-d "$ENV{'PBROOT'}/$pbpkg/$dfam") {
     250                pb_list_bfiles("$ENV{'PBROOT'}/$pbpkg/$dfam",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
     251            } elsif (-d "$ENV{'PBROOT'}/$pbpkg/$ddir") {
     252                pb_list_bfiles("$ENV{'PBROOT'}/$pbpkg/$ddir",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
     253            } elsif (-d "$ENV{'PBROOT'}/$pbpkg/$ddir-$dver") {
     254                pb_list_bfiles("$ENV{'PBROOT'}/$pbpkg/$ddir-$dver",$pbpkg,\%bfiles,\%pkgfiles,$supfiles);
    286255            } else {
    287256                $build{"$ddir-$dver"} = "no";
    288257                next;
    289258            }
    290             print $LOG "DEBUG bfiles: ".Dumper(\%bfiles)."\n" if ($debug >= 1);
     259            pb_log(2,"DEBUG bfiles: ".Dumper(\%bfiles)."\n");
    291260
    292261            # Get all filters to apply
     
    301270            }
    302271        }
    303         if ($debug >= 0) {
    304             my @found;
    305             my @notfound;
    306             foreach my $b (keys %build) {
    307                 push @found,$b if ($build{$b} =~ /yes/);
    308                 push @notfound,$b if ($build{$b} =~ /no/);
    309             }
    310             print $LOG "Build files generated for ".join(',',@found)."\n";
    311             print $LOG "No Build files found for ".join(',',@notfound)."\n" if (@notfound);
    312         }
     272        my @found;
     273        my @notfound;
     274        foreach my $b (keys %build) {
     275            push @found,$b if ($build{$b} =~ /yes/);
     276            push @notfound,$b if ($build{$b} =~ /no/);
     277        }
     278        pb_log(0,"Build files generated for ".join(',',@found)."\n");
     279        pb_log(0,"No Build files found for ".join(',',@notfound)."\n") if (@notfound);
    313280        # Get the generic filter (all.pbf) and
    314281        # apply those to the non-build files including those
     
    321288        if (defined $filteredfiles->{$pbpkg}) {
    322289            foreach my $f (split(/,/,$filteredfiles->{$pbpkg})) {
    323                 pb_filter_file("$ENV{'PBROOT'}/$dir/$f",$ptr,"$dest/$f",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);
     290                pb_filter_file_inplace($ptr,"$dest/$f",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);
    324291                $liste = "$f $liste";
    325292            }
    326293        }
    327         print $LOG "Files ".$liste."have been filtered\n";
     294        pb_log(2,"Files ".$liste."have been filtered\n");
    328295
    329296        # Prepare the dest directory for archive
    330         if (-x "$ENV{'PBCONF'}/$pbpkg/pbinit") {
    331             pb_filter_file("$ENV{'PBCONF'}/$pbpkg/pbinit",$ptr,"$ENV{'PBTMP'}/pbinit",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);
     297        if (-x "$ENV{'PBROOT'}/$pbpkg/pbinit") {
     298            pb_filter_file("$ENV{'PBROOT'}/$pbpkg/pbinit",$ptr,"$ENV{'PBTMP'}/pbinit",$ENV{'PBPROJ'},$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);
    332299            chmod 0755,"$ENV{'PBTMP'}/pbinit";
    333             pb_system("cd $dest ; $ENV{'PBTMP'}/pbinit","Executing init script from $ENV{'PBCONF'}/$pbpkg/pbinit");
     300            pb_system("cd $dest ; $ENV{'PBTMP'}/pbinit","Executing init script from $ENV{'PBROOT'}/$pbpkg/pbinit");
    334301        }
    335302
     
    338305        # Possibility to look at PBSRC to guess more the filename
    339306        pb_system("tar cfz $pbpkg-$pbver.tar.gz $pbpkg-$pbver","Creating $pbpkg tar files compressed");
    340         print $LOG "Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n" if ($debug >= 0);
     307        pb_log(2,"Under $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz\n");
    341308
    342309        # Keep track of what is generated by default
     
    354321        }
    355322
    356         print $LOG "DEBUG pkg: ".Dumper($pkg)."\n" if ($debug >= 1);
     323        pb_log(2,"DEBUG pkg: ".Dumper($pkg)."\n");
    357324        open(PKG,"> $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb") || die "Unable to create $ENV{'PBDESTDIR'}/$pbprojver-$pbprojtag.pb";
    358325        foreach my $p (keys %$pkg) {
     
    374341    # Get the running distro to build on
    375342    my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init();
    376     print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n" if ($debug >= 1);
     343    pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n");
    377344
    378345    # Get content saved in cms2build
     
    392359
    393360        my $src="$ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz";
    394         print $LOG "Source file: $src\n" if ($debug >= 0);
    395 
    396         print $LOG "Working directory: $ENV{'PBBUILDDIR'}\n" if ($debug >= 0);
     361        pb_log(2,"Source file: $src\n");
     362
     363        pb_log(2,"Working directory: $ENV{'PBBUILDDIR'}\n");
    397364        if ($dtype eq "rpm") {
    398365            foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
     
    402369            }
    403370
     371            # Remove in case a previous link/file was there
    404372            unlink "$ENV{'PBBUILDDIR'}/SOURCES/".basename($src);
    405373            symlink "$src","$ENV{'PBBUILDDIR'}/SOURCES/".basename($src) || die "Unable to symlink $src in $ENV{'PBBUILDDIR'}/SOURCES";
     
    408376            @specfile = pb_extract_build_files($src,"$pbpkg-$pbver/pbconf/$ddir-$dver/","$ENV{'PBBUILDDIR'}/SPECS");
    409377
    410             print $LOG "specfile: ".Dumper(\@specfile)."\n" if ($debug >= 1);
     378            pb_log(2,"specfile: ".Dumper(\@specfile)."\n");
    411379            # set LANGUAGE to check for correct log messages
    412380            $ENV{'LANGUAGE'}="C";
    413             #system("ls -R $ENV{'PBBUILDDIR'}") if ($debug >= 1);
    414381            foreach my $f (@specfile) {
    415382                if ($f =~ /\.spec$/) {
     
    432399            pb_system("dpkg-buildpackage -us -uc -rfakeroot","Building package");
    433400            $made="$made $pbpkg"."_*.deb $pbpkg"."_*.dsc $pbpkg"."_*.tar.gz";
     401            if (-f "/usr/bin/lintian") {
     402                pb_system("lintian $made","Checking validity of debs with lintian");
     403            }
    434404        } elsif ($dtype eq "ebuild") {
    435405            my @ebuildfile;
     
    528498    }
    529499    my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($odir,$over);
    530     print $LOG "DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n" if ($debug >= 1);
     500    pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n");
    531501
    532502    # Get content saved in cms2build
     
    575545    }
    576546
    577     print $LOG "Sources handled ($cmt): $src\n" if ($debug >= 0);
     547    pb_log(2,"Sources handled ($cmt): $src\n");
    578548    my ($sshhost,$sshlogin,$sshdir,$sshport,$vmtmout,$testver) = pb_conf_get($host,$login,$dir,$port,$tmout,"testver");
    579549    my $mac = "$sshlogin->{$ENV{'PBPROJ'}}\@$sshhost->{$ENV{'PBPROJ'}}";
     
    723693        }
    724694        if (! -f "$vem") {
    725             print "Unable to find VM $vem\n";
     695            pb_log(0,"Unable to find VM $vem\n");
    726696        } else {
    727697            pb_system("$cmd &","Launching the VM $vem");
     
    730700        }
    731701    } else {
    732         print "Found an existing VM $vem (pid $veexist)\n";
     702        pb_log(0,"Found an existing VM $vem (pid $veexist)\n");
    733703    }
    734704    return($veexist,$vepid);
     
    798768        }
    799769        if (! -f "$vmm") {
    800             print "Unable to find VM $vmm\n";
     770            pb_log(0,"Unable to find VM $vmm\n");
    801771        } else {
    802772            pb_system("$cmd &","Launching the VM $vmm");
     
    805775        }
    806776    } else {
    807         print "Found an existing VM $vmm (pid $vmexist)\n";
     777        pb_log(0,"Found an existing VM $vmm (pid $vmexist)\n");
    808778    }
    809779    return($vmexist,$vmpid);
     
    864834
    865835    die "-V Version parameter needed" if ((not defined $newver) || ($newver eq ""));
    866     my $cms=pb_cms_init($ENV{'PBPROJ'});
    867     if ($cms->{$ENV{'PBPROJ'}} ne "svn") {
     836    my $scheme=pb_cms_init($ENV{'PBPROJ'});
     837    if ($scheme ne "svn") {
    868838        die "Only SVN is supported at the moment";
    869839    }
    870     my $res = pb_cms_isdiff($cms);
     840    my $res = pb_cms_isdiff($scheme);
    871841    die "You need to have no differences before creating a new version" if ($res != 0);
    872     my $cmsurl = pb_cms_getinfo($cms,$ENV{'PBROOT'});
     842    my $cmsurl = pb_cms_getinfo($scheme,$ENV{'PBROOT'},"URL:");
    873843    my $newurl = dirname($cmsurl)."/$newver";
    874     pb_cms_copy($cms,$cmsurl,$newurl);
    875     pb_cms_checkout($cms,$newurl,"$ENV{'PBROOT'}/../$newver");
     844    pb_cms_copy($scheme,$cmsurl,$newurl);
     845    pb_cms_checkout($scheme,$newurl,"$ENV{'PBROOT'}/../$newver");
    876846    my $oldver=basename($cmsurl);
    877847    open(FILE,"$ENV{'PBROOT'}/../$newver/pbconf/$ENV{'PBPROJ'}.pb") || die "Unable to open $ENV{'PBROOT'}/../$newver/pbconf/$ENV{'PBPROJ'}.pb";
     
    884854    close(OUT);
    885855    rename("$ENV{'PBROOT'}/../$newver/pbconf/$ENV{'PBPROJ'}.pb.new","$ENV{'PBROOT'}/../$newver/pbconf/$ENV{'PBPROJ'}.pb");
    886     pb_cms_checkin($cms,"$ENV{'PBROOT'}/../$newver");
     856    pb_cms_checkin($scheme,"$ENV{'PBROOT'}/../$newver");
    887857}
    888858
     
    905875    @pkgs = @ARGV;
    906876}
    907 print $LOG "Packages: ".join(',',@pkgs)."\n" if ($debug >= 0);
     877pb_log(2,"Packages: ".join(',',@pkgs)."\n");
    908878return(\@pkgs);
    909879}
     
    928898    $all = 1;
    929899}
    930 print $LOG "VMs: $ENV{'PBVM'}\n";
     900pb_log(2,"VMs: $ENV{'PBVM'}\n");
    931901@vm = split(/,/,$ENV{'PBVM'});
    932902return(\@vm,$all);
     
    969939    next if ($f =~ /^\./);
    970940    move("$dir/$f","$ddir") || die "Unable to move $dir/$f to $ddir";
    971     print $LOG "mv $dir/$f $ddir\n" if ($debug >= 1);
     941    pb_log(2,"mv $dir/$f $ddir\n");
    972942    push @files,"$ddir/$f";
    973943}
     
    978948}
    979949
     950sub pb_list_bfiles {
     951
     952my $dir = shift;
     953my $pbpkg = shift;
     954my $bfiles = shift;
     955my $pkgfiles = shift;
     956my $supfiles = shift;
     957
     958opendir(BDIR,"$dir") || die "Unable to open dir $dir: $!";
     959foreach my $f (readdir(BDIR)) {
     960    next if ($f =~ /^\./);
     961    $bfiles->{$f} = "$dir/$f";
     962    $bfiles->{$f} =~ s~$ENV{'PBROOT'}~~;
     963    if (defined $supfiles->{$pbpkg}) {
     964        $pkgfiles->{$f} = "$dir/$f" if ($f =~ /$supfiles->{$pbpkg}/);
     965    }
     966}
     967closedir(BDIR);
     968}
     969
    980970sub pb_syntax {
    981971
  • devel/pb/lib/ProjectBuilder/Base.pm

    r314 r315  
    1010use File::Basename;
    1111use File::Path;
     12use File::Copy;
    1213use File::Temp qw /tempdir/;
    1314use Data::Dumper;
     15use POSIX qw(strftime);
    1416
    1517use ProjectBuilder::Changelog qw (pb_changelog);
    1618
    1719$ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc";
     20
     21my $debug = 0;
     22my $LOG = \*STDOUT;
    1823
    1924sub pb_env_init {
     
    2429my $tag;
    2530
    26 # For the moment not dynamic
    27 my $debug = 0;                  # Debug level
    28 my $LOG = *STDOUT;              # Where to log
    29 
    3031#
    3132# Check project name
     
    4445#
    4546my ($pbconf) = pb_conf_read("$ENV{'PBETC'}","pbconf");
    46 print "DEBUG pbconf: ".Dumper($pbconf)."\n" if ($debug >= 1);
     47pb_log(2,"DEBUG pbconf: ".Dumper($pbconf)."\n");
    4748
    4849my %pbconf = %$pbconf;
     
    5051    # Take the first as the default project
    5152    $proj = (keys %pbconf)[0];
    52     if (($debug >= 0) and (defined $proj)) {
    53         print $LOG "WARNING: using $proj as default project as none has been specified\n"
    54         print $LOG "Please create a pbconf reference for project $proj in $ENV{'PBETC'}\nif you want to use another project\n";
     53    if (defined $proj) {
     54        pb_log(2,"WARNING: using $proj as default project as none has been specified\n");
     55        pb_log(2,"Please create a pbconf reference for project $proj in $ENV{'PBETC'}\nif you want to use another project\n");
    5556    }
    5657}
     
    6970# Tree will look like this:
    7071#
    71 #             maint pbdir                                              dev dir (optional)
    72 #                  |                                                      |
    73 #            ------------------------                              --------------------
    74 #            |                      |                              |                  |
    75 #         pbproj1                pbproj2                        pbproj1           pbproj2
    76 #            |                                                     |
    77 #  ---------------------------------------------              ----------
    78 #  *      *        |       |        |          |              *        *
    79 # 1.0    dev    pbconf    ...     build     delivery         1.0      dev
    80 #                  |                |          |
    81 #               ------                        pbrc
     72#             maint pbdir                            PBDIR               dev dir (optional)   PBDEVDIR
     73#                  |                                                        |
     74#            ------------------------                                --------------------
     75#            |                      |                                |                  |
     76#         pbproj1                pbproj2             PBPROJ       pbproj1           pbproj2   PBDEVPROJ
     77#            |                                                       |
     78#  ---------------------------------------------                ----------
     79#  *      *        |       |        |          |                *        *
     80# 1.0    dev    pbconf    ...     build     delivery PBCONF    1.0      dev                   PBDEVROOT
     81#                  |                           |     PBDESTDIR
     82#               ------                        pbrc   PBBUILDDIR
    8283#               |    |       
    83 #              1.0  dev     
     84#              1.0  dev                              PBROOT
    8485#                    |
    8586#               ----------------------------------
     
    101102if (not defined $ENV{'PBDIR'}) {
    102103    if (not defined ($pbdir{$ENV{'PBPROJ'}})) {
    103         print $LOG "WARNING: no pbdir defined, using /var/cache\n";
    104         print $LOG "Please create a pbdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\nif you want to use another directory\n";
     104        pb_log(2,"WARNING: no pbdir defined, using /var/cache\n");
     105        pb_log(2,"Please create a pbdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\nif you want to use another directory\n");
    105106    }
    106107    # That's always the environment variable that will be used
     
    157158
    158159my ($scheme, $account, $host, $port, $path) = pb_get_uri($pbconf{$ENV{'PBPROJ'}});
    159 my $cms = { $ENV{'PBPROJ'} => $scheme };
    160160
    161161if ((not -d "$ENV{'PBCONF'}") || (defined $pbinit)) {
    162     pb_cms_checkout($cms,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'});
     162    pb_cms_checkout($scheme,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'});
    163163} else {
    164     my $cmsurl = pb_cms_getinfo($cms,$ENV{'PBCONF'});
     164    my $cmsurl = pb_cms_getinfo($scheme,$ENV{'PBCONF'},"URL:");
    165165    if ($cmsurl !~ /^$scheme/) {
    166166        pb_rm_rf("$ENV{'PBCONF'}");
    167         pb_cms_checkout($cms,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'});
     167        pb_cms_checkout($scheme,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'});
    168168    } elsif ($cmsurl ne $pbconf{$ENV{'PBPROJ'}}) {
    169169        # The local content doesn't correpond to the repository
    170         print $LOG "ERROR: Inconsistency detected:\n";
    171         print $LOG "* $ENV{'PBCONF'} refers to $cmsurl but\n";
    172         print $LOG "* $ENV{'PBETC'} refers to $pbconf{$ENV{'PBPROJ'}}\n";
     170        pb_log(2,"ERROR: Inconsistency detected:\n");
     171        pb_log(2,"* $ENV{'PBCONF'} refers to $cmsurl but\n");
     172        pb_log(2,"* $ENV{'PBETC'} refers to $pbconf{$ENV{'PBPROJ'}}\n");
    173173        die "Project $ENV{'PBPROJ'} is not Project-Builder compliant.";
    174174    } else {
     
    181181    if (! -f ("$ENV{'PBDESTDIR'}/pbrc")) {
    182182        opendir(DIR,$ENV{'PBCONF'}) || die "Unable to open directory $ENV{'PBCONF'}: $!";
    183         my maxmtime = 0;
     183        my $maxmtime = 0;
    184184        foreach my $d (readdir(DIR)) {
    185185            next if ($d =~ /^\./);
     
    194194        }
    195195        closedir(DIR);
    196         print $LOG "WARNING: no pbroot defined, using $ENV{'PBROOT'}\n";
    197         print $LOG "Please -r release if you want to use another release\n";
     196        pb_log(2,"WARNING: no pbroot defined, using $ENV{'PBROOT'}\n");
     197        pb_log(2,"Please -r release if you want to use another release\n");
    198198    } else {
    199199        my ($pbroot) = pb_conf_read_if("$ENV{'PBDESTDIR'}/pbrc","pbroot");
    200200        # That's always the environment variable that will be used
    201         $ENV{'PBROOT'} = $pbroot{$ENV{'PBPROJ'}};
     201        $ENV{'PBROOT'} = $pbroot->{$ENV{'PBPROJ'}};
    202202    }
    203203} else {
    204204    # transform in full path if relative
    205     $ENV{'PBROOT'} = "$ENV{'PBCONF'}/$ENV{'PBROOT'}" if ($ENV{'PBROOT'} !~ |/|);
     205    $ENV{'PBROOT'} = "$ENV{'PBCONF'}/$ENV{'PBROOT'}" if ($ENV{'PBROOT'} !~ /\//);
    206206}
    207207
     
    220220    # Project version and tag (optional)
    221221    my ($extpkgdir, $version, $filteredfiles, $supfiles, $pkgv, $pkgt) = pb_conf_get_if("extpkgdir","version","filteredfiles","supfiles","projver","projtag");
    222     print "DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n" if ($debug >= 1);
    223     print "DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n" if ($debug >= 1);
    224     print "DEBUG: version: ".Dumper($version)."\n" if ($debug >= 1);
    225     print "DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n" if ($debug >= 1);
    226     print "DEBUG: supfiles: ".Dumper($supfiles)."\n" if ($debug >= 1);
     222    pb_log(2,"DEBUG: defpkgdir: ".Dumper($defpkgdir)."\n");
     223    pb_log(2,"DEBUG: extpkgdir: ".Dumper($extpkgdir)."\n");
     224    pb_log(2,"DEBUG: version: ".Dumper($version)."\n");
     225    pb_log(2,"DEBUG: filteredfiles: ".Dumper($filteredfiles)."\n");
     226    pb_log(2,"DEBUG: supfiles: ".Dumper($supfiles)."\n");
    227227    # Global
    228228    %defpkgdir = %$defpkgdir;
     
    718718        pb_mkdir_p("$ENV{'PBROOT'}/pkg1/pbfilter") || die "Unable to create $ENV{'PBROOT'}/pkg1/pbfilter";
    719719
    720         print "\nDo not to forget to commit the pbconf directory in your CMS if needed\n";
    721         print "After having renamed the pkg1 directory to your package's name      \n\n";
     720        pb_log(2,"\nDo not to forget to commit the pbconf directory in your CMS if needed\n");
     721        pb_log(2,"After having renamed the pkg1 directory to your package's name      \n\n");
    722722    } else {
    723723        die "Unable to open $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb";
     
    725725}
    726726umask 0022;
    727 return($debug,$LOG, \%filteredfiles, \%supfiles, \%defpkgdir, \%extpkgdir);
     727return(\%filteredfiles, \%supfiles, \%defpkgdir, \%extpkgdir);
    728728}
    729729
     
    748748my $cmt=shift || $cmd;
    749749
    750 print "$cmt... ";
     750pb_log(2,"$cmt... ");
    751751#system("$cmd 2>&1 > $ENV{'PBTMP'}/system.log");
    752752system($cmd);
    753753if ($? == -1) {
    754     print "failed to execute ($cmd) : $!\n";
     754    pb_log(2,"failed to execute ($cmd) : $!\n");
    755755    pb_display_file("$ENV{'PBTMP'}/system.log");
    756756} elsif ($? & 127) {
    757     printf "child ($cmd) died with signal %d, %s coredump\n", ($? & 127),  ($? & 128) ? 'with' : 'without';
     757    pb_log(2, "child ($cmd) died with signal ".($? & 127).", ".($? & 128) ? 'with' : 'without'." coredump\n");
    758758    pb_display_file("$ENV{'PBTMP'}/system.log");
    759759} elsif ($? == 0) {
    760     print "OK\n";
     760    pb_log(2,"OK\n");
    761761} else {
    762     printf "child ($cmd) exited with value %d\n", $? >> 8;
     762    pb_log(2, "child ($cmd) exited with value ".($? >> 8)."\n");
    763763    pb_display_file("$ENV{'PBTMP'}/system.log");
    764764}
     
    785785my @return = pb_conf_get_if(@param);
    786786
    787 die "No params found for $ENV{'PBPROJ'}" if (not defined @return);
     787die "No params found for $ENV{'PBPROJ'}" if (not @return);
    788788
    789789foreach my $i (0..$#param) {
     
    807807my $p2;
    808808
    809 #print "DEBUG: param1: ".Dumper(@ptr1)."\n"; # if ($debug >= 1);
    810 #print "DEBUG: param2: ".Dumper(@ptr2)."\n"; # if ($debug >= 1);
     809pb_log(2,"DEBUG: param1: ".Dumper(@ptr1)."\n");
     810pb_log(2,"DEBUG: param2: ".Dumper(@ptr2)."\n");
    811811
    812812foreach my $i (0..$#param) {
     
    842842    }
    843843    $ptr1[$i] = $p1;
    844     #print "DEBUG: param ptr1: ".Dumper(@ptr1)."\n"; # if ($debug >= 1);
     844    pb_log(2,"DEBUG: param ptr1: ".Dumper(@ptr1)."\n");
    845845}
    846846return(@ptr1);
     
    870870my %h;
    871871
    872 my $debug = 0;
    873 
    874872open(CONF,$conffile) || die "Unable to open $conffile";
    875873while(<CONF>) {
    876874    if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) {
    877         print "DEBUG: 1:$1 2:$2 3:$3\n" if ($debug >= 1);
     875        pb_log(2,"DEBUG: 1:$1 2:$2 3:$3\n");
    878876        $h{$1}{$2}=$3;
    879877    }
     
    884882    push @ptr,$h{$param};
    885883}
    886 print "DEBUG: h:".Dumper(%h)." param:".Dumper(@param)." ptr:".Dumper(@ptr)."\n" if ($debug >= 1);
     884pb_log(2,"DEBUG: h:".Dumper(%h)." param:".Dumper(@param)." ptr:".Dumper(@ptr)."\n");
    887885return(@ptr);
    888886}
     
    898896         $uri =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|;
    899897my ($account,$host,$port) = $authority =~ m|(?:([^\@]+)\@)?([^:]+)(:(?:[0-9]+))?|;
    900 print "DEBUG: scheme:$scheme ac:$account host:$host port:$port path:$path\n" if ($debug >= 1);
     898pb_log(2,"DEBUG: scheme:$scheme ac:$account host:$host port:$port path:$path\n");
    901899return($scheme, $account, $host, $port, $path);
    902900}
     
    907905
    908906my $proj = shift || undef;
    909 my $ret;
    910 
    911 my ($cms) = pb_conf_get("cms");
    912 
    913 if ($cms->{$proj} eq "svn") {
    914     $ENV{'PBREVISION'}=`(cd "$ENV{'PBROOT'}" ; svnversion .)`;
    915     chomp($ENV{'PBREVISION'});
     907
     908# Use the project URI
     909my ($uri) = pb_conf_get("pburl");
     910
     911# Extract values from that URI
     912my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri->{$ENV{'PBPROJ'}});
     913
     914if ($scheme =~ /^svn/) {
     915    $ENV{'PBREVISION'}= pb_cms_getinfo($scheme,$uri->{$ENV{'PBPROJ'}},"Revision:");
     916    #$ENV{'PBREVISION'}=`(cd "$ENV{'PBDEVDIR'}" ; svnversion .)`;
    916917    $ENV{'PBCMSLOGFILE'}="svn.log";
    917 } elsif ($cms->{$proj} eq "flat") {
     918} elsif (($scheme eq "file") || ($scheme eq "ftp") || ($scheme eq "http")) {
    918919    $ENV{'PBREVISION'}="flat";
    919920    $ENV{'PBCMSLOGFILE'}="flat.log";
    920 } elsif ($cms->{$proj} eq "cvs") {
     921} elsif ($scheme eq "cvs") {
    921922    # Way too slow
    922923    #$ENV{'PBREVISION'}=`(cd "$ENV{'PBROOT'}" ; cvs rannotate  -f . 2>&1 | awk '{print \$1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`;
     
    930931    $ENV{'CVS_RSH'} = $cvsrsh->{$proj} if (defined $cvsrsh->{$proj});
    931932} else {
    932     die "cms $cms->{$proj} unknown";
    933 }
    934 return($cms);
     933    die "cms $scheme unknown";
     934}
     935
     936#
     937#if (not defined $scheme) {
     938    # We're an upstream guy
     939    # Try to make it easy for us
     940    #pb_log(2,"WARNING: Assuming a local project under $ENV{'PBDIR'}/$ENV{'PBPROJ'}:\n");
     941    #pb_log(2,"If not, pleaase setup a pbproj entry in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb\n");
     942    #return("");
     943#}
     944
     945return($scheme,$uri->{$ENV{'PBPROJ'}});
     946}
     947
     948sub pb_get_date {
     949   
     950return(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
    935951}
    936952
    937953sub pb_cms_export {
    938 my $cms = shift;
    939 my $pbdate = shift || undef;
     954
     955my $scheme = shift;
    940956my $source = shift;
    941957my $destdir = shift;
     
    943959my $tmp1;
    944960
    945 if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
     961my @date = pb_get_date();
     962
     963if ($scheme eq "svn") {
    946964    if (-d $source) {
    947965        $tmp = $destdir;
     
    950968    }
    951969    pb_system("svn export $source $tmp","Exporting $source from SVN to $tmp");
    952 } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
     970} elsif ($scheme eq "flat") {
    953971    if (-d $source) {
    954972        $tmp = $destdir;
     
    957975    }
    958976    pb_system("cp -a $source $tmp","Exporting $source from DIR to $tmp");
    959 } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
     977} elsif ($scheme eq "cvs") {
    960978    my $dir=dirname($destdir);
    961979    my $base=basename($destdir);
     
    970988    # CVS needs a relative path !
    971989    my ($cvsroot) = pb_conf_get("cvsroot");
     990    my $pbdate = strftime("%Y-%m-%d %H:%M:%S", @date);
    972991    pb_system("cd $dir ; cvs -d $cvsroot->{$ENV{'PBPROJ'}} export -D \"$pbdate\" -d $base $tmp1","Exporting $source from CVS to $destdir");
    973992} else {
    974     die "cms $cms->{$ENV{'PBPROJ'}} unknown";
     993    die "cms $scheme unknown";
    975994}
    976995}
     
    9811000my $authors=shift;
    9821001my $dest=shift;
    983 my $cms=shift;
     1002my $scheme=shift;
    9841003
    9851004return if ($authors eq "/dev/null");
     
    9921011    chomp($gcos);
    9931012    print DAUTH "$gcos";
    994     if (defined $cms) {
    995         print DAUTH " ($nick under $cms)\n";
     1013    if (defined $scheme) {
     1014        print DAUTH " ($nick under $scheme)\n";
    9961015    } else {
    9971016        print DAUTH "\n";
     
    10031022
    10041023sub pb_cms_log {
    1005 my $cms = shift;
     1024my $scheme = shift;
    10061025my $pkgdir = shift;
    10071026my $dest = shift;
     
    10091028my $authors = shift;
    10101029
    1011 pb_create_authors($authors,$dest,$cms->{$ENV{'PBPROJ'}});
    1012 
    1013 if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
     1030pb_create_authors($authors,$dest,$scheme);
     1031
     1032if ($scheme eq "svn") {
    10141033    if (! -f "$dest/ChangeLog") {
    10151034        if (-x "/usr/bin/svn2cl") {
    1016             pb_system("/usr/bin/svn2cl --group-by-day --authors=$authors -i -o $dest/ChangeLog $pkgdir","Generating ChangeLog from SVN");
     1035            pb_system("/usr/bin/svn2cl --group-by-day --authors=$authors -i -o $dest/ChangeLog $pkgdir","Generating ChangeLog from SVN with svn2cl");
    10171036        } else {
    10181037            # To be written from pbcl
     
    10201039        }
    10211040    }
    1022 } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
     1041} elsif ($scheme eq "flat") {
    10231042    if (! -f "$dest/ChangeLog") {
    10241043        pb_system("echo ChangeLog for $pkgdir > $dest/ChangeLog","Empty ChangeLog file created");
    10251044    }
    1026 } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
     1045} elsif ($scheme eq "cvs") {
    10271046    my $tmp=basename($pkgdir);
    10281047    # CVS needs a relative path !
    10291048    if (! -f "$dest/ChangeLog") {
    10301049        if (-x "/usr/bin/cvs2cl") {
    1031             pb_system("/usr/bin/cvs2cl --group-by-day -U $authors -f $dest/ChangeLog $pkgdir","Generating ChangeLog from CVS");
     1050            pb_system("/usr/bin/cvs2cl --group-by-day -U $authors -f $dest/ChangeLog $pkgdir","Generating ChangeLog from CVS with cvs2cl");
    10321051        } else {
    10331052            # To be written from pbcl
     
    10361055    }
    10371056} else {
    1038     die "cms $cms->{$ENV{'PBPROJ'}} unknown";
     1057    die "cms $scheme unknown";
    10391058}
    10401059}
    10411060
    10421061sub pb_cms_getinfo {
    1043 my $cms = shift;
     1062my $scheme = shift;
    10441063my $dir = shift;
    1045 my $url = "";
     1064my $info = shift || "URL:";
     1065
     1066my $res = "";
    10461067my $void = "";
    10471068
    1048 if ($cms->{$ENV{'PBPROJ'}} =~ /^svn/) {
     1069if ($scheme =~ /^svn/) {
    10491070    open(PIPE,"LANGUAGE=C svn info $dir |") || return("");
    10501071    while (<PIPE>) {
    1051         ($void,$url) = split(/^URL:/) if (/^URL:/);
     1072        ($void,$res) = split(/^$info/) if (/^$info/);
    10521073    }
    10531074    close(PIPE);
    1054     chomp($url);
    1055 } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
    1056 } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
     1075    chomp($res);
     1076} elsif ($scheme eq "flat") {
     1077} elsif ($scheme eq "cvs") {
    10571078} else {
    1058     die "cms $cms->{$ENV{'PBPROJ'}} unknown";
    1059 }
    1060 return($url);
     1079    die "cms $scheme unknown";
     1080}
     1081return($res);
    10611082}
    10621083
    10631084sub pb_cms_copy {
    1064 my $cms = shift;
     1085my $scheme = shift;
    10651086my $oldurl = shift;
    10661087my $newurl = shift;
    10671088
    1068 if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
     1089if ($scheme eq "svn") {
    10691090    pb_system("svn copy -m \"Creation of $newurl from $oldurl\" $oldurl $newurl","Copying $oldurl to $newurl ");
    1070 } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
    1071 } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
     1091} elsif ($scheme eq "flat") {
     1092} elsif ($scheme eq "cvs") {
    10721093} else {
    1073     die "cms $cms->{$ENV{'PBPROJ'}} unknown";
     1094    die "cms $scheme unknown";
    10741095}
    10751096}
    10761097
    10771098sub pb_cms_checkout {
    1078 my $cms = shift;
     1099my $scheme = shift;
    10791100my $url = shift;
    10801101my $destination = shift;
    10811102
    1082 if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
     1103if ($scheme =~ /^svn/) {
    10831104    pb_system("svn co $url $destination","Checking $url to $destination ");
    1084 } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
    1085 } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
     1105} elsif ($scheme eq "flat") {
     1106} elsif ($scheme eq "cvs") {
    10861107} else {
    1087     die "cms $cms->{$ENV{'PBPROJ'}} unknown";
     1108    die "cms $scheme unknown";
    10881109}
    10891110}
    10901111
    10911112sub pb_cms_checkin {
    1092 my $cms = shift;
     1113my $scheme = shift;
    10931114my $dir = shift;
    10941115
    10951116my $ver = basename($dir);
    1096 if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
     1117if ($scheme eq "svn") {
    10971118    pb_system("svn ci -m \"Updated to $ver\" $dir","Checking in $dir");
    10981119    pb_system("svn up $dir","Updating $dir");
    1099 } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
    1100 } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
     1120} elsif ($scheme eq "flat") {
     1121} elsif ($scheme eq "cvs") {
    11011122} else {
    1102     die "cms $cms->{$ENV{'PBPROJ'}} unknown";
     1123    die "cms $scheme unknown";
    11031124}
    11041125}
    11051126
    11061127sub pb_cms_isdiff {
    1107 my $cms = shift;
    1108 
    1109 if ($cms->{$ENV{'PBPROJ'}} eq "svn") {
     1128my $scheme = shift;
     1129
     1130if ($scheme eq "svn") {
    11101131    open(PIPE,"svn diff $ENV{'PBROOT'} |") || die "Unable to get svn diff from $ENV{'PBROOT'}";
    11111132    my $l = 0;
     
    11141135    }
    11151136    return($l);
    1116 } elsif ($cms->{$ENV{'PBPROJ'}} eq "flat") {
    1117 } elsif ($cms->{$ENV{'PBPROJ'}} eq "cvs") {
     1137} elsif ($scheme eq "flat") {
     1138} elsif ($scheme eq "cvs") {
    11181139} else {
    1119     die "cms $cms->{$ENV{'PBPROJ'}} unknown";
     1140    die "cms $scheme unknown";
    11201141}
    11211142}
     
    11261147
    11271148sub pb_get_filters {
    1128 
    1129 # For the moment not dynamic
    1130 my $debug = 0;                  # Debug level
    1131 my $LOG = *STDOUT;              # Where to log
    11321149
    11331150my @ffiles;
     
    11721189}
    11731190if (@ffiles) {
    1174     print $LOG "DEBUG ffiles: ".Dumper(\@ffiles)."\n" if ($debug >= 1);
     1191    pb_log(2,"DEBUG ffiles: ".Dumper(\@ffiles)."\n");
    11751192
    11761193    foreach my $f (@ffiles) {
     
    11841201
    11851202        $ptr = $h{"filter"};
    1186         print $LOG "DEBUG f:".Dumper($ptr)."\n" if ($debug >= 1);
     1203        pb_log(2,"DEBUG f:".Dumper($ptr)."\n");
    11871204    }
    11881205} else {
     
    12131230my $chglog = shift || undef;
    12141231
    1215 # For the moment not dynamic
    1216 my $debug = 0;                  # Debug level
    1217 my $LOG = *STDOUT;              # Where to log
    1218 
    1219 print $LOG "DEBUG: From $f to $destfile\n" if ($debug >= 1);
     1232pb_log(2,"DEBUG: From $f to $destfile\n");
    12201233pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));
    12211234open(DEST,"> $destfile") || die "Unable to create $destfile";
     
    12251238    foreach my $s (keys %filter) {
    12261239        # Process single variables
    1227         print $LOG "DEBUG filter{$s}: $filter{$s}\n" if ($debug >= 1);
     1240        pb_log(2,"DEBUG filter{$s}: $filter{$s}\n");
    12281241        my $tmp = $filter{$s};
    12291242        next if (not defined $tmp);
    12301243        # Expand variables if any single one found
    1231         print $LOG "DEBUG tmp: $tmp\n" if ($debug >= 1);
     1244        pb_log(2,"DEBUG tmp: $tmp\n");
    12321245        if ($tmp =~ /\$/) {
    12331246            eval { $tmp =~ s/(\$\w+)/$1/eeg };
     
    12451258close(FILE);
    12461259close(DEST);
     1260}
     1261
     1262# Function which applies filter on files (external call)
     1263sub pb_filter_file_inplace {
     1264
     1265my $ptr=shift;
     1266my %filter=%$ptr;
     1267my $destfile=shift;
     1268my $pbproj=shift;
     1269my $pbpkg=shift;
     1270my $pbver=shift;
     1271my $pbtag=shift;
     1272my $pbrev=shift;
     1273my $pbdate=shift;
     1274my $pbpackager=shift;
     1275
     1276my $cp = "$ENV{'PBTMP'}/".basename($destfile);
     1277copy($destfile,$cp) || die "Unable to create $cp";
     1278
     1279pb_filter_file($cp,$ptr,$destfile,$pbproj,$pbpkg,$pbver,$pbtag,$pbrev,$pbdate,$pbpackager);
     1280unlink $cp;
    12471281}
    12481282
     
    12621296my $pbpackager=shift;
    12631297
    1264 # For the moment not dynamic
    1265 my $debug = 0;                  # Debug level
    1266 my $LOG = *STDOUT;              # Where to log
    1267 
    1268 print $LOG "DEBUG: From $f to $destfile\n" if ($debug >= 1);
     1298pb_log(2,"DEBUG: From $f to $destfile\n");
    12691299pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile));
    12701300open(DEST,"> $destfile") || die "Unable to create $destfile";
     
    12741304    foreach my $s (keys %filter) {
    12751305        # Process single variables
    1276         print $LOG "DEBUG filter{$s}: $filter{$s}\n" if ($debug > 1);
     1306        pb_log(2,"DEBUG filter{$s}: $filter{$s}\n");
    12771307        my $tmp = $filter{$s};
    12781308        next if (not defined $tmp);
     
    12891319}
    12901320
     1321sub pb_log_init {
     1322
     1323$debug = shift || 0;
     1324$LOG = shift || \*STDOUT;
     1325
     1326}
     1327
     1328sub pb_log {
     1329
     1330my $dlevel = shift;
     1331my $msg = shift;
     1332
     1333print $LOG "$msg\n" if ($dlevel >= $debug);
     1334}
    12911335
    129213361;
  • devel/pb/lib/ProjectBuilder/Changelog.pm

    r285 r315  
    4242
    4343if (((not defined $chglog) || (! -f $chglog)) && ($doit eq "yes")) {
    44     #print "No ChangeLog file ($chglog) for $pkg\n";
     44    #pb_log(2,"No ChangeLog file ($chglog) for $pkg\n";
    4545    print $OUTPUT "\n";
    4646    return;
     
    9595    chomp($date);
    9696    $date =~ s/\(([0-9-]+)\)/$1/;
    97     #print "**$date**\n";
     97    #pb_log(2,"**$date**\n";
    9898    $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
    9999    $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
    100     #print "**$ndate**\n";
     100    #pb_log(2,"**$ndate**\n";
    101101
    102102    if (($dtype eq "rpm") || ($dtype eq "fc")) {
  • devel/pb/lib/ProjectBuilder/Distribution.pm

    r287 r315  
    212212        my $found = 0;
    213213        my $ptr = $distro_similar{$d};
    214         #print $LOG "amb: ".Dumper($ptr)."\n" if ($debug >= 1);
     214        #pb_log(2,$LOG "amb: ".Dumper($ptr)."\n" if ($debug >= 1);
    215215        $release = "unknown";
    216216        foreach my $dd (@$ptr) {
    217             #print $LOG "check $dd\n" if ($debug >= 1);
     217            #pb_log(2,$LOG "check $dd\n" if ($debug >= 1);
    218218            # Try to check pattern
    219219            if (defined $distro_match{$dd}) {
    220                 #print $LOG "cmp: $distro_match{$dd} - vs - $tmp\n" if ($debug >= 1);
     220                #pb_log(2,$LOG "cmp: $distro_match{$dd} - vs - $tmp\n" if ($debug >= 1);
    221221                ($release) = $tmp =~ m/$distro_match{$dd}/m;
    222222                if ((defined $release) && ($release ne "unknown")) {
Note: See TracChangeset for help on using the changeset viewer.