Last change
on this file since 29536 was 29536, checked in by Jeremy Symon, 9 years ago |
Working on a more flexible generation system. Only working for pacman so far, so if you want to generate packages you'll need to check out an old revision. The reason behind this change is that I discovered that the greenstone user database really needs to be owned by the tomcat user rather than root (things such as edit mode don't work properly otherwise), and setting file ownership requires .install files, which was not really possible with the existing system. At this point it would certainly have been faster to just write all the scripts by hand, but this way I get to learn perl.
|
File size:
1.1 KB
|
Line | |
---|
1 | package Greenstone::Config::Loader;
|
---|
2 |
|
---|
3 | use strict;
|
---|
4 | use warnings;
|
---|
5 | use utf8;
|
---|
6 | use parent 'Greenstone::Config';
|
---|
7 | use Greenstone::Helpers;
|
---|
8 |
|
---|
9 | # Reads a config file into the config hashmap
|
---|
10 | sub readconf {
|
---|
11 | my ($self, $conf) = @_;
|
---|
12 | $self->{config} = {} unless exists $self->{config};
|
---|
13 | open CONF, '<', $conf
|
---|
14 | or die "Failed to open '$conf' for reading: $!";
|
---|
15 | my $var;
|
---|
16 | while (my $line = <CONF>) {
|
---|
17 | if (empty $line or comment $line) {
|
---|
18 | $var = undef;
|
---|
19 | } elsif (defined $var and $line =~ /^\s/) {
|
---|
20 | trim $line;
|
---|
21 | $self->subst ($line);
|
---|
22 | escape $line;
|
---|
23 | push @{$self->{config}->{$var}}, $line;
|
---|
24 | } else {
|
---|
25 | ($var, my $val) = trim (split ":", $line, 2);
|
---|
26 | defined $var and defined $val or die "Invalid variable assignment: '$line'";
|
---|
27 | if (empty $val) {
|
---|
28 | $self->{config}->{$var} = [];
|
---|
29 | } else {
|
---|
30 | $self->subst ($val);
|
---|
31 | escape $val;
|
---|
32 | $self->{config}->{$var} = $val;
|
---|
33 | }
|
---|
34 | }
|
---|
35 | }
|
---|
36 | close CONF;
|
---|
37 | }
|
---|
38 |
|
---|
39 | 1;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.