Fink::SysState(3) Fink documentation Fink::SysState(3)NAMEFink::SysState - Analyze the state of packages on the system
DESCRIPTIONFink::SysState allows checking the consistency of a set of packages and
their dependencies.
Changes can be made to the current state, and then checked for
problems.
NOTE: The states considered by this package are hypothetical states. No
packages are really added or removed by this package.
SYNOPSIS
use Fink::SysState;
# Get the current state
my $state = Fink::SysState->new();
# Examine the state
my $version = $state->installed($pkgname);
my @providers = $state->providers($pkgname);
my @pkgnames = $state->list_packages();
my @pkgnames = $state->provided();
# Look for dependency problems
my @problems = $state->check();
# Add and remove items.
my $new_item = {
package => foo,
version => 1.0-1,
depends => 'bar, baz (>= 4.0-1)',
};
$state->add($new_item, $new_item2);
$state->add_pkgversion($pv, $pv2, $pv3);
$state->remove($pkgname, $pkgname2);
# Make several changes at once
my $changes = {
add => [ @hashes ],
add_pkversion => [ @pvs ],
remove => [ @pkgnames ],
};
$state->change($changes, $changes2, ...);
# Try out changed states
$state->add(...); # Or remove, add_pkgversions, change
...
$state->undo();
$state->checkpoint($checkpoint_name);
...
$state->undo($checkpoint_name);
# Resolve inconsistent states
my @extra_pvs = $state->resolve_install(@install_pvs);
METHODS
Constructing new objects
new
my $state = Fink::SysState->new();
Make a new state object, reflecting the current state of the
system.
Examining the state
installed
my $version = $state->installed($pkgname);
Determines whether a package is installed, and if so what version.
If a package is not installed, returns undef.
providers
my @provider_pkgnames = $state->providers($pkgname);
Gets the names of the packages that provide the named package.
list_packages
my @pkgnames = $state->list_packages();
Get a list of the names of every package installed.
provided
my @pkgnames = $state->provided();
Get a list of every package that has been explicitly provided by
another package. Each such package may or may not be itself
installed.
Changing the system state
add
my $new_item = {
package => foo,
version => 1.0-1,
depends => 'bar, baz (>= 4.0-1)',
};
$state->add($new_item, $new_item2, ...);
Adds one or more packages to this system state, getting the
information about them from hash-refs.
Each package must be specified by a hash, containing at minimum the
fields 'package' and 'version'. The fields 'depends', 'provides'
and 'conflicts' are also considered meaningful; other fields will
be silently deleted.
If a package with the same name as one of those added already
exists in the state, it will be removed and replaced. An exception
will be thrown on other errors.
add_pkgversion
$state->add_pkgversion(@pvs);
Adds one or more packages to this system state, getting the
information about them from Fink::PkgVersion objects.
If a package with the same name as one of those added already
exists in the state, it will be removed and replaced. An exception
will be thrown on other errors.
remove
$state->remove(@pkgnames);
Removes one or more packages from this system state.
If one of the package names requested does not exist in the state,
a warning will be emitted. An exception will be thrown on other
errors.
change
my $changes = {
add => [ @hashes ],
add_pkversion => [ @pvs ],
remove => [ @pkgnames ],
};
$state->change($changes, $changes2, ...);
Make different changes to the system state all at once.
The keys in the changes hash should be: 'add' for package-item
hashes to add, 'add_pkgversion' for Fink::PkgVersion objects to
add, and 'remove' for names of packages to remove.
checkpoint
$state->checkpoint($checkpoint_name);
Set a checkpoint, which can be reverted to later.
undo
$state->undo();
$state->undo($checkpoint_name);
Revert the last change made, or move to a checkpoint. Returns an
array-ref which can be passed to the &change method to revert the
reversion.
WARNING: Once you undo, you can't redo except by using the return
value. All checkpoints that are reverted past are lost.
Dealing with dependency problems
check
my @problems = $state->check();
@problems = $state->check($options);
@problems = $state->check($options, @pkgnames);
Check for unsatisfied dependencies or conflicts. If passed package
names, only checks those packages, otherwise checks all packages.
A list of dependency problems encountered is returned. If the list
is empty, no problems were found. Each item in the list returned is
a hash-ref, containing the following keys:
package
The package with the unsatisfied dependency or conflict.
field
The field which is unsatisfied, either 'depends' or
'conflicts'.
spec
The package specification which is unsatisfied. For a 'depends'
field, this is an array-ref of alternative specifications. For
a 'conflicts' field, this is a single specification. See
spec2struct for the format of specification structures.
desc
A textual description that can be shown to a user to describe
the failed dependency.
conflictor
If the field is conflicts, then this is the name of the package
causing the conflict.
The $options hash-ref can contain the following keys:
verbose
If true, print detailed messages to stderr when a dependency
problem is found. Defaults to false.
detail
The level of detail desired, one of $DETAIL_FIRST,
$DETAIL_PACKAGE or $DETAIL_ALL. With $DETAIL_ALL, every problem
will be returned. To speed up the check, use $DETAIL_PACKAGE to
find just one problem per package with unsatisfied dependencies
or conflicts. For the fastest check, use $DETAIL_FIRST to
return only the first problem found.
In array context $DETAIL_ALL is the default, in scalar context
$DETAIL_FIRST is the default.
resolve_install
my @extra_pvs = $state->resolve_install(@install_pvs);
Dpkg has a known bug, which can lead to an inconsistent system
state when installing packages which no longer satisfy another
package's versioned dependency.
This method attempts to resolve this situation. Pass in a list of
PkgVersion objects which should be installed to the given state,
and the return value will be a list of additional PkgVersion
objects which must be installed at the same time to preserve
consistency.
On return, the state object will reflect the installation of all
the necessary packages.
If no acceptable resolution can be found, an exception will be
thrown.
Fink 0.36.3.1 2013-12-30 Fink::SysState(3)