You are not logged in.

#1 2010-12-13 00:05:12

gauthma
Member
Registered: 2010-02-16
Posts: 215
Website

PKGBUILD, perl, and a novice

I've written a PKGBUILD for a perl module called File-KeePass, but instead using the CPANDist tool (which has some dependency problem), I did manually, using as base the PKGBUILD of perl-crypt-rijndael (it's in AUR, and it's the only dependency of File-KeePass). Here's the final result:

# Maintainer: Oscar Pereira <gauthma dot san att gmail com>
# Generator  : by hand
pkgname='perl-file-keepass'
pkgver='0.03'
pkgrel='1'
pkgdesc="Interface to KeePass V1 database files"
arch=('i686' 'x86_64')
license=('PerlArtistic' 'GPL')
options=('!emptydirs')
depends=('perl')
makedepends=('perl-crypt-rijndael')
url='http://search.cpan.org/dist/File-KeePass'
source=('http://search.cpan.org/CPAN/authors/id/R/RH/RHANDOM/File-KeePass-0.03.tar.gz')
md5sums=('28bbb9c4015496ca1b7d050d4abd7c28')

build() {
  PERL=/usr/bin/perl
  DIST_DIR="${srcdir}/File-KeePass-0.03"
  export PERL_MM_USE_DEFAULT=1 PERL5LIB=""                 \
    PERL_AUTOINSTALL=--skipdeps                            \
    PERL_MM_OPT="INSTALLDIRS=vendor DESTDIR='$pkgdir'"     \
    PERL_MB_OPT="--installdirs vendor --destdir '$pkgdir'" \
    MODULEBUILDRC=/dev/null

  { cd "$DIST_DIR" &&
    $PERL Makefile.PL &&
    make &&
    make test &&
    make install;
  } || return 1;

  find "$pkgdir" -name .packlist -o -name perllocal.pod -delete
}

I've installed this on my machine, and it works. But I have a couple of questions. The first is the fact that it does not have a "provides=" line (it's base PKGBUILD also lacked it). I think this should have a line like so: "provides=('perl-file-keepass')". Is this so?
Next, I tweaked the comment "Generator" line, for obvious reasons (it previously contained a reference to the CPANDist tool); is it best to keep it, or remove it altogether?
Pending the aforementioned issues, is it OK for AUR submission? smile

Offline

#2 2010-12-13 00:11:13

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,365
Website

Re: PKGBUILD, perl, and a novice

No need for the provides line.   Also the "find -delete" line is unneeded as makepkg does this automatically (check out the PURGE option in makepkg.conf).

Your build function seems overly complicated.  Check out some of the PKGBUILDs for perl modules in [extra] and [community] for examples to follow.

Offline

#3 2010-12-13 23:22:45

gauthma
Member
Registered: 2010-02-16
Posts: 215
Website

Re: PKGBUILD, perl, and a novice

Thanks for the feedback. I was indeed able to simplify it:

# Maintainer: Oscar Pereira <gauthma dot san att gmail com>
# Generator  : by hand
pkgname=perl-file-keepass
pkgver=0.03
pkgrel=1
pkgdesc="Interface to KeePass V1 database files"
arch=('i686' 'x86_64')
license=('PerlArtistic' 'GPL')
options=('!emptydirs')
depends=('perl')
makedepends=('perl-crypt-rijndael')
url='http://search.cpan.org/dist/File-KeePass'
source=('http://search.cpan.org/CPAN/authors/id/R/RH/RHANDOM/File-KeePass-0.03.tar.gz')
md5sums=('28bbb9c4015496ca1b7d050d4abd7c28')

build() {
  cd $srcdir/File-KeePass-$pkgver
  PERL_MM_USE_DEFAULT=1 PERL_AUTOINSTALL="--skipdeps" PERL5LIB="" perl Makefile.PL INSTALLDIRS=vendor || return 1
  make || return 1
  make test
  make install DESTDIR=$pkgdir || return 1
}

One question though: if the "find -delete" lines are removed, won't that affect the users who remove PURGE from the OPTIONS array? Not that I imagine why would anyone do something like that, but I'm guessing that extra line in the PKGBUILD is a safeguard... I'm asking this because the packages I saw in [community] all had it...

Offline

#4 2010-12-13 23:37:09

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,365
Website

Re: PKGBUILD, perl, and a novice

gauthma wrote:

I'm asking this because the packages I saw in [community] all had it...

That is just an example of poor packaging...  sad

You can also remove all the "return 1"s as makepkg does that automatically.

Offline

#5 2010-12-13 23:50:20

gauthma
Member
Registered: 2010-02-16
Posts: 215
Website

Re: PKGBUILD, perl, and a novice

Allan wrote:
gauthma wrote:

I'm asking this because the packages I saw in [community] all had it...

That is just an example of poor packaging...  sad

But if PURGE is removed from the OPTIONS array, is this still safe?

You can also remove all the "return 1"s as makepkg does that automatically.

I've checked the wiki for both makepkg and pkgbuild... Is there a place where this sort of thing is explained/mentioned?

Offline

#6 2010-12-14 01:41:26

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: PKGBUILD, perl, and a novice

It should have been mentioned in pacman 3.4's release notes. It's easier seen by looking at the shebang for makepkg, where it includes a -e flag. It means that if an operation ever returns anything but 0, makepkg quits. Because of this, the '|| return 1' idiom is superfluous. You'll still see it around because a lot of packages haven't been updated... or what Allan said...

Offline

#7 2010-12-18 13:07:25

gauthma
Member
Registered: 2010-02-16
Posts: 215
Website

Re: PKGBUILD, perl, and a novice

As I was about to submit the PKGBUILD to AUR, I ran namcap on pkg tarball, and it gave these two warnings:

perl-file-keepass W: No ELF files and not an "any" package
perl-file-keepass W: Dependency included and not needed ('perl')

As I understand it, the latter is a limitation of namcap. But to get rid of the former, I had to change the architecture to 'any' (instead of both 'x86_64' and 'i686'). Is this the way scripts in general (perl, python, shell scripts?) are suppose to be packaged? Again, I'm asking because of what I saw in community...

Also, what's the best way to submit a request for that first message to be changed to something that hints that the problem is related to the arch=()? Submit a bug?

EDIT: I've checked the man page of PKGBUILD, and came across the answer to my first question:

Packages that contain no architecture specific files may use arch=(any).

Last edited by gauthma (2010-12-18 13:09:49)

Offline

#8 2010-12-18 13:17:25

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,365
Website

Re: PKGBUILD, perl, and a novice

gauthma wrote:

I've checked the wiki for both makepkg and pkgbuild... Is there a place where this sort of thing is explained/mentioned?

It will be mentioned in the PKGBUILD man page in future releases:
http://projects.archlinux.org/pacman.gi … d=ba45cb45

Offline

Board footer

Powered by FluxBB