=head1 NAME
ALPM::DB - ALPM database class.
=head1 SYNOPSIS
... load ALPM
with
options first ...
my
$localdb
= ALPM->localdb;
my
$name
=
$localdb
->name;
my
$perl
=
$localdb
->find(
'perl'
);
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'
)->pkgs ) {
print
join
(
q{ }
,
$pkg
->attribs(
'name'
,
'version'
) ),
"\n"
;
}
my
@cache
=
$syncdb
->pkgs;
=head1 METHODS
=head2 name
Usage :
my
$name
=
$db
->name;
Returns : The name of the repository database.
Ex: core, extra, community, etc...
=head2 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.
Note : This only returns one of the URL's of the repository.
=head2 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.
=head2 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
=head2 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.
=head2 pkgs
Usage :
my
@pkgs
=
$db
->pkgs;
Params : None
Returns : An array of all packages in the DB.
=head2 groups
Usage :
my
@groups
=
$db
->groups;
Returns : An array of all groups in the DB.
=head1 add_url
Purpose : This adds a mirror
for
the repository.
Params : The URL
for
the root of the remote repository.
=head2 set_pkg_reason
Usage :
$db
->set_pkg_reason(
'perl'
,
'explicit'
);
Params : The
package
name and a new
package
reason.
Reason can be
'explicit'
,
'implicit'
, 0, or 1.
Purpose : Changes the reason
for
installing the
given
package
.
Comments : Probably best to
use
on
local
database ...
Returns : Nothing.
=head2 update
Usage :
$db
->update;
Params : If provided a parameter, the update is forced.
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.
=head1 SEE ALSO
L<ALPM>, L<ALPM::Package>, L<ALPM::Transaction>
=head1 AUTHOR
Justin Davis, C<< <juster at cpan dot org> >>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2011 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.