Removing old PO files, removing clutter
[koha_fer] / misc / Install.pm
index 3a2b4e0..c4eed88 100644 (file)
@@ -2,7 +2,7 @@ package Install; #assumes Install.pm
 
 
 # Copyright 2000-2002 Katipo Communications
-# Contains parts Copyright 2003-5 MJ Ray
+# Contains parts Copyright 2003-4 MJ Ray
 #
 # This file is part of Koha.
 #
@@ -19,14 +19,12 @@ package Install; #assumes Install.pm
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 #
-# Recent Authors
-# MJR: my.cnf, etcdir, prefix, new display, apache conf, copying fixups
+# Current maintainer MJR slef at users.sourceforge.net
 
 use strict;
 use POSIX;
 #MJR: everyone will have these modules, right?
 # They look like part of perl core to me
-#use Term::Cap;
 use Term::ANSIColor qw(:constants);
 use Text::Wrap;
 use File::Temp qw/ :mktemp /;
@@ -45,14 +43,19 @@ of the code to do installation;
 this code is used by installer.pl
 to perform an actual installation.
 
-=head2 Internal functions (not meant to be used outside of Install.pm)
+=head2 Internal variables
 
 =over 4
 
+=item $VERSION, @ISA, @EXPORT
+
+Defines the version and structure of the module interface
+
 =cut
 
 # set the version for version checking
-$VERSION = 0.01;
+# set the version for version checking
+$VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
 
 @ISA = qw(Exporter);
 @EXPORT = qw(
@@ -81,48 +84,60 @@ $VERSION = 0.01;
                &restoremycnf
                );
 
-use vars qw( $kohaversion $newversion );                       # set in loadconfigfile and installer.pl
-use vars qw( $language );                      # set in installer.pl
-use vars qw( $domainname );                    # set in installer.pl
+=item $kohaversion, $newversion, $language, $clear_string
 
-use vars qw( $etcdir );                                # set in installer.pl, usu. /etc
-use vars qw( $intranetdir $opacdir $kohalogdir );
-use vars qw( $realhttpdconf $httpduser $httpdgroup );
-use vars qw( $servername $svr_admin $opacport $intranetport );
-use vars qw( $mysqldir );
-use vars qw( $database $mysqluser );
-use vars qw( $mysqlpass );                     # normally should not be used
-use vars qw( $hostname $user $pass );  # virtual hosting
+Installer setting details
 
-=item heading
+=item $etcdir, $intranetdir, $opacdir, $kohalogdir
 
-    $messages->{'WelcomeToKohaInstaller'
-       = heading('Welcome to the Koha Installer') . qq|...|;
+Directories to use for installation (configuration, intranet, opac, logs)
 
-The heading function takes one string, the text to be displayed as
-the heading, and returns a formatted heading (currently formatted
-with ANSI colours).
+=item $domainname, $realhttpdconf, $httpduser, $httpdgroup, $servername, $svr_admin, $opacport, $intranetport, $hostname, $user, $pass
 
-This reduces the likelihood of pod2man(1) etc. misinterpreting
-a line of equal signs as illegal POD directives.
+Apache configuration settings
+
+=item $mysqldir, $database, $mysqluser, $mysqlpass, $mycnf, $mytmpcnf
+
+MySQL configuration settings
 
 =cut
 
-#my $termios = POSIX::Termios->new();
-#$termios->getattr();
-#my $terminal = Term::Cap->Tgetent({OSPEED=>$termios->getospeed()});
+use vars qw( $kohaversion $newversion $language
+  $etcdir $intranetdir $opacdir $kohalogdir
+  $domainname $realhttpdconf $httpduser $httpdgroup
+  $servername $svr_admin $opacport $intranetport
+  $hostname $user $pass
+  $mysqldir $database $mysqluser $mysqlpass );
+
 my $clear_string = "\n\n"; #MJR: was $terminal->Tputs('cl');
 
+my $mycnf = $ENV{HOME}."/.my.cnf";
+my $mytmpcnf = mktemp("my.cnf.koha.XXXXXX");
+chomp($mytmpcnf);
+
+=back
+
+=head2 Internal functions (not meant to be used outside of Install.pm)
+
+=over 4
+
+=item C<heading($)>
+
+Takes: a string to be displayed as the heading
+
+Returns: a formatted heading (currently with ANSI colours).
+
+This reduces the likelihood of pod2man(1) etc. misinterpreting
+a line of equal signs as illegal POD directives.
+
+=cut
+
 sub heading ($) {
   my $title = shift;
   my $bal = 5;
   return($clear_string.ON_BLUE.WHITE.BOLD." "x$bal.uc($title)." "x$bal.RESET."\n\n");
 }
 
-my $mycnf = $ENV{HOME}."/.my.cnf";
-my $mytmpcnf = mktemp("my.cnf.koha.XXXXXX");
-chomp($mytmpcnf);
-
 my $messages;
 $messages->{'continuing'}->{en}="Great!  Continuing...\n\n";
 $messages->{'WelcomeToKohaInstaller'}->{en} =
@@ -288,12 +303,10 @@ Press <ENTER> to exit the installer: |;
 
 #'
 
-=item completeupgrade
-
-   completeupgrade
+=item C<completeupgrade()>
 
 Display a message describing what may need changing in httpd.conf
-and any other instructions
+and any other instructions for just before exit.
 
 =cut
 
@@ -301,6 +314,12 @@ sub completeupgrade {
        showmessage(getmessage('UpgradeCompleted',[$intranetdir,$intranetdir,$intranetdir,$opacdir,$opacdir,$intranetdir]),'PressEnter');
 }
 
+=item C<releasecandidatewarning()>
+
+Display a warning about upgrading to a public test release.
+
+=cut
+
 sub releasecandidatewarning {
     my $message=getmessage('ReleaseCandidateWarning', [$newversion, $newversion]);
     my $answer=showmessage($message, 'yn', 'n');
@@ -314,6 +333,14 @@ sub releasecandidatewarning {
     };
 }
 
+=item C<read_autoinstall_file($)>
+
+Takes: a configuration file describing the installation
+
+Returns: a hashref of the configuration
+
+=cut
+
 sub read_autoinstall_file
 {
        my $fname = shift;      # Config file to read
@@ -357,14 +384,10 @@ sub read_autoinstall_file
 
 =over 4
 
-=cut
+=item C<setlanguage($)>
 
-=item setlanguage
-
-    setlanguage('en');
-
-Sets the installation language, normally "en" (English).
-In fact, only "en" is supported.
+Sets the installation language code, normally "en" (English).
+Only "en" is supported so far.
 
 =cut
 
@@ -372,9 +395,7 @@ sub setlanguage ($) {
     ($language) = @_;
 }
 
-=item setdomainname
-
-    setdomainname('example.org');
+=item C<setdomainname($)>
 
 Sets the domain name of the host.
 
@@ -387,9 +408,7 @@ sub setdomainname ($) {
     ($domainname) = @_;
 }
 
-=item setetcdir
-
-    setetcdir('/etc');
+=item C<setetcdir($)>
 
 Sets the sysconfdir, normally /etc.
 This should be an absolute path; a trailing / is not required.
@@ -402,11 +421,9 @@ sub setetcdir ($) {
     if (! ((-d $etcdir) && (-w $etcdir))) { die("Cannot write to $etcdir! Please set the etcdir environment variable to a writeable directory.\nFailed"); }
 }
 
-=item getkohaversion
-
-    getkohaversion();
+=item C<getkohaversion()>
 
-Gets the Koha version as known by the previous config file.
+Returns: the Koha version as known by the previous config file..
 
 =cut
 
@@ -414,23 +431,21 @@ sub getkohaversion () {
     return($kohaversion);
 }
 
-=item setkohaversion
-
-    setkohaversion('1.3.3RC26');
+=item C<setkohaversion($)>
 
 Sets the Koha version as known by the installer.
 
+Note: function is now misnamed, setting $newversion not $kohaversion
+
 =cut
 
 sub setkohaversion ($) {
     ($newversion) = @_;
 }
 
-=item getservername
+=item C<getservername()>
 
-    my $servername = getservername;
-
-Gets the name of the Koha virtual server as specified by the user.
+Returns: the name of the Koha virtual server as specified by the user.
 
 =cut
 
@@ -438,12 +453,10 @@ sub getservername () {
     $servername;
 }
 
-=item getopacport
-
-    $port = getopacport;
+=item C<getopacport()>
 
-Gets the port that will run the Koha OPAC virtual server,
-as specified by the user.
+Returns the port that will run the Koha OPAC virtual server, as
+specified by the user.
 
 =cut
 
@@ -451,12 +464,10 @@ sub getopacport () {
     $opacport;
 }
 
-=item getintranetport
+=item C<getintranetport()>
 
-    $port = getintranetport;
-
-Gets the port that will run the Koha INTRANET virtual server,
-as specified by the user.
+Returns the port that will run the Koha INTRANET virtual server, as
+specified by the user.
 
 =cut
 
@@ -470,15 +481,14 @@ sub getintranetport () {
 
 =over 4
 
-=cut
+=item C<dirname($)>
 
-=item dirname
+Does the equivalent of dirname(1).
 
-    dirname $path;
+Takes: a path
 
-Does the equivalent of dirname(1). Given a path $path, return the
-parent directory of $path (best guess), except when $path seems to
-be the same as /, in which case $path itself is returned unchanged.
+Returns: parent directory of path (best guess), except when the path
+seems to be the same as /, in which case it is returned unchanged.
 
 =cut
 
@@ -494,29 +504,28 @@ sub dirname ($;$) {
     return $path;
 }
 
-=item mkdir_parents
+=item C<mkdir_parents($;$)>
+
+Does the equivalent of mkdir -p, or mkdir --parents.
 
-    mkdir_parents $path;
-    mkdir_parents $path, $mode;
+Takes: a path and an optional mode.
 
-Does the equivalent of mkdir -p, or mkdir --parents. Given a path $path,
-create the directory $path, recursively creating any intermediate
-directories. If $mode is given, the directory will be created with
-mode $mode.
+Create the directory path, recursively creating any intermediate
+directories, with the access mode if given.
 
-WARNING: If $path already exists, mkdir_parents will just return
-successfully (just like mkdir -p), whether the mode of $path conforms
-to $mode or not. (This is the behaviour of the mkdir -p command.)
+WARNING: If the path already exists, mkdir_parents will just return
+successfully (just like mkdir -p), whether the mode of path conforms
+to the mode or not. (This is the behaviour of the mkdir -p command.)
 
 =cut
 
-sub mkdir_parents {
+sub mkdir_parents ($;$) {
     my($path, $mode) = @_;
     my $ok = -d($path)? 1: defined $mode? mkdir($path, $mode): mkdir($path);
 
     if (!$ok && $! == ENOENT) {
        my $parent = dirname($path);
-       $ok = mkdir_parents($parent, $mode);
+       $ok = &mkdir_parents($parent, $mode);
 
        # retry and at the same time make sure that $! is set correctly
        $ok = defined $mode? mkdir($path, $mode): mkdir($path);
@@ -524,22 +533,18 @@ sub mkdir_parents {
     return $ok;
 }
 
+=item C<getmessage($;$)>
 
-=item getmessage
+Takes: a message identifier, an array reference
 
-    getmessage($msgid);
-    getmessage($msgid, $variables);
+Returns: a localized message (format string)
 
-Gets a localized message (format string) with message id $msgid,
-and, if an array reference of variables $variables is given,
-substitutes variables in the format string with @$variables.
-Returns the found message string, with variable substitutions
-if specified.
+The first message must be the message identifier corresponding to a
+defined message string (a valid key to the $Installer::messages hash).
+The second parameter may be an array reference of variables,
+to be substituted into the format string.
 
-$msgid must be the message identifier corresponding to a defined
-message string (a valid key to the $messages hash in the Installer
-package). getmessage throws an exception if the message cannot be
-found.
+getmessage throws an exception if the message cannot be found.
 
 =cut
 
@@ -554,40 +559,25 @@ sub getmessage {
 }
 
 
-=item showmessage
-
-    showmessage($message, 'none');
-    showmessage($message, 'none', undef, $noclear);
-
-    $result = showmessage($message, 'yn');
-    $result = showmessage($message, 'yn', $defaultresponse);
-    $result = showmessage($message, 'yn', $defaultresponse, $noclear);
-
-    $result = showmessage($message, 'restrictchar CHARS');
-    $result = showmessage($message, 'free');
-    $result = showmessage($message, 'silentfree');
-    $result = showmessage($message, 'numerical');
-    $result = showmessage($message, 'email');
-    $result = showmessage($message, 'PressEnter');
+=item C<showmessage($$;$$)>
 
 Shows a message and optionally gets a response from the user.
 
-The first two arguments, the message and the response type,
-are mandatory.  The message must be the actual string to
-display; the caller is responsible for calling getmessage if
-required.
+Takes:
+message string, question type, default response, noclear
 
-The response type must be one of "none", "yn", "free", "silentfree"
-"numerical", "email", "PressEnter", or a string consisting
-of "restrictchar " followed by a list of allowed characters
-(space can be specified). (Case is not significant, but case is
-significant in the list of allowed characters.) If a response
-type other than the above-listed is specified, the result is
-undefined.
+Returns: response string
 
-Note that the response type "yn" is equivalent to "restrictchar yn".
-Because "restrictchar" is case-sensitive, the user is expected
-to enter "y" or "n" in lowercase only.
+The message must be the actual string to display; the caller is
+responsible for calling getmessage if required.
+
+Question type must be 'none' for no response, 'yn' for a yes/no
+question, 'restrictchar CHARS' for one letter from CHARS (Case is not
+significant, but case is significant in the list of allowed
+characters), 'free' for any string, 'silentfree' for any string
+entered without on-screen display, 'numerical', 'email' or
+'PressEnter'.  If a response type other than the above-listed is
+specified, the result is undefined.
 
 Note that the response type of "email" does not actually
 guarantee that the returned value is a well-formed RFC-822
@@ -597,28 +587,27 @@ string that is looks reasonably likely to be an email address
 in the "real world", given the premise that the user is trying
 to enter a real email address.
 
-If a response type other than "none" or "PressEnter" is
-specified, a third argument, specifying the default value, can
-be specified:  If this default response is not specified, the
-default response is the first allowed character if the response
-type is "restrictchar", otherwise the default response is the
-empty string. This default response is used when the user does
-not specify a value (i.e., presses Enter without typing in
-anything), showmessage will assume that the default response is
-the user's response.
+If a response type other than "none" or "PressEnter" is specified, a
+third argument, specifying the default value, can be specified: If
+this default response is not specified, the default response is the
+first allowed character if the response type is "restrictchar",
+otherwise the default response is the empty string. This default
+response is used when the user does not specify a value (i.e., presses
+Enter without typing in anything), showmessage will assume that the
+default response is the user's response.
 
 Note that because the response type "yn" is equivalent to
-"restrictchar yn", the default value for response type "yn",
-if unspecified, is "y".
+"restrictchar yn", the default value for response type "yn", if
+unspecified, is "y".
 
-The screen is normally cleared before the message is displayed;
-if a fourth argument is specified and is nonzero, this
-screen-clearing is not done.
+The screen is normally cleared before the message is displayed; if a
+fourth argument is specified and is nonzero, this screen-clearing is
+not done.
 
 =cut
 #'
 
-sub showmessage {
+sub showmessage ($$;$$) {
     #MJR: Maybe refactor to use anonymous functions that
     # check the responses instead of RnP branching.
     my $message=join('',fill('','',(shift)));
@@ -703,11 +692,7 @@ sub showmessage {
 }
 
 
-=back
-
-=item startsysout
-
-       startsysout;
+=item C<startsysout()>
 
 Changes the display to show system output until the next showmessage call.
 At the time of writing, this means using red text.
@@ -718,18 +703,13 @@ sub startsysout {
        print RED."\n";
 }
 
-
 =back
 
 =head2 Subtasks of doing an installation
 
 =over 4
 
-=cut
-
-=item checkabortedinstall
-
-    checkabortedinstall;
+=item C<checkabortedinstall()>
 
 Checks whether a previous installation process has been abnormally
 aborted, by checking whether $etcidr/koha.conf is a symlink matching
@@ -761,15 +741,14 @@ database is already created.
     }
 }
 
-=item checkpaths
-
-       checkpaths;
+=item C<checkpaths()>
 
 Make sure that we loaded the right dirs from an old koha.conf
 
+FIXME: needs update to use Install.pm
+
 =cut
 
-#FIXME: update to use Install.pm
 sub checkpaths {
 if ($opacdir && $intranetdir) {
     print qq|
@@ -828,17 +807,15 @@ if (!$opacdir || !$intranetdir) {
 
 }
 
-=item checkperlmodules
-
-    checkperlmodules;
+=item C<checkperlmodules(;$)>
 
-Test whether the version of Perl is new enough, whether Perl is
-found at the expected location, and whether all required modules
-have been installed.
+Test whether the version of Perl is new enough, whether Perl is found
+at the expected location, and whether all required modules have been
+installed.
 
 =cut
 
-sub checkperlmodules {
+sub checkperlmodules(;$) {
 #
 # Test for Perl and Modules
 #
@@ -859,8 +836,50 @@ sub checkperlmodules {
        unless (eval {require Digest::MD5})      { push @missing,"Digest::MD5" };
        unless (eval {require MARC::Record})     { push @missing,"MARC::Record" };
        unless (eval {require Mail::Sendmail})   { push @missing,"Mail::Sendmail" };
-       unless (eval {require PDF::API2})   { push @missing,"PDF::API2" };
 # The following modules are not mandatory, depends on how the library want to use Koha
+       unless (eval {require PDF::API2})   { 
+                       if ($#missing>=0) { # only when $#missing >= 0 so this isn't fatal
+                               push @missing,"You will need PDF::API2 for barcode generator";
+                       }
+       }
+       unless (eval {require GD::Barcorde})   { 
+                                    if ($#missing>=0) { # only when $#missing >= 0 so this isn't fatal
+                               push @missing,"You will need GD::Barcode for the new barcode generator";
+                                    }
+                    }
+       unless (eval {require GD::Barcorde})   { 
+                       if ($#missing>=0) { # only when $#missing >= 0 so this isn't fatal
+                               push @missing,"You will need GD::Barcode for the new barcode generator";
+                       }
+       }
+       unless (eval {require Data::Random})   { 
+                                    if ($#missing>=0) { # only when $#missing >= 0 so this isn't fatal
+                               push @missing,"You will need Data::Random for the new barcode generator";
+                                    }
+                    }
+                unless (eval {require PDF::Reuse::Barcode})   {
+                                    if ($#missing>=0) { # only when $#missing >= 0 so this isn't fatal
+                               push @missing,"You will need PDF::Reuse::Barcode for the new barcode generator";
+                                    }
+                    }
+                unless (eval {require PDF::Report})   {
+                                    if ($#missing>=0) { # only when $#missing >= 0 so this isn't fatal
+                                            push @missing,"You will need PDF::Report for spine and barcode printing"
+                                    }
+                    }
+
+                unless (eval {require GD::Barcode})   {
+                                    if ($#missing>=0) { # only when $#missing >= 0 so this isn't fatal
+                                            push @missing,"You will need GD::Barcode for spine and barcode printing"
+                                    }
+                    }
+
+                unless (eval {require GD::Barcode::UPCE})   {
+                                    if ($#missing>=0) { # only when $#missing >= 0 so this isn't fatal
+                                            push @missing,"You will need GD::Barcode::UPCE for spine and barcode printing"
+                                    }
+                    }
+
        unless (eval {require Net::LDAP})       {
                if ($#missing>=0) { # only when $#missing >= 0 so this isn't fatal
                                push @missing, "Net::LDAP";
@@ -877,6 +896,18 @@ sub checkperlmodules {
                        push @missing, "Net::Z3950";
                }
     }
+    unless (eval {require LWP::Simple})       {
+               showmessage(getmessage('LWP::Simple'), 'PressEnter', '', 1);
+               if ($#missing>=0) { # see above note
+                       push @missing, "LWP::Simple";
+               }
+    }
+    unless (eval {require XML::Simple})       {
+               showmessage(getmessage('XML::Simple'), 'PressEnter', '', 1);
+               if ($#missing>=0) { # see above note
+                       push @missing, "XML::Simple";
+               }
+    }
 
 #
 # Print out a list of any missing modules
@@ -939,19 +970,17 @@ We could not create %s, but continuing anyway...
 
 
 
-=item getinstallationdirectories
-
-    getinstallationdirectories;
+=item C<getinstallationdirectories(;$)>
 
-Get the various installation directories from the user, and then
-create those directories (if they do not already exist).
+Asks the user for the various installation directories, and then
+creates those directories (if they do not already exist).
 
-These pieces of information are saved to global variables; the
-function does not return any values.
+These pieces of information are saved to variables; the function does
+not return any values.
 
 =cut
 
-sub getinstallationdirectories {
+sub getinstallationdirectories(;$) {
        my ($auto_install) = @_;
        if (!$ENV{prefix}) { $ENV{prefix} = "/usr/local"; }
     $opacdir = $ENV{prefix}.'/koha/opac';
@@ -1024,11 +1053,10 @@ You must specify different directories for the OPAC and INTRANET files!
     }
 }
 
-=item getmysqldir
+=item C<getmysqldir()>
 
-       getmysqldir;
-
-Get the MySQL database server installation directory, automatically if possible.
+Returns: the MySQL database server installation directory,
+automatically if possible and from the user otherwise.
 
 =cut
 
@@ -1040,7 +1068,7 @@ The file mysqladmin should be in bin/mysqladmin under the directory that you giv
 
 MySQL installation directory: |;
 #'
-sub getmysqldir {
+sub getmysqldir () {
     foreach my $mysql (qw(/usr/local/mysql
                          /opt/mysql
                          /usr/local
@@ -1059,13 +1087,11 @@ sub getmysqldir {
     return($mysqldir);
 }
 
-=item getdatabaseinfo
-
-    getdatabaseinfo;
+=item C<getdatabaseinfo(;$)>
 
-Get various pieces of information related to the Koha database:
-the name of the database, the host on which the SQL server is
-running, and the database user name.
+Asks for various pieces of information related to the Koha database:
+the name of the database, the host on which the SQL server is running,
+and the database user name.
 
 These pieces of information are saved to global variables; the
 function does not return any values.
@@ -1108,7 +1134,7 @@ You must not use a blank password for your MySQL user.
 Press <ENTER> to try again: 
 |;
 
-sub getdatabaseinfo {
+sub getdatabaseinfo(;$) {
        my ($auto_install) = @_;
     $database = 'Koha';
     $hostname = 'localhost';
@@ -1162,13 +1188,11 @@ sub getdatabaseinfo {
 
 
 
-=item getapacheinfo
-
-    getapacheinfo;
+=item C<getapacheinfo(;$)>
 
-Get various pieces of information related to the Apache server:
-the location of the configuration file and, if needed, the Unix
-user that the Koha CGI will be run under.
+Detects or asks for various pieces of information related to the
+Apache server: the location of the configuration file and, if needed,
+the Unix user that the Koha CGI will be run under.
 
 These pieces of information are saved to global variables; the
 function does not return any values.
@@ -1210,7 +1234,7 @@ The userid %s is not a valid userid on this system.
 
 Press <ENTER> to continue: |;
 
-sub getapacheinfo {
+sub getapacheinfo (;$) {
        my ($auto_install) = @_;
     my @confpossibilities;
 
@@ -1299,13 +1323,11 @@ sub getapacheinfo {
 }
 
 
-=item getapachevhostinfo
+=item C<getapachevhostinfo(;$)>
 
-    getapachevhostinfo;
-
-Gets various pieces of information related to virtual hosting:
-the webmaster email address, virtual hostname, and the ports
-that the OPAC and INTRANET modules run on.
+Asks for various pieces of information related to virtual hosting: the
+webmaster email address, virtual hostname, and the ports that the OPAC
+and INTRANET modules run on.
 
 These pieces of information are saved to global variables; the
 function does not return any values.
@@ -1359,7 +1381,7 @@ the OPAC port (%s).
 Enter the Intranet Port [%s]: |;
 
 
-sub getapachevhostinfo {
+sub getapachevhostinfo (;$) {
        my ($auto_install) = @_;
     $svr_admin = "webmaster\@$domainname";
     $servername=`hostname`;
@@ -1396,16 +1418,10 @@ sub getapachevhostinfo {
 }
 
 
-=item updateapacheconf
-
-    updateapacheconf;
-
-Updates the Apache config file according to parameters previously
-specified by the user.
+=item C<updateapacheconf(;$)>
 
-It will append fully-commented directives at the end of the original
-Apache config file.  The old config file is renamed with an extension
-of .prekoha.
+Creates the Apache config file according to parameters previously
+specified by the user as F<$etcdir/koha-httpd.conf>.
 
 If you need to uninstall Koha for any reason, the lines between
 
@@ -1442,7 +1458,7 @@ configuration.
 
 Press <ENTER> to continue: |;
 
-sub updateapacheconf {
+sub updateapacheconf (;$) {
        my ($auto_install)=@_;
     my $logfiledir=$kohalogdir;
     my $httpdconf = $etcdir."/koha-httpd.conf";
@@ -1456,7 +1472,7 @@ sub updateapacheconf {
     open HC, "<$realhttpdconf";
     while (<HC>) {
        if (/^\s*#\s*LoadModule env_module /) {
-           showmessage(getmessage('ApacheConfigMissingModules'));
+           showmessage(getmessage('ApacheConfigMissingModules'),'none');
            $envmodule=1;
        }
        if (/\s*LoadModule includes_module / ) {
@@ -1550,18 +1566,16 @@ EOP
 }
 
 
-=item basicauthentication
-
-    basicauthentication;
-
-Asks the user whether HTTP basic authentication is wanted, and,
-if so, the user name and password for the basic authentication.
-
-These pieces of information are saved to global variables; the
-function does not return any values.
-
-=cut
-
+# =item C<basicauthentication(;$)>
+# 
+# Asks the user whether HTTP basic authentication is wanted, and,
+# if so, the user name and password for the basic authentication.
+# 
+# These pieces of information are saved to global variables; the
+# function does not return any values.
+# 
+# =cut
+# 
 # $messages->{'IntranetAuthenticationQuestion'}->{en} =
 #    heading('LIBRARIAN AUTHENTICATION') . qq|
 # The Librarian site can be password protected using
@@ -1612,16 +1626,17 @@ function does not return any values.
 # }
 
 
-=item installfiles
-
-    installfiles
+=item C<installfiles(;$$)>
 
-Install the Koha files to the specified OPAC and INTRANET
+Copy the Koha files to the specified OPAC and INTRANET
 directories (usually in /usr/local/koha).
 
-The koha.conf file is created, but as koha.conf.tmp. The
-caller is responsible for calling finalizeconfigfile when
-installation is completed, to rename it back to koha.conf.
+Creates the koha.conf file, but as koha.conf.tmp. The caller is
+responsible for calling C<finalizeconfigfile(;$)> when installation is
+completed, to rename it back to koha.conf.
+
+The first parameter may be a marker to say this is a new installation,
+rather than an upgrade.
 
 =cut
 
@@ -1645,7 +1660,7 @@ $messages->{'CopyingFiles'}->{en}="Copying %s to %s.\n";
 
 
 
-sub installfiles {
+sub installfiles (;$$) {
 
        my ($is_first_install,$auto_install) = @_;
        # $is_install is set if it's a fresh install and not an upgrade. If it's an upgrade, copy old files.
@@ -1727,9 +1742,7 @@ opachtdocs=$opacdir/htdocs/opac-tmpl
 }
 
 
-=item databasesetup
-
-    databasesetup;
+=item C<databasesetup(;$)>
 
 Finds out where the MySQL utitlities are located in the system,
 then create the Koha database structure and MySQL permissions.
@@ -1741,7 +1754,7 @@ $messages->{'MysqlRootPassword'}->{en} =
 To create the koha database, please enter your
 mysql server's root user password:
 
-Password: |;   #'
+Password: |;
 
 $messages->{'CreatingDatabase'}->{en} = heading('CREATING DATABASE') . qq|
 Creating the MySQL database for Koha...
@@ -1787,7 +1800,7 @@ $messages->{'BranchCode'}->{en}="Branch Code (4 letters or numbers) [%s]: ";
 $messages->{'PrinterQueue'}->{en}="Printer Queue [%s]: ";
 $messages->{'PrinterName'}->{en}="Printer Name [%s]: ";
 
-sub databasesetup {
+sub databasesetup (;$) {
        my ($auto_install) = @_;
     $mysqluser = 'root';
     $mysqlpass = '';
@@ -1805,12 +1818,14 @@ sub databasesetup {
        setmysqlclipass($mysqlpass);
        # Set up permissions
        startsysout();
-       print system("$mysqldir/bin/mysql -u$mysqluser -e \"insert into user (Host,User,Password) values ('$hostname','$user',password('$pass'))\" mysql\;");
-       system("$mysqldir/bin/mysql -u$mysqluser -e \"insert into db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv, index_priv, alter_priv) values ('%','$database','$user','Y','Y','Y','Y','Y','Y','Y','Y')\" mysql");
-       system("$mysqldir/bin/mysqladmin -u$mysqluser reload");
+       print system("$mysqldir/bin/mysql -u$mysqluser -e \"insert into user (Host,User,Password) values ('$hostname','$user',password('$pass'))\" -h$hostname mysql\;");
+       system("$mysqldir/bin/mysql -u$mysqluser -e \"insert into db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv, index_priv, alter_priv) values ('%','$database','$user','Y','Y','Y','Y','Y','Y','Y','Y')\" -h$hostname mysql");
+       system("$mysqldir/bin/mysqladmin -u$mysqluser -h$hostname reload");
+
+       my $result=system("$mysqldir/bin/mysqladmin", "-u$mysqluser", "create", "$database");
+       system("$mysqldir/bin/mysql '-u$mysqluser' -e \"GRANT ALL PRIVILEGES on ".$database.".* to '$user' IDENTIFIED BY '$pass' \" mysql");
        # Change to admin user login
        setmysqlclipass($pass);
-       my $result=system("$mysqldir/bin/mysqladmin", "-u$user", "create", "$database");
        if ($result) {
                showmessage(getmessage('CreatingDatabaseError'),'PressEnter', '', 1);
        } else {
@@ -1822,9 +1837,7 @@ sub databasesetup {
 }
 
 
-=item updatedatabase
-
-    updatedatabase;
+=item C<updatedatabase(;$)>
 
 Updates the Koha database structure, including the addition of
 MARC tables.
@@ -1844,8 +1857,10 @@ $messages->{'UpdateMarcTables'}->{en} =
    heading('MARC FIELD DEFINITIONS') . qq|
 You can import MARC settings for:
 
-  1 MARC21
-  2 UNIMARC
+  1 MARC21 in english
+  2 UNIMARC in french
+  3 UNIMARC in english
+  4 UNIMARC in ukrainian
   N none
 
 NOTE: If you choose N,
@@ -1873,7 +1888,7 @@ change it from the system preferences screen in the librarian sit.
 
 Which language do you choose? |;
 
-sub updatedatabase {
+sub updatedatabase (;$) {
        my ($auto_install) = @_;
     # At this point, $etcdir/koha.conf must exist, for C4::Context
     $ENV{"KOHA_CONF"}=$etcdir.'/koha.conf';
@@ -1891,7 +1906,7 @@ sub updatedatabase {
                $response=$auto_install->{UpdateMarcTables};
                print ON_YELLOW.BLACK."auto-setting UpdateMarcTable to : $response".RESET."\n";
        } else {
-               $response=showmessage(getmessage('UpdateMarcTables'), 'restrictchar 12Nn', '1');
+               $response=showmessage(getmessage('UpdateMarcTables'), 'restrictchar 1234Nn', '1');
        }
        startsysout();
        if ($response eq '1') {
@@ -1900,6 +1915,12 @@ sub updatedatabase {
        if ($response eq '2') {
                system("cat scripts/misc/marc_datas/unimarc_fr/structure_def.sql | $mysqldir/bin/mysql '-u$user' '$database'");
        }
+       if ($response eq '3') {
+               system("cat scripts/misc/marc_datas/unimarc_en/structure_def.sql | $mysqldir/bin/mysql '-u$user' '$database'");
+       }
+       if ($response eq '4') {
+               system("cat scripts/misc/marc_datas/unimarc_uk/structure_def.sql | $mysqldir/bin/mysql '-u$user' '$database'");
+       }
        delete($ENV{"KOHA_CONF"});
 
        print RESET."\nFinished updating of database. Press <ENTER> to continue..." unless ($auto_install->{NoPressEnter});
@@ -1907,19 +1928,17 @@ sub updatedatabase {
 }
 
 
-=item populatedatabase
-
-    populatedatabase;
+=item C<populatedatabase(;$)>
 
-Populate the non-MARC tables. If the user wants to install the
-sample data, install them.
+Populates the non-MARC tables and installs sample data,
+if wanted.
 
 =cut
 
 $messages->{'ConfirmFileUpload'}->{en} = qq|
 Confirm loading of this file into Koha  [Y]/N: |;
 
-sub populatedatabase {
+sub populatedatabase (;$) {
        my ($auto_install) = @_;
        my $input;
        my $response;
@@ -1951,9 +1970,9 @@ sub populatedatabase {
                $branchcode or $branchcode='DEF';
 
                startsysout();
-               system("$mysqldir/bin/mysql '-u$user' -e \"insert into branches (branchcode,branchname,issuing) values ('$branchcode', '$branch', 1)\" '$database'");
-               system("$mysqldir/bin/mysql '-u$user' -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'IS')\" '$database'");
-               system("$mysqldir/bin/mysql '-u$user' -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'CU')\" '$database'");
+               system("$mysqldir/bin/mysql '-u$user' -e \"insert into branches (branchcode,branchname,issuing) values ('$branchcode', '$branch', 1)\" $database");
+               system("$mysqldir/bin/mysql '-u$user' -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'IS')\" $database");
+               system("$mysqldir/bin/mysql '-u$user' -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'CU')\" $database");
 
                my $printername='lp';
                my $printerqueue='/dev/lp0';
@@ -1972,7 +1991,7 @@ sub populatedatabase {
                        $printerqueue=~s/[^A-Za-z0-9]//g;
                }
                startsysout();  
-               system("$mysqldir/bin/mysql '-u$user' -e \"insert into printers (printername,printqueue,printtype) values ('$printername', '$printerqueue', '')\" '$database'");
+               system("$mysqldir/bin/mysql '-u$user' -e \"insert into printers (printername,printqueue,printtype) values ('$printername', '$printerqueue', '')\" $database");
        }
        my $language;
        if ($auto_install->{Language}) {
@@ -1982,7 +2001,7 @@ sub populatedatabase {
                $language=showmessage(getmessage('Language'), 'free', 'en');
        }
        startsysout();  
-       system("$mysqldir/bin/mysql '-u$user' -e \"update systempreferences set value='$language' where variable='opaclanguages'\" '$database'");
+       system("$mysqldir/bin/mysql '-u$user' -e \"update systempreferences set value='$language' where variable='opaclanguages'\" $database");
        my @dirs;
        if (-d "scripts/misc/sql-datas") {
                # ask for directory to look for files to append
@@ -2056,11 +2075,9 @@ if you confirm, the file will be added to the DB
        }
 }
 
-=item restartapache
+=item C<restartapache(;$)>
 
-    restartapache;
-
-Asks the user whether to restart Apache, and restart it if the user
+Asks the user whether to restart Apache, and restarts it if the user
 wants so.
 
 =cut
@@ -2071,7 +2088,7 @@ The installer can do this if you are using Apache and give the root password.
 
 Would you like to try to restart Apache now?  [Y]/N: |;
 
-sub restartapache {
+sub restartapache (;$) {
        my ($auto_install)=@_;
        my $response;
     $response=showmessage(getmessage('RestartApache'), 'yn', 'y') unless ($auto_install->{NoPressEnter});
@@ -2090,11 +2107,9 @@ sub restartapache {
        }
 }
 
-=item backupkoha
-
-   backupkoha;
+=item C<backupkoha(;$)>
 
-This function attempts to back up all koha's details.
+Attempts to make backup copies of all koha's details.
 
 =cut
 
@@ -2119,7 +2134,7 @@ File Listing
 Does this look right? ([Y]/N): |;
 
 #FIXME: rewrite to use Install.pm
-sub backupkoha {
+sub backupkoha () {
 if (!$ENV{prefix}) { $ENV{prefix} = "/usr/local"; }
 my $backupdir=$ENV{prefix}.'/backups';
 
@@ -2153,7 +2168,7 @@ $year+=1900;
 my $date= sprintf "%4d-%02d-%02d_%02d:%02d:%02d", $year, $month, $day,$hr,$min,$sec;
 
 setmysqlclipass($pass); 
-open (MD, "$mysqldir/bin/mysqldump '--user=$user' --host=$hostname '$database'|");
+open (MD, "$mysqldir/bin/mysqldump --user=$user --host=$hostname $database|");
 
 (open BF, ">$backupdir/Koha.backup_$date") || (die "Error opening up backup file $backupdir/Koha.backup_$date: $!\n");
 
@@ -2194,13 +2209,11 @@ Aborting.  The database dump is located in:
 
 }
 
-=item finalizeconfigfile
+=item C<finalizeconfigfile()>
 
-   finalizeconfigfile;
-
-This function must be called when the installation is complete,
-to rename the koha.conf.tmp file to koha.conf.
+Renames F<koha.conf.tmp> file to F<koha.conf>.
 
+This file must be renamed when the installation is complete,
 Currently, failure to rename the file results only in a warning.
 
 =cut
@@ -2221,19 +2234,15 @@ EOF
 }
 
 
-=item loadconfigfile
-
-   loadconfigfile
-
-Open the existing koha.conf file and get its values,
-saving the values to some global variables.
+=item C<loadconfigfile()>
 
-If the existing koha.conf file cannot be opened for any reason,
-the file is silently ignored.
+Opens the existing koha.conf file and gets its values, saving the
+values to some global variables.  If the existing koha.conf file
+cannot be opened for any reason, the file is silently ignored.
 
 =cut
 
-sub loadconfigfile {
+sub loadconfigfile () {
     my %configfile;
 
        #MJR: reverted to r1.53.  Please call setetcdir().  Do NOT hardcode this.