ALPM

 view release on metacpan or  search on metacpan

lib/ALPM.pod  view on Meta::CPAN

=head1 NAME

ALPM - readonly access to pacman's libalpm.

=head1 VERSION

3.06

This version of ALPM is compatible with pacman 4.

=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);

lib/ALPM.pod  view on Meta::CPAN

Registers a remote synchronizable database.

=over 4

=item C<$NAME>

The name to use for the database (e.g. core, extra, community.)

=item C<$SIGLEVEL> I<(Optional>)

The signature level to use for the database, including the database file and each
package file downloaded from the database mirror. If none is specified, then the
signature level is set to C<'default'> which is equivalent to the signature level set with
the I<set_defsiglvl> method.

=item C<$DB>

On success, an L<ALPM::DB::Sync> object.

=item C<undef>

On failure. Check L</strerror>.

=back

=head2 syncdbs

  @DBS = $OBJ->syncdbs()

Retrieve a list of sync databases that have previously been registered.

=over 4

=item C<@DBS>

A list of L<ALPM::DB::Sync> objects.

=back

=head2 unregister_all

  1 | undef = $OBJ->unregister_all()

Unregisters all sync databases. If you try to use previously registered
L<ALPM::DB::Sync> objects, they will probable cause a segfault...

Returns 1 on success or undef on error. Check L</strerror> on error.

=head1 ALPM OPTIONS

ALPM has a number of options corresponding to the
C<alpm_option_get_...> and C<alpm_option_set...> C functions in the
library.  Options which take multiple values (hint: they have a plural
name) accept multiple arguments in the corresponding methods.
Similarly the same options return a list.

=head2 Read-write options

=over

=item B<logfile> - path to the pacman logfile

=item B<arch> - the machine architecture to use

=item B<gpgdir> - path to gpg stuff

=item B<cachedirs>* - paths containing package caches

=item B<noupgrades>* - a list of package names to not upgrade

=item B<noextracts>* - a list of package names to not extract

=item B<assumeinstalled>* - a list of dependencies to assume are satisfied.
The setter methods take either a dependency hash or a string representing
a dependency.  The accessor returns a list of dependency hash references.

=item B<ignorepkgs>* - a list of package names to ignore for upgrade

=item B<ignoregroups>* - a list of groups to ignore for upgrade

=item B<usesyslog> - if true, log to the system log as well

=item B<deltaratio> - accepts a decimal from 0 to 1

=item B<checkspace> - check for available diskspace

=item B<defsiglvl> - the default signature level. See L</Signature Level>.
This name was shortened from I<alpm_option_set_default_signature_level>.
You're welcome.

=back

=head2 Read-only options

=over

=item B<root> - path to the installation root

=item B<dbpath> - path to the database

=item B<lockfile> - path to the lockfile

=back

  * = the option is set with (and gets you) a list

=head2 Callback options

Callbacks can only be set to code references.

=head3 logcb - Generic logging

The log level and message are passed to the provided code ref as
arguments.

=over 4

=item 1. level

This is one of the following strings: error, warning, debug, function, or unknown.

=item 2. message

This is the message itself.

=back

=head1 DATA TYPES

Several libalpm data types have been converted into hash references. The
alternative is to turn them into full-blown objects, which seems pointless
considering the only methods are data accessors.

=head2 Dependency

Dependencies specify constraints on a set of packages. Only certain packages
satisfy a dependency. These can be used in places other than dependencies,
such as conflicts. Dependencies have the following keys:

=over 4

=item name

The name of a package.

=item version

A version string, which can be empty.

=item mod

A boolean operator used to compare package versions to our dependency
version, must be either an empty string (which allows any version), =, >=,
<=, >, <, or ? if an internal error occurred.

=item desc

If the dependency is optional this key gives a description of the dependency. This key does not exist on a regular dependency.

=back

=head2 Conflict

Conflicts have the following keys:

=over 4

=item package1

An L<ALPM::Package> object.

=item package2



( run in 0.559 second using v1.01-cache-2.11-cpan-5837b0d9d2c )