NAME
ALPM - Perl OO version of libalpm, Archlinux's packaging system
SYNOPSIS
use ALPM;
ALPM->set_options({ root => '/',
dbpath => '/var/lib/pacman/',
cachedirs => [ '/var/cache/pacman/pkg' ],
logfile => '/var/log/pacman.log',
xfercommand => '/usr/bin/wget --passive-ftp -c -O %o %u' });
# ...is the same as...
use ALPM ( root => '/',
dbpath => '/var/lib/pacman/',
cachedirs => [ '/var/cache/pacman/pkg' ],
logfile => '/var/log/pacman.log',
xfercommand => '/usr/bin/wget --passive-ftp -c -O %o %u' );
# Lots of different ways to get/set ALPM options...
my $root = ALPM->get_opt('root');
my ($cachedirs, $localdb) = ALPM->get_options( 'cachedirs', 'localdb' );
my $array_ref = ALPM->get_options_ref( 'cachedirs', 'localdb' );
my %allopts = ALPM->get_options;
my $allopts_ref = ALPM_>get_options_ref; #hashref
my $localdb = ALPM->register_db;
my $pkg = $localdb->get_pkg('perl');
# Lots of different ways to get package attributes...
my $attribs_ref = $pkg->get_attribs_ref;
my $name = $pkg->get_name;
my ($size, $isize) = $pkg->get_attribs('size', 'isize');
print "$name $attribs_ref->{version} $attribs_ref->{arch} $size/$isize";
my $syncdb = ALPM->register_db( 'extra',
'ftp://ftp.archlinux.org/$repo/os/i686' );
my $perlpkgs = $syncdb->search(['perl']);
printf "%d perl packages found.\n", scalar @{$perlpkgs};
DESCRIPTION
Archlinux uses a package manager called pacman. Pacman internally uses the alpm library for handling its database of packages. This module is an attempt at creating a perlish object-oriented interface to the libalpm C library.
EXPORT
None.
Because all alpm functions have been converted to class methods, classes, and object methods, nothing is exported.
IMPORT OPTIONS
There are a few different options you can specify after c<use ALPM>. These help to set configuration options for ALPM. These options are global for everyone who is using the module. You can specify either:
- 1. The path to a pacman.conf configuration file
- 2. A hashref of options to use for ALPM
- 3. A hash of options to use for ALPM
OPTIONS
ALPM has a number of options corresponding to the alpm_option_get_...
and alpm_option_set...
C functions in the library. Options which take multiple values (hint: they have a plural name) expect an array reference as an argument. Similarly the same options return multiple values as an array reference.
TODO
CLASS METHODS
ALPM has all its package specific and database specific functions inside the package and database classes as methods. Everything else is accessed through class methods to ALPM.
As far as I can tell you cannot run multiple instances of libalpm. Class methods help remind you of this. The class method notation also helps to differentiate between globally affecting ALPM functions and package or database-specific functions.
set_options
set_opt
get_options
get_opt
register_db
Usage : my $localdb = ALPM->register_db;
my $syncdb = ALPM->register_db( 'core',
'ftp://ftp.archlinux.org/$repo/os/i686' );
Params : No parameters will return the local database.
Two parameters will register a sync database:
1) The name of the repository to connect to.
2) The URL to the repository's online files.
Like with pacman's mirrorlist config file, $repo will be replaced
with the repository name (argument 1) ... use single quotes!
Precond : You must set options before using register_db.
Throws : An 'ALPM DB Error: ...' message is croaked on errors.
Returns : An ALPM::DB object.
load_pkgfile
Params : The path to a package tarball.
Returns : An ALPM::Package object.
load_config
Params : The path to a pacman.conf configuration file.
Returns : Nothing.
SEE ALSO
http://code.toofishes.net/cgit/ - GIT repository for pacman/libalpm
http://code.toofishes.net/pacman/doc/ - libalpm doxygen docs
libalpm(8) (pretty sparse)
pacman(8)
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.