Changeset 2249 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder/Conf.pm


Ignore:
Timestamp:
Aug 30, 2017, 5:07:28 PM (7 years ago)
Author:
Bruno Cornec
Message:

pbdistrocheck + YAML works

  • Fix for yml main conf file to avoid duplicates
  • Fix for require analysis for YAML module
  • pbdistrocheck works with the main pb.yml file.
  • Need to convert all other configuration files into YAML format
File:
1 edited

Legend:

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

    r2241 r2249  
    124124my $cf = shift;
    125125my $lh = shift;
    126 my $confver = "0.14";
     126
     127my $ldfunc;
    127128
    128129# Read the content of the config file and cache it in the %h hash then available for queries
     
    139140    close(CONF);
    140141} else {
    141     $lh = LoadFile($cf);
     142    eval {
     143        require YAML;
     144        YAML->import();
     145    };
     146    if ($@) {
     147        eval {
     148            # No YAML found using a more std but less complete one. Old perl only
     149            require Module::Build::YAML;
     150            Module::Build::YAML->import();
     151        };
     152        if ($@) {
     153            die "Unable to handle YAML configuration files without a YAML.pm module\n";
     154        } else {
     155            $ldfunc = \&Module::Build::YAML::LoadFile;
     156        }
     157    } else {
     158        $ldfunc = \&YAML::LoadFile;
     159    }
     160
     161    $lh = $ldfunc->($cf);
    142162}
    143163return($lh);
     
    251271my $conffile = shift;
    252272my $h = shift;
    253 my $confver = "0.14";
     273my $dpfunc;
    254274
    255275confess "No configuration file defined to write into !" if (not defined $conffile);
     
    267287} else {
    268288    # This is the new YAML format
    269     print CONF Dump($h);
     289    eval {
     290        require YAML;
     291        YAML->import();
     292    };
     293    if ($@) {
     294        eval {
     295            # No YAML found using a more std but less complete one. Old perl only
     296            require Module::Build::YAML;
     297            Module::Build::YAML->import();
     298        };
     299        if ($@) {
     300            die "Unable to handle YAML configuration files without a YAML.pm module\n";
     301        } else {
     302            $dpfunc = \&Module::Build::YAML::Dump;
     303        }
     304    } else {
     305        $dpfunc = \&YAML::Dump;
     306    }
     307
     308    print CONF $dpfunc->($h);
    270309}
    271310close(CONF);
Note: See TracChangeset for help on using the changeset viewer.