From d6eba778699c2432b11d994130011d5ad071f316 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 13 Dec 2007 17:37:22 -0600 Subject: [PATCH] installer: now can use env vars to set installation variables * Set default value for named parameters, e.g., DB_USER * Override directory targets, e.g., KOHA_CONF_DIR --- Makefile.PL | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Makefile.PL b/Makefile.PL index bcc5b85a53..43cc8675eb 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -820,6 +820,8 @@ Please specify the Zebra database password); $config{'ZEBRA_PASS'} = _get_value('ZEBRA_PASS', $msg, $defaults->{'ZEBRA_PASS'}, $valid_values); } + + print "\n\n"; return %config; } @@ -840,6 +842,12 @@ sub _get_value { my $default = shift; my $valid_values = shift; + # override default value from environment + if (exists $ENV{$key}) { + $default = $ENV{$key}; + $msg .= " (default from environment)"; + } + my $val = prompt($msg, $default); while (exists $valid_values->{$key} and not exists $valid_values->{$key}->{$val}) { my $retry_msg = "Value '$val' is not a valid option.\n"; @@ -941,11 +949,23 @@ sub get_target_directories { $dirmap{'ZEBRA_RUN_DIR'} = File::Spec->catdir(File::Spec->rootdir(), 'var', 'run', $package, 'zebradb'); } + _get_env_overrides(\%dirmap); _get_argv_overrides(\%dirmap); return \%dirmap, \%skipdirs; } +sub _get_env_overrides { + my $dirmap = shift; + + foreach my $key (keys %$dirmap) { + if (exists $ENV{$key}) { + $dirmap->{$key} = $ENV{$key}; + print "Setting $key from environment\n"; + } + } +} + sub _get_argv_overrides { my $dirmap = shift; @@ -976,6 +996,13 @@ sub display_configuration { print "perl Makefile.PL again. To override one of the target\n"; print "directories, you can do so on the command line like this:\n"; print "\nperl Makefile.PL PERL_MODULE_DIR=/usr/share/perl/5.8\n\n"; + print "You can also set different default values for parameters\n"; + print "or override directory locations by using environment variables.\n"; + print "\nFor example:\n\n"; + print "export DB_USER=my_koha\n"; + print "perl Makefile.PL\n"; + print "\nor\n\n"; + print "DB_USER=my_koha DOC_DIR=/usr/local/info perl Makefile.PL\n\n"; } package MY; -- 2.20.1