Changeset 2239 in ProjectBuilder for devel/pb-modules/lib/ProjectBuilder
- Timestamp:
- Jul 31, 2017, 1:25:12 AM (7 years ago)
- Location:
- devel/pb-modules/lib/ProjectBuilder
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Conf.pm
r2176 r2239 19 19 use ProjectBuilder::Base; 20 20 use ProjectBuilder::Version; 21 #use YAML;22 21 23 22 # Inherit from the "Exporter" module which handles exporting functions. 24 23 25 use vars qw($VERSION $REVISION @ISA @EXPORT);24 use vars qw($VERSION $REVISION $PBCONFVER @ISA @EXPORT); 26 25 use Exporter; 27 26 … … 31 30 our @ISA = qw(Exporter); 32 31 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); 33 ($VERSION,$REVISION ) = pb_version_init();32 ($VERSION,$REVISION,$PBCONFVER) = pb_version_init(); 34 33 35 34 # Global hash of conf files … … 70 69 to allow for overwrite to work: 71 70 72 1. /usr/share/pb/pb. conf- the read-only system conf file provided by install73 2. /etc/pb/pb. conf- the same global conf file given to the sysadmin in order to make system wide modifications71 1. /usr/share/pb/pb.yml - the read-only system conf file provided by install 72 2. /etc/pb/pb.yml - the same global conf file given to the sysadmin in order to make system wide modifications 74 73 3. /path/to/project.pb - Configuration file for the project we're building for 75 74 4. /(vm|ve|rm)path/to/.pbrc - configuration file for VM, VE or RM specific parameters. Cumulative should be orthogonal … … 124 123 my $cf = shift; 125 124 my $lh = shift; 126 my $confver = "0.14"; 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 } 127 138 128 139 # Read the content of the config file and cache it in the %h hash then available for queries 129 if ($ confver < 0.15) {140 if ($PBCONFVER < 1) { 130 141 open(CONF,$cf) || confess "Unable to open $cf"; 131 142 # This is the original conf file format for versions up to 0.14 … … 139 150 close(CONF); 140 151 } else { 141 $lh = LoadFile($cf);152 $lh = $ldfunc->($cf); 142 153 } 143 154 return($lh); … … 251 262 my $conffile = shift; 252 263 my $h = shift; 253 my $confver = "0.14"; 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 } 254 276 255 277 confess "No configuration file defined to write into !" if (not defined $conffile); … … 257 279 open(CONF,"> $conffile") || confess "Unable to write into $conffile"; 258 280 259 if ($ confver < 0.15) {281 if ($PBCONFVER < 1) { 260 282 # This is the original conf file format for versions up to 0.14 261 283 foreach my $p (sort keys %$h) { … … 267 289 } else { 268 290 # This is the new YAML format 269 print CONF Dump($h);291 print CONF $dpfunc->($h); 270 292 } 271 293 close(CONF); -
devel/pb-modules/lib/ProjectBuilder/Distribution.pm
r2234 r2239 26 26 # Inherit from the "Exporter" module which handles exporting functions. 27 27 28 use vars qw($VERSION $REVISION @ISA @EXPORT);28 use vars qw($VERSION $REVISION $PBCONFVER @ISA @EXPORT); 29 29 use Exporter; 30 30 … … 34 34 our @ISA = qw(Exporter); 35 35 our @EXPORT = qw(pb_distro_init pb_distro_conffile pb_distro_sysconffile pb_distro_get pb_distro_getlsb pb_distro_installdeps pb_distro_getdeps pb_distro_only_deps_needed pb_distro_setuprepo pb_distro_setuposrepo pb_distro_setuprepo_gen pb_distro_get_param pb_distro_get_context pb_distro_to_keylist pb_distro_conf_print pb_apply_conf_proxy); 36 ($VERSION,$REVISION ) = pb_version_init();36 ($VERSION,$REVISION,$PBCONFVER) = pb_version_init(); 37 37 38 38 =pod … … 77 77 sub pb_distro_conffile { 78 78 79 return("CCCC/pb.conf"); 79 if ($PBCONFVER < 1) { 80 return("CCCC/pb.conf"); 81 } else { 82 return("CCCC/pb.yml"); 83 } 80 84 } 81 85 … … 88 92 sub pb_distro_sysconffile { 89 93 90 return("SSSS/pb.conf"); 94 if ($PBCONFVER < 1) { 95 return("SSSS/pb.conf"); 96 } else { 97 return("SSSS/pb.yml"); 98 } 91 99 } 92 100 … … 99 107 Mandriva, Open SuSE and Fedora have all the same "rpm" type of build system. Ubuntu and Debian have the same "deb" type of build system. 100 108 And "fc" is the extension generated for all Fedora packages (Version will be added by pb). 101 All this information is stored in an external configuration file typically at /etc/pb/pb. conf109 All this information is stored in an external configuration file typically at /etc/pb/pb.yml 102 110 103 111 When passing the distribution name and version as parameters, the B<pb_distro_init> function returns the parameter of that distribution instead of the underlying one. … … 635 643 my $dirdest = ""; 636 644 my $reponame = ""; 637 # TODO: could go in pb. confin fact645 # TODO: could go in pb.yml in fact 638 646 if ($pbos->{install} =~ /\byum\b/) { 639 647 $reponame="yum"; -
devel/pb-modules/lib/ProjectBuilder/Version.pm
r2105 r2239 29 29 my $projectbuilderver = $VERSION; 30 30 my $projectbuilderrev = $REVISION; 31 # We fix the format of the conf file for this version of pb 32 my $projectbuilderconfver = 1; 31 33 32 return($projectbuilderver,$projectbuilderrev );34 return($projectbuilderver,$projectbuilderrev,$projectbuilderconfver); 33 35 } 34 36 1;
Note:
See TracChangeset
for help on using the changeset viewer.