Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Painless Perl Ports
  with cpan2port
    Benny Siegert ‹bsiegert@gmail.com›
The MirOS Project (http://www.mirbsd.org)

   ...
Contents
1. Introduction
  Perl, MirPorts
2. Presenting cpan2port
  with live demo
3. Implementation notes
4. Conclusion
Perl and CPAN
‣ Comprehensive Perl Archive Network
‣ 15 000 modules by >7000 authors
 ➡ lots of ports to create


‣ CPAN m...
Ports
‣ mechanism to install 3rd-party software in
  BSD operating systems
‣ ports are used to create binary packages
‣ in...
# $MirOS: ports/devel/svk/Makefile,v 1.4 2008/10/04 19:46:50 bsiegert Exp $

                                             ...
Other metadata


‣ DESCR: long description (about 100 words)
‣ PLIST: packing list (automatically created)
‣ distinfo: che...
Introducing cpan2port
‣ Perl script allowing the rapid creation
  of Perl module ports
  ‣ using the CPAN module


‣ creat...
… live demo …
Log::Dispatch module
Implementation notes
How does it work?

‣ CPAN.pm discovers most of the information
  needed
‣ finds the distribution name for a module
  (e.g. ...
How does it work?

‣ CPAN.pm discovers most of the information
  needed
‣ finds the distribution name for a module
  (e.g. ...
How does it work?

‣ CPAN.pm discovers most of the information
  needed
‣ finds the distribution name for a module
  (e.g. ...
How does it work?

‣ CPAN.pm discovers most of the information
  needed
‣ finds the distribution name for a module
  (e.g. ...
Before “make“
Module id = Log::Dispatch
    DESCRIPTION Log messages to multiple outputs
    CPAN_USERID DROLSKY (Dave Rol...
After “make“
Distribution id = D/DR/DROLSKY/Log-Dispatch-2.22.tar.gz
    CPAN_USERID DROLSKY (Dave Rolsky <autarch@urth.or...
Dependencies
‣ prereq_pm is a hash with
  module => minversion

‣ expand module to distname
‣ static table of modules in t...
Descriptions

‣ For some modules, cpan knows a one-line
  description (COMMENT), not for others
‣ readmes are useless for ...
POD parsing
‣ “NAME“ section contains one-line comment
  ‣   Log::Dispatch - Dispatches messages to one or
      more outp...
finally …
‣ ask user for category, create directory
‣ variable substitution in Makefile template
‣ write DESCR
‣ copy distfil...
Porting to other systems
‣ right now, cpan2port is available for MirPorts


‣ easily portable
‣ adapt perlmod.Makefile temp...
Conclusion
‣ cpan2port does the routine work
  in porting Perl modules

‣ available in MirPorts, easy to port

‣ pkgsrc, FreeBSD, Ope...
Thank you for your attention!

         Questions?
Upcoming SlideShare
Loading in …5
×

Painless Perl Ports with cpan2port

3,137 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Painless Perl Ports with cpan2port

  1. 1. Painless Perl Ports with cpan2port Benny Siegert ‹bsiegert@gmail.com› The MirOS Project (http://www.mirbsd.org) FOSDEM 2009
  2. 2. Contents 1. Introduction Perl, MirPorts 2. Presenting cpan2port with live demo 3. Implementation notes 4. Conclusion
  3. 3. Perl and CPAN ‣ Comprehensive Perl Archive Network ‣ 15 000 modules by >7000 authors ➡ lots of ports to create ‣ CPAN module and shell (perl -MCPAN -eshell) does not know about ports and packages
  4. 4. Ports ‣ mechanism to install 3rd-party software in BSD operating systems ‣ ports are used to create binary packages ‣ installation “recipe” in a Makefile + metadata ↪What is required to create a port?
  5. 5. # $MirOS: ports/devel/svk/Makefile,v 1.4 2008/10/04 19:46:50 bsiegert Exp $ one-line description COMMENT= distributed version control system VERSION= 2.2.0 distribution name, version DASH_VER= 0 DISTNAME= SVK-v${VERSION} PKGNAME= svk-${VERSION}-${DASH_VER} category CATEGORIES= devel net HOMEPAGE= http://svk.bestpractical.com/ MASTER_SITES= ${MASTER_SITE_PERL_CPAN:=../by-authors/id/C/CL/CLKAO/} where to download RESPONSIBLE= Benny Siegert <bsiegert@gmx.de> # LGPL PERMIT_PACKAGE_CDROM= Yes PERMIT_PACKAGE_FTP= Yes PERMIT_DISTFILES_CDROM= Yes PERMIT_DISTFILES_FTP= Yes B_R_DEPENDS+= ::archivers/p5-PerlIO-via-Bzip2 [...] dependencies! CONFIGURE_STYLE= perl CONFIGURE_ARGS+= --defaultdeps .include <bsd.port.mk>
  6. 6. Other metadata ‣ DESCR: long description (about 100 words) ‣ PLIST: packing list (automatically created) ‣ distinfo: checksums for distfile (automatically created)
  7. 7. Introducing cpan2port ‣ Perl script allowing the rapid creation of Perl module ports ‣ using the CPAN module ‣ creates a stub port which may be refined and drops you to a shell ‣ only a few more commands needed in the ideal case
  8. 8. … live demo … Log::Dispatch module
  9. 9. Implementation notes
  10. 10. How does it work? ‣ CPAN.pm discovers most of the information needed ‣ finds the distribution name for a module (e.g. D/DR/DROLSKY/Log-Dispatch-2.22.tar.gz) ‣ for more info, “make“ the module inside cpan
  11. 11. How does it work? ‣ CPAN.pm discovers most of the information needed ‣ finds the distribution name for a module (e.g. D/DR/DROLSKY/Log-Dispatch-2.22.tar.gz) download dir ‣ for more info, “make“ the module inside cpan
  12. 12. How does it work? ‣ CPAN.pm discovers most of the information needed ‣ finds the distribution name for a module (e.g. D/DR/DROLSKY/Log-Dispatch-2.22.tar.gz) DISTNAME ‣ for more info, “make“ the module inside cpan
  13. 13. How does it work? ‣ CPAN.pm discovers most of the information needed ‣ finds the distribution name for a module (e.g. D/DR/DROLSKY/Log-Dispatch-2.22.tar.gz) EXTRACT_SUFX ‣ for more info, “make“ the module inside cpan
  14. 14. Before “make“ Module id = Log::Dispatch DESCRIPTION Log messages to multiple outputs CPAN_USERID DROLSKY (Dave Rolsky <autarch@urth.org>) CPAN_VERSION 2.22 CPAN_FILE D/DR/DROLSKY/Log-Dispatch-2.22.tar.gz DSLI_STATUS RdpO (released,developer,perl,object-oriented) INST_FILE (not installed) Distribution id = D/DR/DROLSKY/Log-Dispatch-2.22.tar.gz CPAN_USERID DROLSKY (Dave Rolsky <autarch@urth.org>) CONTAINSMODS Log::Dispatch::File::Locked [...]
  15. 15. After “make“ Distribution id = D/DR/DROLSKY/Log-Dispatch-2.22.tar.gz CPAN_USERID DROLSKY (Dave Rolsky <autarch@urth.org>) CALLED_FOR Log::Dispatch CONTAINSMODS Log::Dispatch::File::Locked [...] MD5_STATUS OK archived tar build_dir /Users/bsiegert/.cpan/build/Log-Dispatch-2.22 localfile /Users/bsiegert/.cpan/sources/authors/id/D/DR/ DROLSKY/Log-Dispatch-2.22.tar.gz make YES prereq_pm Test::More Params::Validate File::Temp Module::Build prereq_pm_detected 1 unwrapped YES writemakefile YES
  16. 16. Dependencies ‣ prereq_pm is a hash with module => minversion ‣ expand module to distname ‣ static table of modules in the base system, with “unsystematic“ names or non-CPAN ‣ rest: glob for /usr/ports/*/p5-NAME ‣ output dependency string in our format
  17. 17. Descriptions ‣ For some modules, cpan knows a one-line description (COMMENT), not for others ‣ readmes are useless for getting a longer one ‣ parse the manpage, i.e. the POD
  18. 18. POD parsing ‣ “NAME“ section contains one-line comment ‣ Log::Dispatch - Dispatches messages to one or more outputs ‣ longer description: first few paragraphs from “DESCRIPTION“ section ‣ up to first control command ‣ plain-text conversion is easy my $parser = Pod::Text->new(indent => 0, width => 72);
  19. 19. finally … ‣ ask user for category, create directory ‣ variable substitution in Makefile template ‣ write DESCR ‣ copy distfile to Distfiles directory ‣ run “make checksum“ ‣ drop user to a shell, needs to run regress, update-plist, install targets
  20. 20. Porting to other systems ‣ right now, cpan2port is available for MirPorts ‣ easily portable ‣ adapt perlmod.Makefile template ‣ change base module list accordingly ‣ adapt dependency output to your syntax
  21. 21. Conclusion
  22. 22. ‣ cpan2port does the routine work in porting Perl modules ‣ available in MirPorts, easy to port ‣ pkgsrc, FreeBSD, OpenBSD people: try it! ‣ Sources available at http://cvs.mirbsd.de/ports/infrastructure/scripts/cpan2port http://cvs.mirbsd.de/ports/infrastructure/templates/ perlmod.Makefile
  23. 23. Thank you for your attention! Questions?

×