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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.