ALPM
view release on metacpan or search on metacpan
lib/ALPM.pod view on Meta::CPAN
=head1 SYNOPSIS
## We can start by setting options all by ourselves.
use ALPM;
my $alpm = ALPM->new('/', '/var/lib/db'); # root and dbpath
$alpm->set_cachedirs('/var/cache/pacman/pkg');
$alpm->set_logfile('/var/log/pacman.log');
## Or use ALPM::Conf, a handy module for pacman.conf parsing.
use ALPM::Conf qw(/etc/pacman.conf);
## ALPM::Conf loads an object into "our" package variable.
our $alpm;
## Querying databases & packages
my $localdb = $alpm->localdb;
my $pkg = $localdb->find('perl') or die 'wtfbbq';
printf "%s %s %s %d\n", $pkg->name, $pkg->version,
$pkg->arch, $pkg->size;
my $extradb = $alpm->register('extra') or die $alpm->strerror;
$extradb->add_mirror('ftp://ftp.archlinux.org/extra/os/i686')
or die $alpm->strerror;
$extradb->update or die $alpm->strerror;
my @perlpkgs = $extradb->search('perl');
printf "%d perl packages found.\n", scalar @perlpkgs;
## libalpm's version comparison function. (a classy method)
my $cmp = ALPM->vercmp('0.01', '0.02');
if($cmp == -1){
print "less than\n";
}elsif($cmp == 0){
print "equal\n";
}elsif($cmp == 1){
print "greater than\n";
}
## $found is undef or the package object for findme.
my @syncdbs = $alpm->syncdbs;
my $found = $alpm->find_dbs_satisfier('findme', @syncdbs);
$found = $alpm->find_satisfier('findme', $extradb->pkgs);
## These are perl wrappers around localdb and syncdbs:
## Search all databases/repos (includes localdb).
printf "%10s: %s %s\n", $_->db->get_name, $_->name,
$_->version for $alpm->search('perl');
## Find a database by name of repository.
my $coredb = $alpm->db('core');
=head1 DESCRIPTION
Archlinux uses a package manager called pacman. Pacman internally
uses the alpm library for handling its database of packages. This
module creates a perlish object-oriented interface to the libalpm C library.
In the past this module implemented transactions as well, allowing you
to modify the system/database. This is no longer implemented because
I grew tired of rewriting this module every time the pacman API was
changed.
=head1 CLASS METHODS
=head2 new
$OBJ = ALPM->new($ROOTDIR, $DBDIR);
=over 4
=item C<$ROOTDIR>
The root directory for all deployed packages managed by libalpm.
=item C<$DBDIR>
The database directory where the local database and sync databases are kept.
=item C<$OBJ>
An ALPM object which is used for all other method calls. This is referenced in
the object method definitions below.
=back
=head2 version
$VERSTR = ALPM->version()
=over 4
=item C<$VERSION>
libalpm's internal version string, as returned by the I<alpm_version> C function.
=back
=head2 caps
@CAPS = ALPM->caps()
=over 4
=item C<@CAPS>
Corresponds to the I<alpm_capabilities> C function. A list of strings, describing
capabilities of libalpm. Any of the following capabilities may or may not be
present:
=over 4
=item nls
Foreign language support.
=item downloader
If libcurl is installed then a downloader is embedded.
=item signatures
( run in 2.408 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )