3 # Conf -- configured path names and such.
4 # Copyright (C) 2005 Erik van Konijnenburg
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # You can get and set configuration items by name,
21 # with the following restrictions:
22 # - only get and set known keys
23 # - after first get, no further set is allowed.
25 # Defaults are packaged as subs, so that you can change
26 # one setting and have the change ripple through in other
37 # Default values for configuration; if there is no default,
38 # it's not a known parameter, and you cannot modify it.
41 version => sub { my $v = `uname -r`; chomp $v; $v; },
42 libModules => sub { "/lib/modules"; },
43 kernConf => sub { "/boot/config-"
45 modDep => sub { get('libModules')
46 . '/' . get('version')
48 usbMap => sub { get('libModules')
49 . '/' . get('version')
50 . '/modules.usbmap'; },
51 pciMap => sub { get('libModules')
52 . '/' . get('version')
53 . '/modules.pcimap'; },
54 modDir => sub { get('libModules')
55 . '/' . get('version')
57 sysFs => sub { "/sys"; },
58 procFs => sub { "/proc"; },
60 sysBlock => sub { get ('sysFs') . "/block"; },
61 sysDevices => sub { get ('sysFs') . "/devices"; },
62 dev => sub { "/dev"; },
63 fstab => sub { "/etc/fstab"; },
64 hotplug => sub { "/etc/hotplug"; },
65 appVersion => sub { "0.0.5"; },
66 auxDir => sub { "/usr/local/lib/yaird/exec"; },
70 my $overrides = {}; # config values where default is overridden,
71 # presumably via command line.
72 my $used = {}; # if a key exists, the config value has
73 # been used, and it no longer can be changed.
77 my $dflt = $defaults->{$key};
78 Base::assert (defined ($dflt));
80 my $ovr = $overrides->{$key};
88 my ($key, $value) = @_;
89 my $dflt = $defaults->{$key};
90 Base::assert (defined ($dflt));
91 Base::assert (! defined ($used->{$key}));
92 $overrides->{$key} = $value;