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

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

Rework interfaces of pb_init, conf files content and management to ease usage

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