| 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); |
|---|
| 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 | DEFAULT => { }, |
|---|
| 31 | ARGCOUNT => AppConfig::ARGCOUNT_ONE, |
|---|
| 32 | } |
|---|
| 33 | }); |
|---|
| 34 | $config->file($conffile); |
|---|
| 35 | my $ptr = $config->get("pbroot") || die "Unable to find pbroot in $conffile"; |
|---|
| 36 | return($ptr); |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | sub pb_conf_init { |
|---|
| 40 | |
|---|
| 41 | my $conffile = shift; |
|---|
| 42 | my $ptr; |
|---|
| 43 | my $trace; |
|---|
| 44 | |
|---|
| 45 | if ($debug > 0) { |
|---|
| 46 | $trace = 1; |
|---|
| 47 | } else { |
|---|
| 48 | $trace = 0; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | my $config = AppConfig->new({ |
|---|
| 52 | # Auto Create variables mentioned in Conf file |
|---|
| 53 | CREATE => 1, |
|---|
| 54 | DEBUG => $trace, |
|---|
| 55 | GLOBAL => { |
|---|
| 56 | # Each conf item is a hash |
|---|
| 57 | DEFAULT => { }, |
|---|
| 58 | ARGCOUNT => AppConfig::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; |
|---|
| 70 | print "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; |
|---|
| 75 | print "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"); |
|---|
| 79 | if (not defined $ptr) { |
|---|
| 80 | %extpkgdir = (); |
|---|
| 81 | } else { |
|---|
| 82 | %extpkgdir = %$ptr; |
|---|
| 83 | } |
|---|
| 84 | print "DEBUG: extpkgdir: ".Dumper(\%extpkgdir)."\n" if ($debug >= 1); |
|---|
| 85 | |
|---|
| 86 | # Valid version names (optional) |
|---|
| 87 | $ptr = $config->get("version"); |
|---|
| 88 | if (not defined $ptr) { |
|---|
| 89 | %version = (); |
|---|
| 90 | } else { |
|---|
| 91 | %version = %$ptr; |
|---|
| 92 | } |
|---|
| 93 | print "DEBUG: version: ".Dumper(\%version)."\n" if ($debug >= 1); |
|---|
| 94 | |
|---|
| 95 | # List of files to filter (optional) |
|---|
| 96 | $ptr = $config->get("filteredfiles"); |
|---|
| 97 | if (not defined $ptr) { |
|---|
| 98 | %filteredfiles = (); |
|---|
| 99 | } else { |
|---|
| 100 | %filteredfiles = %$ptr; |
|---|
| 101 | } |
|---|
| 102 | print "DEBUG: filteredfiles: ".Dumper(\%filteredfiles)."\n" if ($debug >= 1); |
|---|
| 103 | |
|---|
| 104 | } |
|---|
| 105 | 1; |
|---|