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