NAME
ALPM::Transaction - An object wrapper for transaction functions.
SYNOPSIS
my $t = ALPM->transaction( type => 'upgrade',
flags => qw/ nodeps force / );
$t->add( qw/ perl perl-alpm / );
$t->commit;
DESCRIPTION
The transaction object wraps all the alpm_trans_...
C functions. When the object goes out of scope and is automatically garbage collected, the transaction is released.
METHODS
add
Usage : $trans->add( 'perl', 'perl-alpm', 'etc' );
Purpose : Add package names to be affected by transaction.
Params : A list of package names to be added (or just one).
Comment : You cannot add packages to a prepared transaction.
Returns : 1
prepare
Usage : $trans->prepare;
Purpose : Prepares a transaction for committing.
Comment : commit() does this automatically if needed.
Returns : 1
commit
Usage : $trans->commit;
Purpose : Commits the transaction.
Returns : 1
RELEASING A TRANSACTION
You may have noticed there is no release method. A transaction is released as soon as it goes out of scope and is garbage collected. For example:
sub foo
{
my $t = ALPM->transaction( type => 'sync' );
... do stuffs ...
}
# here, $t is out of scope, garbage collected, and transaction is
# released
In this way, with good coding practices, you should not need to release a transaction because it will go out of scope. But in order to explicitly release a transaction, assign undef
to it. For example:
my $t = ALPM->transaction( type => 'sync' );
$t->add('perl');
$t->commit;
$t = undef;
# Transaction is released immediately
So be careful you don't keep extra copies of a transaction stored around or else it will not be released. If you need extra copies try using weaken
in Scalar::Util.
EVENT CALLBACKS
The ALPM::transaction()
method takes an optional event key/value pair. The event types and their different values are listed here because there are so many of them.
Events are passed to the callback as a hash reference. Every event type has a name
and a status
key. The name gives the type of event, and status gives a string representing the status. The different kinds of extra arguments depends on the type of event.
All events can have one of the two statuses, 'start' or 'done' unless noted.
- checkdeps
- fileconflicts
- resolvedeps
- integrity
- deltaintegrity
-
All the above events have no special keys.
- interconflicts
-
When status is 'done' there is a key named 'target' which is an ALPM::Package object.
- add
-
Both 'start' and 'done' events also have a key named 'package' which is an ALPM::Package object.
- remove
-
Both 'start' and 'done' events also have a key named 'package' which is an ALPM::Package object.
- upgrade
-
The 'start' event has a key named 'package'. The 'done' event has the keys 'new' and 'old'.
- deltapatches
-
The 'done' event also has keys 'pkgname', and 'patches'.
- deltapatch
-
There is also a fail event with 'status' set to 'failed', in which case there is an 'error' key with an error message as its value.
- scriptlet
-
This always has 'status' set to the empty string. There is also a 'text' key with the scriptlet text I imagine?
- printuri
-
This always has 'status' set to the empty string. There is also a 'name' key with the URI I guess?
SEE ALSO
AUTHOR
Justin Davis, <jrcd83 at gmail dot com>
COPYRIGHT AND LICENSE
Copyright (C) 2009 by Justin Davis
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.