Ignore:
Timestamp:
Feb 14, 2017, 7:17:12 PM (3 years ago)
Author:
bruno
Message:

Fix package based installation of pb

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/Conf.pm

    r2154 r2176  
    1919use ProjectBuilder::Base;
    2020use ProjectBuilder::Version;
     21#use YAML;
    2122
    2223# Inherit from the "Exporter" module which handles exporting functions.
     
    123124my $cf = shift;
    124125my $lh = shift;
     126my $confver = "0.14";
    125127
    126128# Read the content of the config file and cache it in the %h hash then available for queries
    127 open(CONF,$cf) || confess "Unable to open $cf";
    128 while(<CONF>) {
    129     next if (/^#/);
    130     if (/^\s*([A-z0-9-_.]+)\s+([[A-z0-9-_.\?\[\]\*\+\\]+)\s*=\s*(.*)$/) {
    131         pb_log(3,"DEBUG: 1:$1 2:$2 3:$3\n");
    132         $lh->{$1}->{$2}=$3;
     129if ($confver < 0.15) {
     130    open(CONF,$cf) || confess "Unable to open $cf";
     131    # This is the original conf file format for versions up to 0.14
     132    while(<CONF>) {
     133        next if (/^#/);
     134        if (/^\s*([A-z0-9-_.]+)\s+([[A-z0-9-_.\?\[\]\*\+\\]+)\s*=\s*(.*)$/) {
     135            pb_log(3,"DEBUG: 1:$1 2:$2 3:$3\n");
     136            $lh->{$1}->{$2}=$3;
     137        }
    133138    }
    134 }
    135 close(CONF);
     139    close(CONF);
     140} else {
     141    $lh = LoadFile($cf);
     142}
    136143return($lh);
    137144}
     
    244251my $conffile = shift;
    245252my $h = shift;
     253my $confver = "0.14";
    246254
    247255confess "No configuration file defined to write into !" if (not defined $conffile);
     
    249257open(CONF,"> $conffile") || confess "Unable to write into $conffile";
    250258
    251 foreach my $p (sort keys %$h) {
    252     my $j = $h->{$p};
    253     foreach my $k (sort keys %$j) {
    254         print CONF "$p $k = $j->{$k}\n";
     259if ($confver < 0.15) {
     260    # This is the original conf file format for versions up to 0.14
     261    foreach my $p (sort keys %$h) {
     262        my $j = $h->{$p};
     263        foreach my $k (sort keys %$j) {
     264            print CONF "$p $k = $j->{$k}\n";
     265        }
    255266    }
     267} else {
     268    # This is the new YAML format
     269    print CONF Dump($h);
    256270}
    257271close(CONF);
Note: See TracChangeset for help on using the changeset viewer.