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
Line 
1#!/usr/bin/perl -w
2#
3# Project Builder configuration file handler
4# For project pb ;-)
5#
6# $Id$
7#
8use strict;
9use AppConfig qw(ARGCOUNT_HASH ARGCOUNT_ONE);
10use Data::Dumper;
11
12sub pb_init {
13
14my $conffile = shift;
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
30 ARGCOUNT => ARGCOUNT_ONE,
31 },
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;
41my $ptr;
42my $trace;
43
44if ($debug > 0) {
45 $trace = 1;
46} else {
47 $trace = 0;
48}
49
50my $config = AppConfig->new({
51 # Auto Create variables mentioned in Conf file
52 DEBUG => $trace,
53 CREATE => '1',
54 GLOBAL => {
55 # Each conf item is a hash
56 ARGCOUNT => ARGCOUNT_HASH,
57 },
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
63# other dirs will be created and used
64
65# main parameter hash (mandatory)
66$ptr = $config->get("confparam") || die "Unable to find confparam in $conffile";
67%confparam = %$ptr;
68print "DEBUG: confparam: ".Dumper($ptr)."\n" if ($debug >= 1);
69
70# List of pkg to build by default (mandatory)
71$ptr = $config->get("defpkgdir") || die "Unable to find defpkgdir in $conffile";
72%defpkgdir = %$ptr;
73print "DEBUG: defpkgdir: ".Dumper($ptr)."\n" if ($debug >= 1);
74
75# List of additional pkg to build when all is called (optional)
76$ptr = $config->get("extpkgdir");
77if (not defined $ptr) {
78 %extpkgdir = ();
79} else {
80 %extpkgdir = %$ptr;
81}
82print "DEBUG: extpkgdir: ".Dumper(\%extpkgdir)."\n" if ($debug >= 1);
83
84# Valid version names (optional)
85$ptr = $config->get("version");
86if (not defined $ptr) {
87 %version = ();
88} else {
89 %version = %$ptr;
90}
91print "DEBUG: version: ".Dumper(\%version)."\n" if ($debug >= 1);
92
93# List of files to filter (optional)
94$ptr = $config->get("filteredfiles");
95if (not defined $ptr) {
96 %filteredfiles = ();
97} else {
98 %filteredfiles = %$ptr;
99}
100print "DEBUG: filteredfiles: ".Dumper(\%filteredfiles)."\n" if ($debug >= 1);
101
102}
1031;
Note: See TracBrowser for help on using the repository browser.