Justin Davis > WWW-AUR > WWW::AUR::Package



Annotate this POD


New  1
Open  0
View/Report Bugs


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


  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...
  printf "Downloaded %s to %s.\n", $pkg->name, $pkg->src_pkg_path;
  # extract() method sets the src_dir_path() accessor...
  printf "Extracted source package to %s.\n", $pkg->src_dir_path;
  # build() method sets the bin_pkg_path() accessor...
  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();


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.


  $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.

The name of the AUR package.

%PATH_PARAMS (Optional)

Path parameters. See "PATH PARAMETERS" in WWW::AUR.

Failed to find package: $NAME

This error is croak-ed if the package with the given $NAME could not be found.


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.


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

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


The OutOfDate RPC field was renamed to outdated.


The FirstSubmitted RPC field was renamed to ctime.


The LastModified RPC field was renamed to mtime.


  %INFO = $OBJ->info;

Returns all data from the info accessors as one hash. Keys are the same as the accessor names.


  $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.


  $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.

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


  $MAINTAINER_OBJ = $OBJ->maintainer( %PATH_PARAMS? )

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 = $OBJ->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;
  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.



Justin Davis, <juster at cpan dot org>


Please email me any bugs you find. I will try to fix them as quick as I can.


Send me an email if you have any questions or need help.


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.

syntax highlighting: