Ignore:
Timestamp:
Feb 22, 2008, 4:07:41 AM (12 years ago)
Author:
bruno
Message:

Improvements in cms2build for SVN but still not finished.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/lib/ProjectBuilder/Base.pm

    r323 r327  
    3232
    3333our @ISA = qw(Exporter);
    34 our @EXPORT = qw(pb_env_init pb_conf_read pb_conf_read_if pb_conf_get pb_conf_get_if 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 pb_get_pkg $debug $LOG);
     34our @EXPORT = qw(pb_env_init pb_conf_read pb_conf_read_if pb_conf_get pb_conf_get_if 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 pb_get_pkg pb_cms_compliant $debug $LOG);
    3535
    3636$ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc";
     
    188188
    189189#
    190 # Check pbconf compliance
    191 #
    192 
    193 my ($pbconfdir) = pb_conf_get_if("pbconfdir");
    194 my %pbconfdir = %$pbconfdir;
    195 
    196 if ((defined $pbconfdir) && (defined $pbconfdir{$ENV{'PBPROJ'}})) {
    197     # That's always the environment variable that will be used
    198     $ENV{'PBCONF'} = $pbconfdir{$ENV{'PBPROJ'}};
    199 } else {
    200     pb_log(0,"WARNING: no pbconfdir defined, using $ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf\n");
    201     pb_log(0,"         Please create a pbconfdir reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
    202     pb_log(0,"         if you want to use another directory\n");
    203     $ENV{'PBCONF'} = "$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf";
    204 }
    205 
    206 # Expand potential env variable in it
    207 eval { $ENV{'PBCONF'} =~ s/(\$ENV.+\})/$1/eeg };
    208 pb_log(2,"PBCONF: $ENV{'PBCONF'}\n");
    209 
    210 my ($scheme, $account, $host, $port, $path) = pb_get_uri($pbconf{$ENV{'PBPROJ'}});
    211 
    212 if ((! -d "$ENV{'PBCONF'}") || (defined $pbinit)) {
    213     pb_log(1,"Checking out pbconf\n");
    214     pb_cms_checkout($scheme,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'});
    215 } else {
    216     pb_log(1,"pbconf found, checking content\n");
    217     my $cmsurl = pb_cms_getinfo($scheme,$ENV{'PBCONF'},"URL:");
    218     my ($scheme2, $account2, $host2, $port2, $path2) = pb_get_uri($cmsurl);
    219     if ($scheme2 ne $scheme) {
    220         pb_log(1,"WARNING: Content of $ENV{'PBCONF'} irrelevant, cleaning up and checking it out\n");
    221         pb_rm_rf("$ENV{'PBCONF'}");
    222         pb_cms_checkout($scheme,$pbconf{$ENV{'PBPROJ'}},$ENV{'PBCONF'});
    223     } elsif ($cmsurl ne $pbconf{$ENV{'PBPROJ'}}) {
    224         # The local content doesn't correpond to the repository
    225         pb_log(0,"ERROR: Inconsistency detected:\n");
    226         pb_log(0,"       * $ENV{'PBCONF'} refers to $cmsurl but\n");
    227         pb_log(0,"       * $ENV{'PBETC'} refers to $pbconf{$ENV{'PBPROJ'}}\n");
    228         die "Project $ENV{'PBPROJ'} is not Project-Builder compliant.";
    229     } else {
    230         pb_log(1,"Content correct - doing nothing - you may want to update your repository however\n");
    231         # they match - do nothing - there may be local changes
    232     }
    233 }
     190# Check pbconf cms compliance
     191#
     192pb_cms_compliant("pbconfdir",'PBCONF',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}/pbconf",$pbconf{$ENV{'PBPROJ'}},$pbinit);
    234193
    235194# Check where is our PBROOT (release tag name can't be guessed the first time)
     
    936895            # No ref in home dir project conf file so use the CMS one.
    937896            $p2->{$ENV{'PBPROJ'}} = $p2->{'default'} if (not defined $p2->{$ENV{'PBPROJ'}});
    938             $p1->{$ENV{'PBPROJ'}} = $p2->{$ENV{'PBPROJ'}};
     897            $p1 = $p2;
    939898        } else {
    940899            # Both are defined - handling the overloading
     
    952911                }
    953912            }
     913            # Now copy back into p1 all p2 content which doesn't exist in p1
     914            # p1 content (local) always has priority over p2 (project)
     915            foreach my $k (keys %$p2) {
     916                $p1->{$k} = $p2->{$k} if (not defined $p1->{$k});
     917            }
    954918        }
    955919    }
     
    986950while(<CONF>) {
    987951    if (/^\s*([A-z0-9-_]+)\s+([[A-z0-9-_]+)\s*=\s*(.+)$/) {
    988         pb_log(2,"DEBUG: 1:$1 2:$2 3:$3\n");
     952        pb_log(3,"DEBUG: 1:$1 2:$2 3:$3\n");
    989953        $h{$1}{$2}=$3;
    990954    }
     
    10551019}
    10561020
    1057 #
    1058 #if (not defined $scheme) {
    1059     # We're an upstream guy
    1060     # Try to make it easy for us
    1061     #pb_log(2,"WARNING: Assuming a local project under $ENV{'PBDIR'}/$ENV{'PBPROJ'}:\n");
    1062     #pb_log(2,"         If not, pleaase setup a pbproj entry in $ENV{'PBROOT'}/$ENV{'PBPROJ'}.pb\n");
    1063     #return("");
    1064 #}
    1065 
    10661021return($scheme,$uri->{$ENV{'PBPROJ'}});
    10671022}
     
    10881043        $tmp = $destdir;
    10891044    } else {
    1090         $tmp = $destdir."/".basename($source);
    1091         pb_mkdir_p($destdir);
     1045        $tmp = "$destdir/".basename($source);
     1046        pb_mkdir_p($tmp);
    10921047    }
    10931048    pb_system("svn export $source $tmp","Exporting $source from SVN to $tmp");
     
    15391494}
    15401495
     1496sub pb_cms_compliant {
     1497
     1498my $param = shift;
     1499my $envar = shift;
     1500my $defdir = shift;
     1501my $uri = shift;
     1502my $pbinit = shift;
     1503#
     1504# Check pbconf/project cms compliance
     1505#
     1506
     1507my ($pdir) = pb_conf_get_if($param);
     1508my %pdir = %$pdir;
     1509
     1510if ((defined $pdir) && (defined $pdir{$ENV{'PBPROJ'}})) {
     1511    # That's always the environment variable that will be used
     1512    $ENV{$envar} = $pdir{$ENV{'PBPROJ'}};
     1513} else {
     1514    pb_log(0,"WARNING: no $param defined, using $defdir\n");
     1515    pb_log(0,"         Please create a $param reference for project $ENV{'PBPROJ'} in $ENV{'PBETC'}\n");
     1516    pb_log(0,"         if you want to use another directory\n");
     1517    $ENV{$envar} = "$defdir";
     1518}
     1519
     1520# Expand potential env variable in it
     1521eval { $ENV{$envar} =~ s/(\$ENV.+\})/$1/eeg };
     1522pb_log(2,"$envar: $ENV{$envar}\n");
     1523
     1524my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);
     1525
     1526if ((! -d "$ENV{$envar}") || (defined $pbinit)) {
     1527    pb_log(1,"Checking out $uri\n");
     1528    pb_cms_checkout($scheme,$uri,$ENV{$envar});
     1529} else {
     1530    pb_log(1,"$uri found locally, checking content\n");
     1531    my $cmsurl = pb_cms_getinfo($scheme,$ENV{$envar},"URL:");
     1532    my ($scheme2, $account2, $host2, $port2, $path2) = pb_get_uri($cmsurl);
     1533    if ($cmsurl ne $uri) {
     1534        # The local content doesn't correpond to the repository
     1535        pb_log(0,"ERROR: Inconsistency detected:\n");
     1536        pb_log(0,"       * $ENV{$envar} refers to $cmsurl but\n");
     1537        pb_log(0,"       * $ENV{'PBETC'} refers to $uri\n");
     1538        die "Project $ENV{'PBPROJ'} is not Project-Builder compliant.";
     1539    } else {
     1540        pb_log(1,"Content correct - doing nothing - you may want to update your repository however\n");
     1541        # they match - do nothing - there may be local changes
     1542    }
     1543}
     1544}
     1545
    154115461;
Note: See TracChangeset for help on using the changeset viewer.