Difference between revisions of "Perl package guidelines"

From ArchWiki
Jump to: navigation, search
(added my own CPANPLUS::Dist plugin to the end of Automation)
m (format, markup)
Line 5: Line 5:
  
 
==File Placement==
 
==File Placement==
Perl modules should install module files in ''/usr/lib/perl5/vendor_perl/'' (this is done by setting the ''INSTALLDIRS'' variable as shown below). No files should be stored in ''/usr/lib/perl5/site_perl/'' as that directory is reserved for use by the system administrator to install Perl packages outside the package management system. The files ''perllocal.pod'' and ''.packlist'' also should not be present; this is taken care of by the example PKGBUILD given below.
+
Perl modules should install module files in {{Filename|/usr/lib/perl5/vendor_perl/}} (this is done by setting the {{Codeline|INSTALLDIRS}} variable as shown below). No files should be stored in {{Filename|/usr/lib/perl5/site_perl/}} as that directory is reserved for use by the system administrator to install Perl packages outside the package management system. The files {{Filename|perllocal.pod}} and {{Filename|.packlist}} also should not be present; this is taken care of by the example [[PKGBUILD]] given below.
  
 
==Example==
 
==Example==
An example PKGBUILD can be found at ''/usr/share/pacman/PKGBUILD-perl.proto'' which is present in the '''abs''' package. It is also reproduced below (without the comments)
+
An example PKGBUILD can be found at {{Filename|/usr/share/pacman/PKGBUILD-perl.proto}} which is present in the {{Package Official|abs}} package. It is also reproduced below (without the comments):
 
+
 
<pre>
 
<pre>
 
# Contributor: Your Name <youremail@domain.com>
 
# Contributor: Your Name <youremail@domain.com>
Line 51: Line 50:
 
</pre>
 
</pre>
  
In most cases, you should put '''any''' in the ''arch'' array since most Perl packages are architecture independent.
+
In most cases, you should put '''any''' in the {{Codeline|arch}} array since most Perl packages are architecture independent.
  
 
==Automation==
 
==Automation==
 
As Perl is centered around the [http://www.cpan.org CPAN], there are a few scripts to make the most of this, and save you writing PKGBUILDs by hand.
 
As Perl is centered around the [http://www.cpan.org CPAN], there are a few scripts to make the most of this, and save you writing PKGBUILDs by hand.
  
There is a CPANPLUS::Dist plugin which adds support for pacman, available on the AUR: http://aur.archlinux.org/packages.php?ID=5954
+
There is a {{Codeline|CPANPLUS::Dist}} plugin which adds support for pacman, available in the [[AUR]]: http://aur.archlinux.org/packages.php?ID=5954
  
There is also a script called pacpan, which can generate (recursively) PKGBUILDs for a module: http://aur.archlinux.org/packages.php?ID=23495
+
There is also a script called {{Codeline|pacpan}}, which can recursively generate PKGBUILDs for a module: http://aur.archlinux.org/packages.php?ID=23495
  
A second CPANPLUS::Dist plugin for installing CPAN modules as dynamically generated pacman packages is available at http://aur.archlinux.org/packages.php?ID=24971
+
A second {{Codeline|CPANPLUS::Dist}} plugin for installing CPAN modules as dynamically generated pacman packages is available at http://aur.archlinux.org/packages.php?ID=24971
  
 
==Before Perl 5.10.0-1 (legacy)==
 
==Before Perl 5.10.0-1 (legacy)==
'''This section refers to the old Perl guidelines and is kept for historical purposes only.'''
+
{{Note|This section refers to the old Perl guidelines and is kept for historical purposes only.}}
 
+
  
 
Packages before perl 5.10.0-1 installed modules into /usr/lib/perl5/current and /usr/lib/perl5/site_perl/current.
 
Packages before perl 5.10.0-1 installed modules into /usr/lib/perl5/current and /usr/lib/perl5/site_perl/current.
  
 
+
===Example Makefile.PL PKGBUILD===
=== Example Makefile.PL PKGBUILD ===
+
 
+
 
<pre>
 
<pre>
 
# Contributor:  Your Name <your_email@foobar.org>
 
# Contributor:  Your Name <your_email@foobar.org>
Line 99: Line 95:
 
</pre>
 
</pre>
  
===Example Build.PL PKGBUILD ===
+
===Example Build.PL PKGBUILD===
 
<pre>
 
<pre>
 
# Contributor:  Your Name <your_email@foobar.org>
 
# Contributor:  Your Name <your_email@foobar.org>

Revision as of 23:01, 12 November 2009

Package Naming

For modules the package name should begin with perl- and the rest of the name should be constructed from the module name by converting it to lowercase and then replacing colons with hyphens. For example the package name corresponding to HTML::Parser will be perl-html-parser. Perl applications should have the same name as that of the application but in lowercase.

File Placement

Perl modules should install module files in Template:Filename (this is done by setting the Template:Codeline variable as shown below). No files should be stored in Template:Filename as that directory is reserved for use by the system administrator to install Perl packages outside the package management system. The files Template:Filename and Template:Filename also should not be present; this is taken care of by the example PKGBUILD given below.

Example

An example PKGBUILD can be found at Template:Filename which is present in the Template:Package Official package. It is also reproduced below (without the comments):

# Contributor: Your Name <youremail@domain.com>
pkgname=perl-foo-bar
pkgver=VERSION
pkgrel=1
pkgdesc=""
arch=()
url=""
license=('GPL' 'PerlArtistic')
depends=('perl>=5.10.0')
makedepends=()
provides=()
conflicts=()
replaces=()
backup=()
options=(!emptydirs)
install=
source=(http://search.cpan.org/CPAN/authors/id/***/***-$pkgver.tar.gz)
md5sums=()

build() {
  cd "$srcdir/***-$pkgver"

  # install module in vendor directories.
  PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor || return 1
  make || return 1
  make install DESTDIR="$pkgdir/" || return 1

  ## for packages with Build.PL, do this instead:
  # perl Build.PL installdirs=vendor destdir="$pkgdir/"
  # perl Build
  # perl Build install

  # remove perllocal.pod and .packlist
  find "$pkgdir" -name perllocal.pod -delete
  find "$pkgdir" -name .packlist -delete
}

# vim:set ts=2 sw=2 et:

In most cases, you should put any in the Template:Codeline array since most Perl packages are architecture independent.

Automation

As Perl is centered around the CPAN, there are a few scripts to make the most of this, and save you writing PKGBUILDs by hand.

There is a Template:Codeline plugin which adds support for pacman, available in the AUR: http://aur.archlinux.org/packages.php?ID=5954

There is also a script called Template:Codeline, which can recursively generate PKGBUILDs for a module: http://aur.archlinux.org/packages.php?ID=23495

A second Template:Codeline plugin for installing CPAN modules as dynamically generated pacman packages is available at http://aur.archlinux.org/packages.php?ID=24971

Before Perl 5.10.0-1 (legacy)

Note: This section refers to the old Perl guidelines and is kept for historical purposes only.

Packages before perl 5.10.0-1 installed modules into /usr/lib/perl5/current and /usr/lib/perl5/site_perl/current.

Example Makefile.PL PKGBUILD

# Contributor:  Your Name <your_email@foobar.org>
pkgname=perl-dbd-pg
pkgver=1.49
pkgrel=1
pkgdesc="Postgres Driver for DBI"
url="http://search.cpan.org/~DBDPG/DBD-Pg"
depends=('perl-dbi>=1.45')
license=('GPL')
options=('!emptydirs')
arch=('i686' 'x86_64')
source=(http://www.cpan.org/authors/id/D/DB/DBDPG/DBD-Pg-$pkgver.tar.gz) 
md5sums=('76b9d6a2f4cbaefcba23380f83998215')

build() {
  cd  ${srcdir}/DBD-Pg-$pkgver
  eval `perl -V:archname`
  /usr/bin/perl Makefile.PL \
      INSTALLARCHLIB=/usr/lib/perl5/current/${archname} \
      INSTALLSITELIB=/usr/lib/perl5/site_perl/current \
      INSTALLSITEARCH=/usr/lib/perl5/site_perl/current/${archname}
  /usr/bin/make || return 1
  /usr/bin/make DESTDIR=${pkgdir} install
  /usr/bin/find ${pkgdir} -name '.packlist' -delete
  /usr/bin/find ${pkgdir} -name '*.pod' -delete
}

Example Build.PL PKGBUILD

# Contributor:  Your Name <your_email@foobar.org>
pkgname=perl-string-random
pkgver=0.22
pkgrel=1
pkgdesc="Generate random strings"
url="http://search.cpan.org/~STEVE/String-Random"
makedepends=('perl-module-build')
license=('GPL')
options=('!emptydirs')
arch=('i686' 'x86_64')
source=(http://www.cpan.org/authors/id/S/ST/STEVE/String-Random-$pkgver.tar.gz) 
md5sums=('c0319f95c56450624cc646f7425e327e')

build() {
  cd  ${srcdir}/String-Random-$pkgver
  eval `perl -V:archname`
  perl Build.PL destdir=${pkgdir} \
       --install_path lib=/usr/lib/perl5/site_perl/current \
       --install_path arch=/usr/lib/perl5/site_perl/current/${archname}
  ./Build
  ./Build install
  /usr/bin/find ${pkgdir} -name '.packlist' -delete
  /usr/bin/find ${pkgdir} -name '*.pod' -delete
}