Changeset 2241 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder/Conf.pm
- Timestamp:
- Aug 2, 2017, 6:16:44 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Conf.pm
r2239 r2241 19 19 use ProjectBuilder::Base; 20 20 use ProjectBuilder::Version; 21 #use YAML; 21 22 22 23 # Inherit from the "Exporter" module which handles exporting functions. 23 24 24 use vars qw($VERSION $REVISION $PBCONFVER@ISA @EXPORT);25 use vars qw($VERSION $REVISION @ISA @EXPORT); 25 26 use Exporter; 26 27 … … 30 31 our @ISA = qw(Exporter); 31 32 our @EXPORT = qw(pb_conf_init pb_conf_add pb_conf_read pb_conf_read_if pb_conf_write pb_conf_get pb_conf_get_if pb_conf_get_all pb_conf_get_hash pb_conf_cache); 32 ($VERSION,$REVISION ,$PBCONFVER) = pb_version_init();33 ($VERSION,$REVISION) = pb_version_init(); 33 34 34 35 # Global hash of conf files … … 69 70 to allow for overwrite to work: 70 71 71 1. /usr/share/pb/pb. yml- the read-only system conf file provided by install72 2. /etc/pb/pb. yml- the same global conf file given to the sysadmin in order to make system wide modifications72 1. /usr/share/pb/pb.conf - the read-only system conf file provided by install 73 2. /etc/pb/pb.conf - the same global conf file given to the sysadmin in order to make system wide modifications 73 74 3. /path/to/project.pb - Configuration file for the project we're building for 74 75 4. /(vm|ve|rm)path/to/.pbrc - configuration file for VM, VE or RM specific parameters. Cumulative should be orthogonal … … 123 124 my $cf = shift; 124 125 my $lh = shift; 125 126 my $ldfunc; 127 128 eval { 129 require YAML; 130 YAML->import(); 131 $ldfunc = \&YAML::LoadFile; 132 }; 133 if ($@) { 134 # No YAML found using a more std but less complete one. Old perl only 135 use Module::Build::YAML; 136 $ldfunc = \&Module::Build::YAML::LoadFile; 137 } 126 my $confver = "0.14"; 138 127 139 128 # Read the content of the config file and cache it in the %h hash then available for queries 140 if ($ PBCONFVER < 1) {129 if ($confver < 0.15) { 141 130 open(CONF,$cf) || confess "Unable to open $cf"; 142 131 # This is the original conf file format for versions up to 0.14 … … 150 139 close(CONF); 151 140 } else { 152 $lh = $ldfunc->($cf);141 $lh = LoadFile($cf); 153 142 } 154 143 return($lh); … … 262 251 my $conffile = shift; 263 252 my $h = shift; 264 my $dpfunc; 265 266 eval { 267 require YAML; 268 YAML->import(); 269 $dpfunc = \&YAML::Dump; 270 }; 271 if ($@) { 272 # No YAML found using a more std but less complete one. Old perl only 273 use Module::Build::YAML; 274 $dpfunc = \&Module::Build::YAML::Dump; 275 } 253 my $confver = "0.14"; 276 254 277 255 confess "No configuration file defined to write into !" if (not defined $conffile); … … 279 257 open(CONF,"> $conffile") || confess "Unable to write into $conffile"; 280 258 281 if ($ PBCONFVER < 1) {259 if ($confver < 0.15) { 282 260 # This is the original conf file format for versions up to 0.14 283 261 foreach my $p (sort keys %$h) { … … 289 267 } else { 290 268 # This is the new YAML format 291 print CONF $dpfunc->($h);269 print CONF Dump($h); 292 270 } 293 271 close(CONF);
Note:
See TracChangeset
for help on using the changeset viewer.