source: ProjectBuilder/devel/pb/lib/pb.pm@ 39

Last change on this file since 39 was 39, checked in by Bruno Cornec, 17 years ago

Add a patch to AppConfig::File to solve the issue around automatically create '1' key entry in all hashes

File size: 2.2 KB
RevLine 
[6]1#!/usr/bin/perl -w
2#
[18]3# Project Builder configuration file handler
[6]4# For project pb ;-)
5#
6# $Id$
7#
8use strict;
[39]9use AppConfig qw(ARGCOUNT_HASH ARGCOUNT_ONE);
[19]10use Data::Dumper;
[6]11
12sub pb_init {
13
14my $conffile = shift;
[38]15my $trace;
16
17if ($debug > 0) {
18 $trace = 1;
19} else {
20 $trace = 0;
21}
22
23
24my $config = AppConfig->new({
25 # Auto Create variables mentioned in Conf file
26 CREATE => 1,
27 DEBUG => $trace,
28 GLOBAL => {
29 # Each conf item is a hash
[39]30 ARGCOUNT => ARGCOUNT_ONE,
31 },
[38]32 });
33$config->file($conffile);
34my $ptr = $config->get("pbroot") || die "Unable to find pbroot in $conffile";
35return($ptr);
36}
37
38sub pb_conf_init {
39
40my $conffile = shift;
[7]41my $ptr;
[21]42my $trace;
[6]43
[22]44if ($debug > 0) {
[21]45 $trace = 1;
46} else {
47 $trace = 0;
48}
49
[6]50my $config = AppConfig->new({
51 # Auto Create variables mentioned in Conf file
[21]52 DEBUG => $trace,
[39]53 CREATE => '1',
[17]54 GLOBAL => {
55 # Each conf item is a hash
[39]56 ARGCOUNT => ARGCOUNT_HASH,
57 },
[6]58 });
59$config->file($conffile);
60
61# Root of the project to build
62# needs at least 2 levels of dir as in the upper
[18]63# other dirs will be created and used
[6]64
[18]65# main parameter hash (mandatory)
66$ptr = $config->get("confparam") || die "Unable to find confparam in $conffile";
67%confparam = %$ptr;
[21]68print "DEBUG: confparam: ".Dumper($ptr)."\n" if ($debug >= 1);
[18]69
70# List of pkg to build by default (mandatory)
[7]71$ptr = $config->get("defpkgdir") || die "Unable to find defpkgdir in $conffile";
72%defpkgdir = %$ptr;
[21]73print "DEBUG: defpkgdir: ".Dumper($ptr)."\n" if ($debug >= 1);
[6]74
[18]75# List of additional pkg to build when all is called (optional)
[7]76$ptr = $config->get("extpkgdir");
[18]77if (not defined $ptr) {
78 %extpkgdir = ();
79} else {
80 %extpkgdir = %$ptr;
81}
[21]82print "DEBUG: extpkgdir: ".Dumper(\%extpkgdir)."\n" if ($debug >= 1);
[6]83
[18]84# Valid version names (optional)
[7]85$ptr = $config->get("version");
[18]86if (not defined $ptr) {
87 %version = ();
88} else {
89 %version = %$ptr;
90}
[21]91print "DEBUG: version: ".Dumper(\%version)."\n" if ($debug >= 1);
[6]92
[18]93# List of files to filter (optional)
[15]94$ptr = $config->get("filteredfiles");
[18]95if (not defined $ptr) {
96 %filteredfiles = ();
97} else {
98 %filteredfiles = %$ptr;
99}
[21]100print "DEBUG: filteredfiles: ".Dumper(\%filteredfiles)."\n" if ($debug >= 1);
[15]101
[6]102}
1031;
Note: See TracBrowser for help on using the repository browser.