<<

NAME

C4::Installer

SYNOPSIS

 use C4::Installer;
 my $installer = C4::Installer->new();
 my $all_languages = getAllLanguages();
 my $error = $installer->load_db_schema();
 my $list;
 #fill $list with list of sql files
 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.

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.

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, UNIMARC or NORMARC.

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

set_version_syspref

  $installer->set_version_syspref();

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

set_languages_syspref

  $installer->set_languages_syspref();

Add the installation language to 'language' and 'opaclanguages' system preferences if different from 'en'

process_yml_table

  my $query_info   = $installer->process_yml_table($table);

Analyzes a table loaded in YAML format. Returns the values required to build an insert statement.

load_sql

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

Runs the specified input file using a sql loader DBIx::RunSQL, or a yaml loader Returns any strings sent to STDERR

# FIXME This should be improved: sometimes the caller and load_sql warn the same error.

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>

<<