Manpages - WWW_AUR_Package.3pm
Table of Contents
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 ); #-----------------------------------------------------------------–—
– 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“; #-----------------------------------------------------------------–—
$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; printf “Downloaded %s to %s.\n”, $pkg->name, $pkg->src_pkg_path; # extract() method sets the src_dir_path() accessor… $pkg->extract; printf “Extracted source package to %s.\n”, $pkg->src_dir_path; # build() method sets the bin_pkg_path() accessor… $pkg->build; printf “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(); # Or maybe you only want their name… (this is faster) my $maint_name = $pkg->maintainer_name();
DESCRIPTION
The package class is the most important class for the WWW-AUR distribution. 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.
NOTE: In order to look up a package by name, this module must query the AUR RPC first. Just keep in mind every WWW::AUR::Package object you creates requires an HTTP request.
- $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 croak-ed 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; $URL = $OBJ->url; $URLPATH = $OBJ->urlpath; $LICENSE = $OBJ->license; $VOTES = $OBJ->votes; (“NumVotes”) $OUTDATED = $OBJ->outdated; (“OutOfDate”) $CTIME = $OBJ->ctime; (“FirstSubmitted”) $MTIME = $OBJ->mtime; (“LastModified”)
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:
- $VOTES
The NumVotes RPC field was renamed to, simply, votes.
- $OUTDATED
- The OutOfDate RPC field was renamed to outdated.
- $CTIME
- The FirstSubmitted RPC field was renamed to ctime.
- $MTIME
- The LastModified RPC field was renamed to mtime.
info
%INFO = $OBJ->info;
Returns all data from the info accessors as one hash. Keys are the same as the accessor names.
pkgbuild
$PKGBUILD_OBJ = $OBJ->pkgbuild;
Parses the PKGBUILD file and returns it as a WWW::AUR::PKGBUILD object.
If the package has already been extracted 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:
- $SRCPKGPATH
The absolute path to the source package file that was downloaded.
maintainer
$MAINTAINER_OBJ = $OBJ->maintainer( %PATH_PARAMS? )
- $MAINTAINER_OBJ
- The WWW::AUR::Maintainer object representing the maintainer of this package.
- %PATH_PARAMS (Optional)
- Optional path parameters to store in the new maintainer object. These will get passed to any package object that are initialized by it.
maintainer_name
$MAINTAINER_NAME = $OBJ->maintainer_name()
- $MAINTAINER_NAME
- The name of the maintainer of this package. This
method is alot faster than
maintainer()
because it does not verify anything. This just scrapes the package’s webpage for the maintainer name.
Package File Methods
$SRCPKGDIR = $OBJ->extract; $BINPKGDIR = $OBJ->build( %BUILD_PARAMS? ); undef | $PATH = $OBJ->src_pkg_path; undef | $PATH = $OBJ->src_pkg_dir; undef | $PATH = $OBJ->bin_pkg_path;
After calling download a WWW::AUR::Package::File object is stored inside the WWW::AUR::Package object. All of the WWW::AUR::Package::File methods are wrapped by the Package object.
The extract and build methods call download first if it has not already been called. build calls the build method in the WWW::AUR::Package::File object, which will call the corresponding extract method if it has not already been called.
SEE ALSO
- WWW::AUR
- WWW::AUR::Package::File
- WWW::AUR::PKGBUILD
AUTHOR
Justin Davis, <juster at cpan dot org>
BUGS
Please email me any bugs you find. I will try to fix them as quick as I can.
SUPPORT
Send me an email if you have any questions or need help.
LICENSE AND COPYRIGHT
Copyright 2014 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.