NAME
ALPM::Package - Class representing an alpm package
SYNOPSIS
use ALPM qw( /etc/pacman.conf );
my $perlpkg = ALPM->local_db->get_pkg('perl');
# TMTOWTDI!
my $name = $perlpkg->get_name();
print "$name rocks!\n";
print $perlpkg->get_attr('name'), " rocks!\n";
my %attrs = $perlpkg->get_attribs();
print "$attrs{name} rocks!\n";
my $attrs_ref = $perlpkg->get_attribs_ref();
print "attrs_ref->{name} rocks!\n";
# Dependencies are given as array of hashrefs:
print "$name depends on:\n";
for my $dep ( @{ $perlpkg->get_depends() } ) {
print "\t$dep->{name} $dep->{mod} $dep->{ver}\n";
}
# Others lists are arrayrefs of scalars:
print "$name owns files:\n";
for my $file ( @{ $perlpkg->get_files() } ) {
print "\t$file\n";
}
DESCRIPTION
This class is a wrapper for all of the alpm_pkg_...
C library functions of libalpm. You retrieve the package from the database and you can then access its attributes. Attributes are like ALPM's options. There are many different ways to access them. Yet you cannot modify a package using its methods.
ATTRIBUTES
There are three basic ways to access an attribute. You can use the accessor method that is specific to an attribute, you can use the get_attr
method, or you can use the get_attribs
method.
ATTRIBUTE ACCESSORS
The accessors are named exactly the same as the alpm_pkg_get...
functions. They are easy to use if you only want a few attributes.
get_filename
get_name
get_version
get_desc
get_url
get_builddate
get_installdate
get_packager
get_md5sum
get_arch
get_size
get_isize
get_reason
get_licenses
get_groups
get_depends
get_optdepends
get_conflicts
get_provides
get_deltas
get_replaces
get_files
get_backup
has_scriptlet
has_force
download_size
Attributes with plural names return an arrayref of strings.
get_depends is different because it returns an arrayref of hashrefs (an AoH). The hash has the following key-value pairs:
|------+----------------------------------------|
| Key | Value |
|------+----------------------------------------|
| name | Package name of the dependency |
| ver | The version to compare the real one to |
| mod | The modifier of the dependency |
| | ('==', '>=', '<=', '<', or '>') |
|------+----------------------------------------|
PERLISH METHODS
There are also more perlish ways to get attributes. get_attr
is useful if you have the name of the attribute in a scalar. get_attribs
is useful if you want to get all attributes at once in a hash, or many attributes at once into a list or variables.
get_attr
Usage : my $name = $pkg->get_attr('name');
Params : The name of the attribute.
(use 'name' to call get_name, etc.
use 'scriplet' to call has_scriptlet, etc.
'download_size' is unchanged)
Returns : The attribute value.
get_attribs
Usage : my %attribs = $pkg->get_attribs();
my ($name, $desc) = $pkg->get_attribs('name', 'desc');
Params : If you specify attribute names, their values are returned as
a list. Otherwise, returns a hash of all attributes.
Returns : Either a hash or a list.
get_attribs_ref
This is the same as get_attribs, but it returns a hashref or
arrayref instead.
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.