NAME

WWW::AUR::Package - Query, download, and build AUR packages.

SYNOPSIS

use WWW::AUR;
my $aurobj = WWW::AUR->new();
my $pkg = $aurobj->find( 'perl-www-aur' );

# or using WWW::AUR::Package directly ...
use WWW::AUR::Package;
my $pkg = WWW::AUR::Package->new( 'perl-www-aur' );

#----------------------------------------------------------------------

# Accessors exist for package info fields...
printf "ID: %d -- Name: %s -- Version: %s\n",
    $pkg->id, $pkg->name, $pkg->version;

# Or retrieve the info as a hash, easier for printing...
my %info = $pkg->info;
print "ID: $info{id} -- Name: $info{name} -- Version: $info{version}"

# Before extracting, pkgbuild() gets the PKGBUILD from the webpage...
my %pkgbuild = $pkg->pkgbuild;
print "pkgname: $pkgbuild{pkgname}\npkgver: $pkgbuild{pkgver}\n";

#----------------------------------------------------------------------

# Check the source package file size before downloading...
my $dlsize = $pkg->download_size;
print "Source package size is $dlsize bytes.\n";

# PKGBUILD arrays are turned into array refs...
printf "depends: %s\n", join q{ }, @{ $pkgbuild{depends} };

# download() method sets the src_pkg_path() accessor...
$pkg->download;
print "Downloaded %s to %s.\n", $pkg->name, $pkg->src_pkg_path;

# extract() method sets the src_dir_path() accessor...
$pkg->extract;
print "Extracted source package to %s.\n", $pkg->src_dir_path;

# build() method sets the bin_pkg_path() accessor...
$pkg->build;
print "Build binary package and saved to %s.\n", $pkg->bin_pkg_path();

# After extracting, pkgbuild() is read from the file on disk...
%pkgbuild = $pkg->pkgbuild;

# Get the package owner maintainer object...
my $maint_obj = $pkg->maintainer();

DESCRIPTION

The package class is the most important class for the WWW::AUR package. Using a package object, you can lookup any information you need for the package as well as download, extract, and build the package with the makepkg command.

CONSTRUCTOR

$OBJ = WWW::AUR::Package->new( $NAME, %PATH_PARAMS );

The constructor takes the package name as its argument. An error will be croaked with Carp if the package could not be found on the AUR. Path parameters are optional, see "PATH PARAMETERS" in WWW::AUR for more information.

$NAME

The name of the AUR package.

%PATH_PARAMS

Optional path parameters. See "PATH PARAMETERS" in WWW::AUR.

Errors
Failed to find package: $NAME

This error is croaked if the package with the given $NAME could not be found.

METHODS

PACKAGE INFO ACCESSORS

$IDNUM    = $OBJ->id;         (RPC Field Names)
$NAME     = $OBJ->name;
$VERSION  = $OBJ->version;
$DESC     = $OBJ->desc;       ("Description")
$CATEGORY = $OBJ->category;
$LOCID    = $OBJ->locationid;
$URL      = $OBJ->url;
$URLPATH  = $OBJ->urlpath;
$LICENSE  = $OBJ->license;
$VOTES    = $OBJ->votes;      ("NumVotes")
$OUTDATED = $OBJ->outdated;   ("OutOfDate")

These accessors correlate exactly to the keys returned to by the AUR's rpc.php output given. Most of the fields are self explanatory.

$CATEGORY

Instead of using an id number for categories, they are mapped to the name of the category. The following names are used for each corresponding category ID:

1. daemons
2. devel
3. editors
4. emulators
5. games
6. gnome
7. i18n
8. kde
9. kernels
10. lib
11. modules
12. multimedia
13. network
14. office
15. science
16. system
17. x11
18. xfce
$VOTES

The NumVotes RPC field was renamed to, simply, votes.

$OUTDATED

The OutOfDate RPC field was renamed to outdated.

pkgbuild

%PKGBUILD = $OBJ->pkgbuild;

Parses the PKGBUILD file and returns it as a hash, converting all bash arrays to array references. The hash key names are identical to the PKGBUILD variable names. See PKGBUILD(5).

If the package has already been extracted (see "extract") then the PKGBUILD is read from the PKGBUILD file extracted to disk. Otherwise, the PKGBUILD is read direct from the AUR webpage without downloading a source package file.

download

$SRCPKGPATH = $OBJ->download( $CALLBACK? )
$CALLBACK (Optional)

A code reference that will be called everytime a "chunk" of data is downloaded. Two parameters are passed to the supplied code reference:

1. The number of bytes downloaded so far.
2. The total size of the package, in bytes.
$SRCPKGPATH

The absolute path to the source package file that was downloaded.

extract

$SRCPKGDIR = $OBJ->extract;
$SRCPKGDIR

The absolute path to the directory where the source package was extracted. (This is the directory that is contained in the source package file, extracted)

build

$BINPKGDIR = $OBJ->build( %BUILD_PARAMS? );

Builds the AUR package, using the makepkg utility.

%BUILD_PARMAS (Optional)

Path parameters can be mixed with build parameters. Several build parameters can be used to provide arguments to makepkg.

Build parameter keys:

pkgdest

Overrides where to store the built binary package file.

quiet

If set to a true value the makepkg output is redirected to /dev/null.

prefix

A string to prefix before the makepkg command.

args

A string to append to the makepkg command as arguments.

$BINPKGDIR

The absolute path to the binary package that was created by running makepkg.

src_pkg_path

undef | $PATH = $OBJ->src_pkg_path;

If download has been called, then the path of the downloaded source package file is returned. Otherwise undef is returned.

src_pkg_dir

undef | $PATH = $OBJ->src_pkg_dir;

If extract has been called, then the path of the extract source package dir is returned. Otherwise undef is returned.

bin_pkg_path

undef | $PATH = $OBJ->bin_pkg_path;

If build has been called, then the path of the built binary package is returned. Otherwise undef is returned.

SEE ALSO

AUTHOR

Justin Davis, <juster at cpan dot org>

BUGS

Please report any bugs or feature requests to bug-www-aur at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-AUR. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Send me an email at the above address if you have any questions or need help.

LICENSE AND COPYRIGHT

Copyright 2010 Justin Davis.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.