Justin Davis > CPANPLUS-Dist-Arch > CPANPLUS::Dist::Arch

Download:
CPANPLUS-Dist-Arch-1.29.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 1.29   Source  

NAME ^

CPANPLUS::Dist::Arch - CPANPLUS backend for building Archlinux pacman packages

SYNOPSIS ^

  (First, setup cpan to use us automatically)
  $ setupdistarch

  (Install the module as a pacman package)
  $ cpanp -i Perl::Module::Here

  (Use cpan2dist to make a package, but don't install it)
  $ cpan2dist Acme::Bleach

  (Use our included cpan2aur to make a source package in current dir)
  $ cpan2aur CPANPLUS::Dist::Arch

  (In case we need to customize our package build, create a directory
   with a template we can use for future versions.)
  $ cpan2aur -d CPANPLUS::Dist::Arch
  ==> Creating new directory for CPANPLUS::Dist::Arch...
    -> Looking up module for CPANPLUS::Dist::Arch on CPAN...
  Running [/usr/bin/perl /usr/bin/perlbin/core/cpanp-run-perl /home/juster/.cpanplus/5.10.1/build/CPANPLUS-Dist-Arch-0.16/Makefile.PL INSTALLDIRS=site]...
  Writing Makefile for CPANPLUS::Dist::Arch
    -> Creating new PKGBUILD.tt template file...
  ==> Created perl-cpanplus-dist-arch source package directory.

  (Customize the template... add a optdepends, library depends, etc.
   Just leave the rest of it alone.)
  $ cd perl-cpanplus-dist-arch
  $ ed PKGBUILD.tt

  (Submit it to AUR!  Will ask for a login username/password or remember
   the last one used)
  $ cpan2aur -u

DESCRIPTION ^

This module is used as a plugin of CPANPLUS to transparently package CPAN distribution files into pacman packages as they are installed. This module can also be used by programmers to build packages in more complex ways. For example, it can create source packages for the AUR by using the included cpan2aur program.

REQUIREMENTS ^

You will need to have pacman installed, of course, to create package and to install these new packages. Pacman is included with Archlinux but can even be used on other Linux distributions. (see http://wiki.archlinux.org/index.php/Pacman)

SETUP ^

Type setupdistarch at the command line to install CPAN modules as packages by default.

WHERE IS THE PACKAGE ^

By default, packages are stored under the user's home directory in the .cpanplus directory. Two seperate directories are created for building packages and for storing the resulting package file.

5.10.1 represents the version of perl you used to build the package and ~/.cpanplus represents the base directory chosen in your CPANPLUS config.

CUSTOMIZATION ^

You can change defaults settings machine-wide (for every user) or for one user or package. The machine-wide settings are set in the /etc/makepkg.conf file. The user/package customizations are set using environment variables.

PKGDEST

Override where the package files end up.

PACKAGER

Override the Contributor comment line at the top of the PKGBUILD.

EXAMPLE

Here is how you can use environment variables to put the package files in our ~/pkgs directory for the ALPM module. (along with any modules we have to build and install to create it)

  PACKAGER='Juster <juster at cpan dot org>' PKGDEST=~/pkgs cpanp -i ALPM

COMMAND LINE OPTIONS ^

There are many command line options to cpan2dist and cpanp. A small number of these options are recognized by CPANPLUS::Dist::Arch.

--verbose (DISABLED)

We are now verbose by default! Hope this is okay.

--skiptest

This will pass the --nocheck option to makepkg. Automated tests that the module author has written for your benefit will be avoided when building a package for the module.

  WARNING: This affects all pre-requisite module/packages that are
           built and installed; not just the module you specify.

DIST OPTIONS ^

cpan2dist allows you specify CPANPLUS::Dist::Arch specific options on the command line using the --dist-opts switch. You can also pass these arguments when using CPANPLUS::Module methods like dist().

pkgtype

This specifies whether to make a source package or a binary package. The default is to make a binary package.

destdir

This overrides every other package destination specified. Whether from the makepkg.conf file, environment variable, or default.

quiet

If set to a true value, pipe makepkg output to /dev/null.

nocolor

If set to a true value, disable colorized output from makepkg. Use monochrome output only.

PROGRAMMERS API ^

The rest of the document describes how a programmer can use the module. You can use this module with the CPANPLUS module in order to install distributions/packages in more complex ways.

Here is a quick example of how you use C::D::A with CPANPLUS::Backend.

EXAMPLE

  use CPANPLUS::Backend;
  use warnings;
  use strict;

  # Create a source package in our current directory, no verbosity.
  my $cb  = CPANPLUS::Backend->new();
  my $mod = $cb->module_tree( 'ALPM' );
  $mod->install( target  => 'create',
                 format  => 'CPANPLUS::Dist::Arch',
                 pkg     => 'src',
                 destdir => '.',
                 verbose => 0
               );

See also CPANPLUS::Module. The create_dist_arch sub in the cpan2aur script shows how to use CPANPLUS::Module's dist() method, which is a little funky. (I want to submit a patch to it when I get the chance)

EXPORT TAGS

:all

This will import the functions dist_pkgname and dist_pkgver into your package. These functions are not imported by default.

EXPORTED FUNCTIONS

dist_pkgname

  Usage   : my $pkgname = dist_pkgname( 'Acme-Drunk' );
  Purpose : Converts a module's distribution name to an
            Archlinux style perl package name.
  Params  : $dist_name - The name of the distribution (ex: Acme-Drunk)
  Returns : The Archlinux perl package name (ex: perl-acme-drunk).
            following the Archlinux packaging standards.

dist_pkgver

  Usage   : my $pkgver = dist_pkgver( '1.20.1_2A' );
  Purpose : Convert a module's CPAN distribution version into our more
            restrictive pacman package version number.
  Params  : The version of the CPAN distribution file.
  Returns : The Archlinux package version following the Archlinux
            packaging standards.

PUBLIC METHODS

When using the CPANPLUS module in a perl script to create packages, these public methods are available. See the cpanpkgbuild.pl script included in the examples directory for an example.

get_pkgname

  Usage   : say $dist->get_pkgname;
  Returns : The name of the package.

get_pkgver

  Usage   : say $dist->get_pkgver;
  Returns : The version of the package.

get_pkgrel

  Usage   : say "Release: ", $dist->get_pkgrel;
  Notes   : Default is 1, unless set_pkgrel is used.
  Returns : The package release number.

set_pkgrel

  Usage   : $newrel = $dist->set_pkgrel( 2 );
  Params  : $new_relnum - Croaks if this is not a number.
  Returns : The new release number.

set_destdir

  Usage   : $dist->set_destdir('~/pkg/perl');
  Purpose : Overrides the directory to store the built package
            for this particular object.
  Returns : The directory that was set.

get_destdir

  Usage   : my $dest = $dist->get_destdir;
  Returns : The directory previously specified by set_destdir.

get_pkgpath

  Usage   : my $fqp = $dist->get_pkgpath;
  Returns : The fully qualified path of the built package
            or undef if no package was built yet.

get_cpandistdir

  Usage   : my $distdir = $dist->get_cpandistdir;
  Returns : The main directory name that will be inside the distribution
            tarball.  This directory contains the entire distribution.
  Example : If the distribution file of Acme-Bleach is in the tarball
            Acme-Bleach-1.12.tar.gz or Acme-Bleach-1.12.tar.bz2
            then $dist->get_cpandistdir will return 'Acme-Bleach-1.12'.
  Notes   : Does not actually check if the directory exists in the tarball.
            So far it always has...

get_pkgvars

  Usage   : my %pkgvars = $dist->get_pkgvars;
  Returns : A hash containing all the PKGBUILD variables.
            Keys are the bash variable names in the PKGBUILD.
            Dependencies are converted to their pacman names.
  Notes   : The keys are: pkgname, pkgver, pkgdesc, depends, url, source
            md5sums, arch, pkglinks, and sha512sums (if Digest::SHA is
            installed).
 
            One key not named after a PKGBUILD field is 'pkglinks' whose
            value is a hashref. Inside this hashref, the keys 'depends'
            and 'makedepends' are always present, even if they are an
            empty arrayref. The keys 'checkdepends' and 'conflicts' are
            only present if they contain a non-empty arrayref.
            
            These values are package specifications. Each specification
            is an arrayref of package name, a comparison operator,
            and a version number.

get_pkgvars_ref

  Usage    : my $pkgvars_ref = $dist->get_pkgvars_ref;
  Returns  : The same as get_pkgvars except as a hashref.

get_pkgbuild

  Usage    : my $pkgbuildtext = $dist->get_pkgbuild;
  Returns  : A scalar containing the full text of the PKGBUILD that would
             be generated in the perl pacman package.

create_pkgbuild

  Usage   : $self->create_pkgbuild( '/tmp', 1 );
  Purpose : Creates a PKGBUILD file in the specified directory.
  Params  : $destdir - The directory to put the new PKGBUILD in.
  Precond : You must first call prepare or have CPANPLUS do it automatically.
  Throws  : unknown installer type: '...'
            failed to write PKGBUILD: ...
            Invalid arguments to create_pkgbuild
            Invalid directoy passed to create_pkgbuild: ...
  Returns : Nothing.

TEMPLATE METHODS

get_pkgbuild_templ

  Usage   : my $tt_text = $self->get_pkgbuild_templ();
  Purpose : Mostly just to compliment L</set_pkgbuild_templ>.
  Returns : The template used internally by L</get_pkgbuild>

See "PKGBUILD TEMPLATE".

set_pkgbuild_templ

  Usage   : my $new_tt_text = $self->set_pkgbuild_templ( $templ_text );
  Purpose : Create PKGBUILDs based on a custom template.
  Params  : $templ_text - New template text to use for creating the PKGBUILD.
  Returns : The new template text.

See "PKGBUILD TEMPLATE".

set_tt_init_args

  Usage   : $self->set_tt_init_args( INCLUDE_PATH => '/home/juster/aur/tt',
                                     EVAL_PERL    => 1 );
  Purpose : Change arguments that are given to the template module's
            constructor when we create an object to process templates.
  Params  : %init_args - A hash of config key/value pairs.
  Returns : A hash reference to %init_args.

What config value are supported depends on what template module is being used. You'll have to look at the module's docs to be sure.

set_tt_module

  Usage   : $obj->set_tt_module( 0 );
  Params  : $modname - The name of a template module to use or
                       0 to force using the internal engine.
  Warning : This sets the template module to use for ALL
            CPANPLUS::Dist::Arch objects.
  Returns : $modname

get_tt_module

  Usage   : my $modname = $obj->get_tt_module();
            my $modname = CPANPLUS::Dist::Arch->get_tt_module();
  Returns : The name of the template module that is being used or 0
            if we are using our own internal template engine.

PKGBUILD TEMPLATE

Since version 0.19 we now use template modules if they are available. So if any of the following modules are installed and can be used, they will be used instead of our builtin template engine:

1. Template::Toolkit
2. Template::Alloy
3. Template::Tiny

The modules have the priority listed above. We go through the list sequentially and use the first module that we find.

BUILTIN TEMPLATE FORMAT

The builtin template format is an extremely simplified ripoff of Template::Toolkit syntax. It only implements variable interpolation and the IF directive. To insert a template variable use the syntax [% foo %]. This will insert the value of the variable named 'foo'. The get_pkgbuild() method will croak with the message "Template variable ... was not provided" if the variable was not defined. [% IF var_name %] ... [% END %] will remove what is in-between the IF and END tags if the variable named var_name is not set to a true value.

Trailing newlines will also be stripped if you use the -%] syntax (notice the -) to close the Template::Toolkit style blocks.

See "get_pkgvars" for a list of the variables that can be used inside the template.

LIMITATIONS ^

There are some limitations in the way CPANPLUS and pacman works together that I am not sure can be fixed automatically. Instead you might need a human to intervene. I called these limitations because they aren't exactly bugs. More specific bugs with exact error messages are in the "BUGS" section.

Cannot detect non-perl dependencies

As of version 0.09, CPANPLUS will try to find non-perl dependencies. This only works with ExtUtils::MakeMaker distributions.

This means if you plan on distributing a perl module package (ie uploading to AUR) you should edit the PKGBUILD by hand to include the libraries needed by the XS module.

The included cpan2aur script helps creating customized AUR packages.

A module is installed, but pacman says it isn't

CPAN[PLUS] considers a module installed if it can use it. That is, if it is in @INC somewhere on your system.

Pacman considers a module installed if it has been packaged and installed with pacman.

So if you installed some modules in the past without packaging them first, they don't exist as far as pacman is concerned. Usually, you can just reinstall them using this module because CPANPLUS::Dist::Arch installs modules under the vendor_perl/ directories, such as /usr/share/perl5/vendor_perl/..., and CPAN installs under the site_perl/ directories, such as /usr/share/perl5/site_perl/....

Installing with this module will appease pacman, but you may want to manually delete the previously installed modules to prevent version mismatch problems.

Pre-requisites are always installed

CPANPLUS by default installs the pre-requisite modules before the module you requested. This module does the same only it creates an Arch package and installs it with pacman instead.

You should be able to run pacman under sudo for this to work properly. Or you could run cpan2dist as root, but I wouldn't recommend it.

Readline is broken and I can't use cpanplus!

I had this problem recently. A system upgrade had updated my readline package but the Term::ReadLine::Gnu module was not updated. Or perhaps I had the termcap-compat package, which breaks Term::ReadLine::Gnu.

I forget, in any case Term::ReadLine::Gnu was broken. To be able to update the perl-term-readline-gnu package, I had to force the Term::ReadLine module to not try to load Term::ReadLine::Gnu with the PERL_RL environment variable:

  PERL_RL=0 cpanp -i Term::ReadLine::Gnu

BUGS ^

Please email me or report any bugs or feature requests to <bug-cpanplus-dist-arch at rt.cpan.org>, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPANPLUS-Dist-Arch. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

Known Bugs

Dist creation of '...' skipped, build time exceeded: 300 seconds

If compiling a module takes a long time, this message will pop up. Interestingly, though, the module keeps compiling in the background...?

This is something CPANPLUS does automatically. If you had been trying to install the module, the install step will be aborted. The package will still be created in the usual directory, so you can install it manually.

I haven't been able to track this down yet... I think it has only happened with cpan2dist so far. It happened when building PDL, by the way.

TODO ^

SUPPORT ^

Email me at <juster at cpan dot org> or message me as juster on the Archlinux BBS at http://bbs.archlinux.org.

To check why the build process failed, read the build logs CPANPLUS keeps in ~/.cpanplus/install_logs/. The problem may be specific to the module you're building and not this module.

ACKNOWLEDGEMENTS ^

This module was inspired by the perl-cpanplus-pacman package and CPANPLUS::Dist::Pacman by Firmicus which is available at http://aur.archlinux.org/packages.php?ID=5954.

This mostly started from CPANPLUS::Dist::RPM which is on Google Code at http://code.google.com/p/cpanplus-dist-rpm/. This was a very helpful starting point to try to understand the internals of CPANPLUS.

CONTRIBUTORS ^

Contributors are credited in detail in the ChangeLog file. The following people have been kind enough to submit bug reports:

Thank you for your help!

SEE ALSO ^

AUTHOR ^

Justin Davis <juster at cpan dot org>

COPYRIGHT & LICENSE ^

Copyright 2010 Justin Davis, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: