Some of our PERL tools require some CPAN modules that are not part of the standard Ubuntu distribution. It’s obviously possible to install the module using CPAN but I like using deb packages where possible as then you only have one repository to manage. Fortunately with dh-make-perl it is possible to quickly turn any CPAN module in to a debian package!
First make sure dh-make-perl is installed
<br /> apt-get install dh-make-perl<br />
Then download the PERL module you wish to package and extract it
<br /> rus@absinthe:~$ wget https://www.cpan.org/modules/by-module/Crypt/Crypt-RC5-2.00.tar.gz<br /> rus@absinthe:~$ tar -pzxvf Crypt-RC5-2.00.tar.gz<br /> Crypt-RC5-2.00/<br /> Crypt-RC5-2.00/Changes<br /> Crypt-RC5-2.00/Makefile.PL<br /> Crypt-RC5-2.00/MANIFEST<br /> Crypt-RC5-2.00/RC5.pm<br /> Crypt-RC5-2.00/README<br /> Crypt-RC5-2.00/test.pl<br />
Now run dh-make-perl on the directory to create the files needed for the package
<br /> rus@absinthe:~$ dh-make-perl Crypt-RC5-2.00/<br /> cat: /etc/mailname: No such file or directory<br /> Use of uninitialized value in concatenation (.) or string at /usr/bin/dh-make-perl line 527.<br /> Found: Crypt::RC5 2.00 (libcrypt-rc5-perl arch=all)<br /> Package does not provide a long description - Please fill it in manually.<br /> Using maintainer: rus<br /> Found changelog: Changes<br /> Found docs: README<br /> Using rules: /usr/share/dh-make-perl/rules.MakeMaker.noxs<br /> Done<br />
This will have created a debian directory
<br /> rus@absinthe:~/Crypt-RC5-2.00$ ls<br /> Changes debian Makefile.PL MANIFEST RC5.pm README test.pl<br /> rus@absinthe:~/Crypt-RC5-2.00$ ls debian/<br /> changelog compat control copyright rules<br />
Then cd in to the directory and run debuild to actually build the package
``
rus@absinthe:$ cd Crypt-RC5-2.00//Crypt-RC5-2.00$ debuild
rus@absinthe:
This package has a Debian revision number but there does not seem to be
an appropriate original tar file or .orig directory in the parent directory;
(expected libcrypt-rc5-perl_2.00.orig.tar.gz or Crypt-RC5-2.00.orig)
continue anyway? (y/n) y
fakeroot debian/rules clean
dh_testdir
dh_testroot
Add commands to clean up after the build process here
[ ! -f Makefile ] || /usr/bin/make realclean
dh_clean build-stamp install-stamp
dpkg-source -b Crypt-RC5-2.00
dpkg-source: warning: source directory ‘./Crypt-RC5-2.00’ is not - ’libcrypt-rc5-perl-2.00’
dpkg-source: building libcrypt-rc5-perl in libcrypt-rc5-perl_2.00-1.tar.gz
dpkg-source: building libcrypt-rc5-perl in libcrypt-rc5-perl_2.00-1.dsc
debian/rules build
dh_testdir
Add commands to compile the package here
/usr/bin/perl Makefile.PL INSTALLDIRS=vendor
Checking if your kit is complete…
Looks good
Writing Makefile for Crypt::RC5
/usr/bin/make OPTIMIZE="-Wall -O2 -g"
make1: Entering directory /home/rus/Crypt-RC5-2.00'<br /> cp RC5.pm blib/lib/Crypt/RC5.pm<br /> Manifying blib/man3/Crypt::RC5.3pm<br /> make[1]: Leaving directory /home/rus/Crypt-RC5-2.00’
touch build-stamp
fakeroot debian/rules binary
dh_testdir
dh_testroot
dh_clean -k
Add commands to install the package into debian/ACKAGE_NAME here
/usr/bin/make test
make1: Entering directory `/home/rus/Crypt-RC5-2.00’
PERL_DL_NONLAZY=1 /usr/bin/perl “-Iblib/lib” “-Iblib/arch” test.pl
1..1
Running under perl version 5.008008 for linux
Current time local: Fri Feb 1 16:23:07 2008
Current time GMT: Fri Feb 1 16:23:07 2008
Using Test.pm version 1.25
ok 1
make1: Leaving directory /home/rus/Crypt-RC5-2.00'<br /> /usr/bin/make install DESTDIR=/home/rus/Crypt-RC5-2.00/debian/libcrypt-rc5-perl PREFIX=/usr<br /> make[1]: Entering directory /home/rus/Crypt-RC5-2.00’
Manifying blib/man3/Crypt::RC5.3pm
Installing /home/rus/Crypt-RC5-2.00/debian/libcrypt-rc5-perl/usr/share/perl5/Crypt/RC5.pm
Installing /home/rus/Crypt-RC5-2.00/debian/libcrypt-rc5-perl/usr/share/man/man3/Crypt::RC5.3pm
make1: Leaving directory `/home/rus/Crypt-RC5-2.00’
As this is a architecture independent package, we are not
supposed to install stuff to /usr/lib. MakeMaker creates
the dirs, we delete them from the deb:
rmdir –ignore-fail-on-non-empty –parents /home/rus/Crypt-RC5-2.00/debian/libcrypt-rc5-perl/usr/lib/perl5
touch install-stamp
dh_testdir
dh_testroot
dh_installdocs README
dh_installchangelogs Changes
dh_perl
dh_link
dh_strip
dh_compress
dh_fixperms
dh_installdeb
dh_gencontrol
dpkg-gencontrol: warning: unknown substitution variable ${misc:Depends}
dh_md5sums
dh_builddeb
dpkg-deb: building package libcrypt-rc5-perl' in ../libcrypt-rc5-perl_2.00-1_all.deb’.
dpkg-genchanges
dpkg-genchanges: including full source code in upload
dpkg-buildpackage (debuild emulation): full upload; Debian-native package (full source is included)
Now signing changes and any dsc files…
Could not find a signing program (pgp or gpg)!
debuild: fatal error at line 1174:
running debsign failed
rus@absinthe:~/Crypt-RC5-2.00$
``
You should then find a nice debian package a directory above!
<br /> rus@absinthe:~/Crypt-RC5-2.00$ ls .. | grep libcrypt | grep deb<br /> libcrypt-rc5-perl_2.00-1_all.deb<br />

Programming Perl is an awesome and recommended guide to Perl.