NAME
ALPM::DB - ALPM database class.
SYNOPSIS
... load ALPM with options first ...
my $localdb = ALPM->localdb;
my $name = $localdb->name;
my $perl = $localdb->find('perl');
my $url = 'ftp://ftp.archlinux.org/community/os/i686';
my $syncdb = ALPM->register_db( 'community' => $url );
for my $pkg ( $syncdb->search( 'perl' ) ) {
printf "%s %s\n", $pkg->name, $pkg->version;
}
for my $pkg ( $syncdb->find_group('xfce4')->packages ) {
print join( q{ }, $pkg->attribs('name', 'version') ), "\n";
}
my @cache = $syncdb->pkgs;
METHODS
name
Usage : my $name = $db->name;
Returns : The name of the repository database.
Ex: core, extra, community, etc...
url
Usage : my $url = $db->url;
Returns : The url of the repository, the same one the DB
was initialized with or the empty string if this
is a 'local' database.
find
Usage : my $package = $db->find( $package_name )
Params : $package_name - Exact name of the package to retrieve.
Returns : An ALPM::Package object if the package is found.
undef if the package with that name is not found.
find_group
Usage : my $group = $db->find_group( $group_name );
Returns : An ALPM::Group object if it is found or undef.
ALPM::Group objects have two accessors:
$group->name - the name of the group
$group->pkgs - A list of package objects in the group
search
Usage : my @results = $db->search( 'foo', 'bar', 'baz' );
Params : A list of strings to search for.
Returns : An array of package objects whose name matched the search.
packages
Usage : my @pkgs = $db->packages;
Params : None
Returns : An array of all packages in the DB.
Notes : This is a wrapper for the C<get_pkg_cache> method.
It is easier if you want a list.
groups
Usage : my @groups = $db->groups;
Returns : An array of all groups in the DB.
pkgs
This is an alias for the packages
method.
Usage : my @pkgs = $db->pkgs;
get_pkg_cache
Usage : my $cache_ref = $db->get_pkg_cache;
Comments : Resembles the alpm_db_get_pkgcache function.
Returns : An arrayref of package objects in the DB cache.
pkgs_ref
This is an alias for the get_pkg_cache
method.
Usage : my $pkgs_ref = $db->pkgs_ref;
update
Usage : $db->update;
Purpose : Updates the local copy of the database's package list.
Comment : This needs to create a transaction to work, so make sure
you don't have any active transactions.
Things may work incorrectly if the database is not updated.
If there is no local db copy, the package cache will be empty.
Returns : 1
TODO : Provide different return values like alpm does.
SEE ALSO
ALPM, ALPM::Package, ALPM::Transaction
AUTHOR
Justin Davis, <juster at cpan dot org>
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.