1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # Project Builder configuration file handler
|
---|
4 | # For project pb ;-)
|
---|
5 | #
|
---|
6 | # $Id$
|
---|
7 | #
|
---|
8 | use strict;
|
---|
9 | use AppConfig qw(ARGCOUNT_HASH ARGCOUNT_ONE);
|
---|
10 | use Data::Dumper;
|
---|
11 |
|
---|
12 | sub pb_init {
|
---|
13 |
|
---|
14 | my $conffile = shift;
|
---|
15 | my $trace;
|
---|
16 |
|
---|
17 | if ($debug > 0) {
|
---|
18 | $trace = 1;
|
---|
19 | } else {
|
---|
20 | $trace = 0;
|
---|
21 | }
|
---|
22 |
|
---|
23 |
|
---|
24 | my $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);
|
---|
34 | my $ptr = $config->get("pbroot") || die "Unable to find pbroot in $conffile";
|
---|
35 | return($ptr);
|
---|
36 | }
|
---|
37 |
|
---|
38 | sub pb_conf_init {
|
---|
39 |
|
---|
40 | my $conffile = shift;
|
---|
41 | my $ptr;
|
---|
42 | my $trace;
|
---|
43 |
|
---|
44 | if ($debug > 0) {
|
---|
45 | $trace = 1;
|
---|
46 | } else {
|
---|
47 | $trace = 0;
|
---|
48 | }
|
---|
49 |
|
---|
50 | my $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;
|
---|
68 | print "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;
|
---|
73 | print "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");
|
---|
77 | if (not defined $ptr) {
|
---|
78 | %extpkgdir = ();
|
---|
79 | } else {
|
---|
80 | %extpkgdir = %$ptr;
|
---|
81 | }
|
---|
82 | print "DEBUG: extpkgdir: ".Dumper(\%extpkgdir)."\n" if ($debug >= 1);
|
---|
83 |
|
---|
84 | # Valid version names (optional)
|
---|
85 | $ptr = $config->get("version");
|
---|
86 | if (not defined $ptr) {
|
---|
87 | %version = ();
|
---|
88 | } else {
|
---|
89 | %version = %$ptr;
|
---|
90 | }
|
---|
91 | print "DEBUG: version: ".Dumper(\%version)."\n" if ($debug >= 1);
|
---|
92 |
|
---|
93 | # List of files to filter (optional)
|
---|
94 | $ptr = $config->get("filteredfiles");
|
---|
95 | if (not defined $ptr) {
|
---|
96 | %filteredfiles = ();
|
---|
97 | } else {
|
---|
98 | %filteredfiles = %$ptr;
|
---|
99 | }
|
---|
100 | print "DEBUG: filteredfiles: ".Dumper(\%filteredfiles)."\n" if ($debug >= 1);
|
---|
101 |
|
---|
102 | }
|
---|
103 | 1;
|
---|