<<

NAME

C4::Installer

SYNOPSIS

 use C4::Installer;
 my $installer = C4::Installer->new();
 my $all_languages = getAllLanguages();
 my $error = $installer->load_db_schema();
 my $list = $installer->sql_file_list('en', 'marc21', { optional => 1, mandatory => 1 });
 my ($fwk_language, $error_list) = $installer->load_sql_in_order($all_languages, @$list);
 $installer->set_version_syspref();
 $installer->set_marcflavour_syspref('MARC21');

DESCRIPTION

METHODS

new

  my $installer = C4::Installer->new();

Creates a new installer.

marcflavour_list

  my ($marcflavours) = $installer->marcflavour_list($lang);

Return a arrayref of the MARC flavour sets available for the specified language $lang. Returns 'undef' if a directory for the language does not exist.

marc_framework_sql_list

  my ($defaulted_to_en, $list) = 
     $installer->marc_framework_sql_list($lang, $marcflavour);

Returns in $list a structure listing the filename, description, section, and mandatory/optional status of MARC framework scripts available for $lang and $marcflavour.

If the $defaulted_to_en return value is true, no scripts are available for language $lang and the 'en' ones are returned.

sample_data_sql_list

  my ($defaulted_to_en, $list) = $installer->sample_data_sql_list($lang);

Returns in $list a structure listing the filename, description, section, and mandatory/optional status of sample data scripts available for $lang. If the $defaulted_to_en return value is true, no scripts are available for language $lang and the 'en' ones are returned.

sql_file_list

  my $list = $installer->sql_file_list($lang, $marcflavour, $subset_wanted);

Returns an arrayref containing the filepaths of installer SQL scripts available for laod. The $lang and $marcflavour arguments specify the desired language and MARC flavour. while $subset_wanted is a hashref containing possible named parameters 'mandatory' and 'optional'.

load_db_schema

  my $error = $installer->load_db_schema();

Loads the SQL script that creates Koha's tables and indexes. The return value is a string containing error messages reported by the load.

load_sql_in_order

  my ($fwk_language, $list) = $installer->load_sql_in_order($all_languages, @sql_list);

Given a list of SQL scripts supplied in @sql_list, loads each of them into the database and sets the FrameworksLoaded system preference to names of the scripts that were loaded.

The SQL files are loaded in alphabetical order by filename (not including directory path). This means that dependencies among the scripts are to be resolved by carefully naming them, keeping in mind that the directory name does *not* currently count.

FIXME: this is a rather delicate way of dealing with dependencies between the install scripts.

The return value $list is an arrayref containing a hashref for each "level" or directory containing SQL scripts; the hashref in turns contains a list of hashrefs containing a list of each script load and any error messages associated with the loading of each script.

FIXME: The $fwk_language code probably doesn't belong and needs to be moved to a different method.

set_marcflavour_syspref

  $installer->set_marcflavour_syspref($marcflavour);

Set the 'marcflavour' system preference. The incoming $marcflavour references to a subdirectory of installer/data/$dbms/$lang/marcflavour, and is normalized to MARC21 or UNIMARC.

FIXME: this method assumes that the MARC flavour will be either MARC21 or UNIMARC.

set_version_syspref

  $installer->set_version_syspref();

Set or update the 'Version' system preference to the current Koha software version.

load_sql

  my $error = $installer->load_sql($filename);

Runs a the specified SQL using the DB's command-line SQL tool, and returns any strings sent to STDERR by the command-line tool.

FIXME: there has been a long-standing desire to replace this with an SQL loader that goes through DBI; partly for portability issues and partly to improve error handling.

FIXME: even using the command-line loader, some more basic error handling should be added - deal with missing files, e.g.

get_file_path_from_name

  my $filename = $installer->get_file_path_from_name('script_name');

searches through the set of known SQL scripts and finds the fully qualified path name for the script that mathches the input.

returns undef if no match was found.

AUTHOR

C4::Installer is a refactoring of logic originally from installer/installer.pl, which was originally written by Henri-Damien Laurant.

Koha Development Team <http://koha-community.org/>

Galen Charlton <galen.charlton@liblime.com>

<<