Fink::Config(3) Fink documentation Fink::Config(3)NAMEFink::Config - Read/write the fink configuration
SYNOPSIS
use Fink::Config;
my $config = Fink::Config->new_with_path($config_file);
# General configuration file parameters
my $value = $config->param($key);
$config->set_param($key, $value);
$config->save;
# Configuration flags
my $bool = $config->has_flag($flag);
$config->set_flag($flag);
$config->clear_flag($flag);
# Specific configuration options
my $path = $config->get_path;
my $verbosity = $config->verbosity_level;
my $use_apt = $config->binary_requested;
# Tree initialization
my $apt_trees = apt_tree_default($distribution);
my $fink_trees= fink_tree_default($distribution);
# Tree management
my @trees = $config->get_treelist();
my $bool = $config->want_magic_tree($tree);
# Command-line parameters
my @args_left = $config->parse_options(@args);
my $value = get_option($key, $default);
set_options({ $key => $value, $key2 => ... });
DESCRIPTION
A class representing the fink configuration file as well as any command
line options. Fink::Config inherits from Fink::Base.
Fink::Config will not work without a Fink::Config object having been
made that contains a basepath. The fink program typically does this
for you. Since the variables Fink::Config exports use data from the
last initialized Fink::Config object, creating a second object is not
recommended.
Constructors
new
new_from_properties
Inherited from Fink::Base.
new_with_path
my $config = Fink::Config->new_with_path($config_file);
my $config = Fink::Config->new_with_path($config_file, \%defaults);
Reads a fink.conf file into a new Fink::Config object and
initializes Fink::Config globals from it.
If %defaults is given they will be used as defaults for any keys
not in the config file. For example...
my $config = Fink::Config->new_with_path($file, { Basepath => "/sw" });
Fink initialization
parse_options
my @args_left = $config->parse_options(@args);
Parse the global command-line options for Fink.
Tree initialization
apt_tree_default
my $apt_trees = apt_tree_default($distribution);
Returns a space-delimited list of the trees used by apt when
accessing a binary distribution supplied by fink. Prior to 10.6,
the list was "main crypto"; in 10.6 and later, it is "main".
fink_tree_default
my $fink_trees = fink_tree_default($distribution);
Returns a space-delimited list of the trees used by default when
configuring fink. This list is derived from
apt_tree_default($distribution), so only the latter needs to be
changed if things change in the future. Prior to 10.6, the list
was "local/main stable/main stable/crypto"; in 10.6 and later, it
is "local/main stable/main".
Configuration queries
get_path
my $path = $config->get_path;
Returns the path to the configuration file which $config
represents.
get_treelist
my @trees = $config->get_treelist;
Returns the trees which should be currently used. This depends on
the value of Trees in fink.conf, as well as any trees specified at
the command line.
want_magic_tree
my $bool = $config->want_magic_tree($tree);
Get whether or not the user desires the given magic tree to be
used. Current magic trees are:
virtual
The virtual packages created dynamically by Fink.
status
The packages discovered by their presence in the dpkg status
file, including all currently installed packages.
custom_treelist
my $bool = $config->custom_treelist;
Returns whether or not we're using a custom list of trees specified
at the command line.
param
param_default
param_boolean
has_param
set_param
Inherited from Fink::Base.
set_param also keeps a list of params that have been change since
the $config object was originally initialized or last did
$config->save()
save
$config->save;
Saves any changes made with set_param() to the config file. Only
lines of the file that correspond to params that were changed by
set_param() are altered.
write_sources_list
$config->write_sources_list;
Writes an appropriate $basepath/etc/apt/sources.list file, based on
configuration information. Called automatically by $config->save.
bindist_check_prefix
my $err = $config->bindist_check_prefix;
Check whether the current prefix allows use of the bindist. Returns
an error string if a problem exists, otherwise returns a false
value.
bindist_check_distro
my $err = $config->bindist_check_distro;
Check whether the current distribution allows use of the bindist.
Returns an error string if a problem exists, otherwise returns a
false value.
Exported Functions
These functions are exported only on request
set_options
set_options({ key1 => val1, key2 => val2, ...});
Sets global configuration options, mostly used for command line
options.
get_option
my $value = get_option($key);
my $value = get_option($key, $default_value);
Gets a global configuration option. If the $key was never set,
$default_value is returned.
verbosity_level
my $level = $config->verbosity_level();
Return the current verbosity level as a value 0-3, where 0 is the
quietest. This is affected by the --verbose and --quiet command
line options as well as by the "Verbose" setting in fink.conf. A
--quiet always takes precedence; otherwise the more verbose of the
fink.conf and cmdline values is used. The former documentation here
described the values as:
· 3 full
· 2 download and tarballs
· 1 download
· 0 none
binary_requested
my $boolean = $config->binary_requested();
Determine whether the binary distribution or compilation has been
requested. This is affected by the --use-binary-dist and
--compile-from-source command line options as well as by the
"UseBinaryDist" setting in fink.conf. A command-line flag takes
precedence over a fink.conf setting. Returns 1 for binary
distribution, 0 for compile-from-source.
build_as_user_group
my $result = Fink::Config::build_as_user_group;
Returns a ref to a hash with keys 'user', 'group', and 'user:group'
and values depending on whether the option build_as_nobody is set
or not. Also checks for the existence of the user and group
'fink-bld' if build_as_nobody is set. If either the user or the
group 'fink-bld' can't be found the method falls back to 'nobody'.
has_flag
my $bool = $config->has_flag($flag);
Check for the existence of a configuration flag.
set_flag
$config->set_flag($flag);
Set a configuration flag. Modified configuration can be saved with
save().
clear_flag
$config->clear_flag($flag);
Clear a configuration flag. Modified configuration can be saved
with save().
mixed_arch
my $not_mixed = $config->mixed_arch(%opts);
Make sure that the local architecture matches the one for which
fink is configured. If not a message can be printed on stderr, a
fatal error can be generated, and/or a boolean value can be
returned. The following %opts are known:
message (optional)
If a non-null string, a message including this string is
printed on stderr.
fatal (optional)
If true, we die. If not, we just return a boolean indicating if
there is a mismatch.
Exported Variables
These variables are exported on request. They are initialized by
creating a Fink::Config object.
$basepath
Path to the base of the Fink installation directory.
Typically /sw.
$buildpath
Directory where fink packages will be built.
Typically $basepath/src
$config
The last Fink::Config object created.
$distribution
Fink package distribution being used.
For example, 10.2.
$dbpath
Where fink stores it's database files.
$libpath
XXX Don't understand this one.
SEE ALSO
Fink::Base
Fink 0.36.3.1 2013-12-30 Fink::Config(3)