1 |
package Magus::Config; |
2 |
# |
3 |
# Copyright (c) 2007,2008 Chris Reinhardt. All rights reserved. |
4 |
# |
5 |
# Redistribution and use in source and binary forms, with or without |
6 |
# modification, are permitted provided that the following conditions are |
7 |
# met: |
8 |
# |
9 |
# 1. Redistributions of source code must retain the above copyright notice |
10 |
# this list of conditions and the following disclaimer. |
11 |
# |
12 |
# 2. Redistributions in binary form must reproduce the above copyright |
13 |
# notice, this list of conditions and the following disclaimer in the |
14 |
# documentation and/or other materials provided with the distribution. |
15 |
# |
16 |
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
17 |
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
18 |
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
19 |
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 |
# |
27 |
# $MidnightBSD: mports/Tools/lib/Magus/Config.pm,v 1.4 2008/09/09 15:28:40 ctriv Exp $ |
28 |
# |
29 |
# MAINTAINER= ctriv@MidnightBSD.org |
30 |
# |
31 |
|
32 |
|
33 |
use strict; |
34 |
use warnings; |
35 |
use YAML qw(LoadFile); |
36 |
|
37 |
our %Config; |
38 |
|
39 |
|
40 |
sub import { |
41 |
no strict 'refs'; |
42 |
|
43 |
my $caller = caller; |
44 |
|
45 |
*{"$caller\::Config"} = \%Config; |
46 |
} |
47 |
|
48 |
sub load_config { |
49 |
%Config = ( |
50 |
# defaults |
51 |
SlaveSrcDir => '/usr/src', |
52 |
%{ LoadFile(shift) }, |
53 |
); |
54 |
|
55 |
# More defaults |
56 |
$Config{SlaveDataDir} ||= "$Magus::Root/slave-data"; |
57 |
$Config{SlaveMportsDir} ||= "$Config{SlaveDataDir}/mports"; |
58 |
$Config{SlaveChrootsDir} ||= "$Config{SlaveDataDir}/chroots"; |
59 |
} |
60 |
|
61 |
BEGIN { load_config("$Magus::Root/config.yaml") }; |
62 |
|
63 |
|
64 |
1; |
65 |
__END__ |
66 |
|