source: trunk/lib/OpenGuides/Build.pm @ 85

Last change on this file since 85 was 85, checked in by kake, 19 years ago

Bumped version number.
Redid the script and template installation so the script does actually get called what you said it should be (code copied somewhat from Siesta::Build).
Also you now need to specify the template installation directory.
Fixed the support for non-local databases/IDENT authentication. I think.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1package OpenGuides::Build;
2
3use strict;
4use Module::Build;
5use base 'Module::Build';
6
7sub ACTION_install {
8    my $self = shift;
9    $self->SUPER::ACTION_install;
10    $self->ACTION_install_extras;
11
12    eval "use Config::Tiny";
13    die "Config::Tiny is required to set up this application.\n" if $@;
14
15    my $config = Config::Tiny->read("wiki.conf");
16
17    # Initialise the database if necessary.
18    my $dbname = $config->{_}->{dbname};
19    my $dbuser = $config->{_}->{dbuser};
20    my $dbpass = $config->{_}->{dbpass};
21    my $dbhost = $config->{_}->{dbhost};
22    my $dbtype = $config->{_}->{dbtype};
23
24    my %cgi_wiki_exts = ( postgres => "Pg",
25                          mysql    => "MySQL" );
26
27    my $cgi_wiki_module = "CGI::Wiki::Setup::" . $cgi_wiki_exts{$dbtype};
28    eval "require $cgi_wiki_module";
29    die "CGI::Wiki is required to set up this application.\n" if $@;
30
31    print "Checking database schema...\n";
32    {
33        no strict 'refs';
34        &{$cgi_wiki_module . "::setup"}( $dbname, $dbuser, $dbpass, $dbhost );
35    }
36}
37
38sub ACTION_fakeinstall {
39    my $self = shift;
40    $self->SUPER::ACTION_fakeinstall;
41    $self->ACTION_install_extras( fake => 1 );
42    print "Checking database schema...\n";
43}
44
45sub ACTION_install_extras {
46    my ($self, %args) = @_;
47    my $FAKE = $args{fake} || 0;
48
49    eval "use Config::Tiny";
50    die "Config::Tiny is required to set up this application.\n" if $@;
51
52    my $config = Config::Tiny->read("wiki.conf");
53
54    # Install the scripts where we were told to.
55    my $install_directory = $config->{_}->{install_directory};
56    my $script_name       = $config->{_}->{script_name};
57    my $template_path     = $config->{_}->{template_path};
58    my @extra_scripts     = @{ $self->{config}{__extra_scripts} };
59    my @templates         = @{ $self->{config}{__templates} };
60
61    print "Installing scripts to $install_directory:\n";
62    if ( $FAKE ) {
63        print "wiki.cgi -> $install_directory/$script_name (FAKE)\n";
64    } else {
65        if ( $script_name ne "wiki.cgi" ) {
66            File::Copy::copy("wiki.cgi", $script_name)
67                or die "Can't copy('wiki.cgi', '$script_name'): $!";
68        }
69        my $copy = $self->copy_if_modified( $script_name, $install_directory );
70        if ( $copy ) {
71            $self->fix_shebang_line($copy);
72            $self->make_executable($copy);
73        } else {
74            print "Skipping $install_directory/$script_name (unchanged)\n";
75        }
76        print "(Really: wiki.cgi -> $install_directory/$script_name)\n"
77            unless $script_name eq "wiki.cgi";
78    }
79
80    foreach my $script ( @extra_scripts ) {
81        if ( $FAKE ) {
82            print "$script -> $install_directory/$script (FAKE)\n";
83        } else {
84            my $copy = $self->copy_if_modified( $script, $install_directory );
85            if ( $copy ) {
86                $self->fix_shebang_line($copy);
87                $self->make_executable($copy);
88            } else {
89                print "Skipping $install_directory/$script (unchanged)\n";
90            }
91        }
92    }
93
94    print "Installing templates to $template_path:\n";
95    foreach my $template ( @templates ) {
96        if ( $FAKE ) {
97            print "templates/$template -> $template_path/$template (FAKE)\n";
98        } else {
99            $self->copy_if_modified( "templates/$template", $template_path )
100                or print "Skipping $template_path/$template (unchanged)\n";
101        }
102    }
103}
104
1051;
Note: See TracBrowser for help on using the repository browser.