Bugzilla::Install::Util - Utility functions that are useful both during installation and afterwards.
This module contains various subroutines that are used primarily during installation. However, these subroutines can also be useful to non-installation code, so they have been split out into this module.
The difference between this module and Bugzilla::Util is that this module is safe to use
anywhere in Bugzilla,
even during installation,
because it depends only on Bugzilla::Constants and built-in perl modules.
None of the subroutines are exported by default--you must explicitly export them.
bin_loc
On *nix systems,
given the name of a binary,
returns the path to that binary,
if the binary is in the PATH
.
get_version_and_os
Returns a hash containing information about what version of Bugzilla we're running, what perl version we're using, and what OS we're running on.
get_console_locale
Returns the language to use based on the LC_CTYPE value returned by the OS. If LC_CTYPE is of the form fr-CH, then fr is appended to the list.
init_console
Sets the ANSI_COLORS_DISABLED
and HTTP_ACCEPT_LANGUAGE
environment variables.
indicate_progress
This prints out lines of dots as a long update is going on, to let the user know where we are and that we're not frozen. A new line of dots will start every 60 dots.
Sample usage: indicate_progress({ total => $total,
current => $count,
every => 1 })
Here's some sample output with total = 1000
and every = 10
:
............................................................600/1000 (60%) ........................................
total
- The total number of items we're processing.current
- The number of the current item we're processing.every
- How often the function should print out a dot. For example, if this is 10, the function will print out a dot every ten items. Defaults to 1 if not specified.install_string
This is a very simple method of templating strings for installation. It should only be used by code that has to run before the Template Toolkit can be used. (See the comments at the top of the various Bugzilla::Install modules to find out when it's safe to use Template Toolkit.)
It pulls strings out of the strings.txt.pl "template" and replaces any variable surrounded by double-hashes (##) with a value you specify.
This allows for localization of strings used during installation.
Let's say your template string looks like this:
The ##animal## jumped over the ##plant##.
Let's say that string is called 'animal_jump_plant'. So you call the function like this:
install_string('animal_jump_plant', { animal => 'fox', plant => 'tree' });
That will output this:
The fox jumped over the tree.
$string_id
- The name of the string from strings.txt.pl.$vars
- A hashref containing the replacement values for variables inside of the string.template_include_path
Used by Bugzilla::Template and "install_string" to determine the directories where templates are installed. Templates can be installed in many places. They're listed here in the basic order that they're searched:
$extension
/template/$language
/$project
$extension
/template/$language
/custom$extension
/template/$language
/default$language
/$project
$language
/custom$language
/default$project
has to do with installations that are using the $ENV{PROJECT}
variable to have different "views" on a single Bugzilla.
The default directory includes templates shipped with Bugzilla.
The custom directory is a directory for local installations to override the default templates. Any individual template in custom will override a template of the same name and path in default.
$language
is a language code, en
being the default language shipped with Bugzilla. Localizers ship other languages.
$extension
is the name of any directory in the extensions/ directory. Each extension has its own directory.
Note that languages are sorted by the user's preference (as specified in their browser, usually), and extensions are sorted alphabetically.
include_languages
Used by Bugzilla::Template to determine the languages' list which are compiled with the browser's Accept-Language and the languages of installed templates.