Author: dom Date: 2013-01-02 00:53:20 +0000 (Wed, 02 Jan 2013) New Revision: 1451
Modified: trunk/Changes trunk/lib/OpenGuides/Build.pm Log: Respect destdir when initialising database; also protect against undefined warnings when destdir is not set
Modified: trunk/Changes =================================================================== --- trunk/Changes 2013-01-02 00:32:36 UTC (rev 1450) +++ trunk/Changes 2013-01-02 00:53:20 UTC (rev 1451) @@ -10,7 +10,8 @@ not installed Work around a "No such method textContent" bug in Test::HTML::Content when XML::LibXML is not installed - Respect destdir when installing scripts, templates, etc + Respect destdir when installing scripts, templates, etc and + when initialising SQLite databases Use mkpath to create the custom template directory rather than mkdir, for cases where the parent directory doesn't already exist
Modified: trunk/lib/OpenGuides/Build.pm =================================================================== --- trunk/lib/OpenGuides/Build.pm 2013-01-02 00:32:36 UTC (rev 1450) +++ trunk/lib/OpenGuides/Build.pm 2013-01-02 00:53:20 UTC (rev 1451) @@ -21,7 +21,13 @@ my $config = OpenGuides::Config->new( file => "wiki.conf" );
# Initialise the database if necessary. - my $dbname = $config->dbname; + # Using destdir here is a bit far-fetched, unless we expect + # packagers to ship pre-initialised databases. However, it is + # better than ignoring it. A better solution would be to allow + # more control over whether the database is initialised here. + my $dbname = ( $config->dbtype eq 'sqlite' && defined $self->destdir ) ? + File::Spec->catdir($self->destdir, $config->dbname) : + $config->dbname; my $dbuser = $config->dbuser; my $dbpass = $config->dbpass; my $dbhost = $config->dbhost; @@ -59,12 +65,12 @@ my $config = OpenGuides::Config->new( file => "wiki.conf" );
# Install the scripts where we were told to. - my $install_directory = File::Spec->catdir($self->destdir, $config->install_directory); + my $install_directory = defined $self->destdir ? File::Spec->catdir( $self->destdir, $config->install_directory ) : $config->install_directory; my $script_name = $config->script_name; - my $template_path = File::Spec->catdir($self->destdir, $config->template_path); - my $custom_template_path = File::Spec->catdir($self->destdir, $config->custom_template_path); + my $template_path = defined $self->destdir ? File::Spec->catdir( $self->destdir, $config->template_path ) : $config->template_path; + my $custom_template_path = defined $self->destdir ? File::Spec->catdir( $self->destdir, $config->custom_template_path ) : $config->custom_template_path; my $custom_lib_path = $config->custom_lib_path; - my $static_path = File::Spec->catdir($self->destdir, $config->static_path); + my $static_path = defined $self->destdir ? File::Spec->catdir( $self->destdir, $config->static_path ) : $config->static_path; my @extra_scripts = @{ $self->config_data( "__extra_scripts" ) }; my @templates = @{ $self->config_data( "__templates" ) }; my @static_files = @{ $self->config_data( "__static_files" ) };
openguides-commits@lists.openguides.org