painless perl ports with cpan2port

23
Painless Perl Ports with cpan2port Benny Siegert ‹[email protected]The MirOS Project (http://www.mirbsd.org) FOSDEM 2009

Upload: benny-siegert

Post on 05-Dec-2014

3.972 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Painless Perl Ports with cpan2port

Painless Perl Portswith cpan2portBenny Siegert ‹[email protected]

The MirOS Project (http://www.mirbsd.org)

FOSDEM 2009

Page 2: Painless Perl Ports with cpan2port

Contents

1. Introduction

Perl, MirPorts

2. Presenting cpan2port

with live demo

3. Implementation notes

4. Conclusion

Page 3: Painless Perl Ports with cpan2port

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

Page 4: Painless Perl Ports with cpan2port

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?

Page 5: Painless Perl Ports with cpan2port

# $MirOS: ports/devel/svk/Makefile,v 1.4 2008/10/04 19:46:50 bsiegert Exp $

COMMENT= distributed version control system

VERSION= 2.2.0DASH_VER= 0DISTNAME= SVK-v${VERSION}PKGNAME= svk-${VERSION}-${DASH_VER}CATEGORIES= devel net

HOMEPAGE= http://svk.bestpractical.com/MASTER_SITES= ${MASTER_SITE_PERL_CPAN:=../by-authors/id/C/CL/CLKAO/}

RESPONSIBLE= Benny Siegert <[email protected]>

# LGPLPERMIT_PACKAGE_CDROM= YesPERMIT_PACKAGE_FTP= YesPERMIT_DISTFILES_CDROM= YesPERMIT_DISTFILES_FTP= Yes

B_R_DEPENDS+= ::archivers/p5-PerlIO-via-Bzip2[...]

CONFIGURE_STYLE= perlCONFIGURE_ARGS+= --defaultdeps

.include <bsd.port.mk>

distribution name, version

category

where to download

dependencies!

one-line description

Page 6: Painless Perl Ports with cpan2port

Other metadata

‣ DESCR: long description (about 100 words)

‣ PLIST: packing list (automatically created)

‣ distinfo: checksums for distfile(automatically created)

Page 7: Painless Perl Ports with cpan2port

Introducing cpan2port

‣ Perl script allowing the rapid creationof Perl module ports

‣ using the CPAN module

‣ creates a stub port which may be refinedand drops you to a shell

‣ only a few more commands neededin the ideal case

Page 8: Painless Perl Ports with cpan2port

… live demo …Log::Dispatch module

Page 9: Painless Perl Ports with cpan2port

Implementation notes

Page 10: Painless Perl Ports with cpan2port

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

Page 11: Painless Perl Ports with cpan2port

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

download dir

Page 12: Painless Perl Ports with cpan2port

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

DISTNAME

Page 13: Painless Perl Ports with cpan2port

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

EXTRACT_SUFX

Page 14: Painless Perl Ports with cpan2port

Before “make“

Module id = Log::Dispatch DESCRIPTION Log messages to multiple outputs CPAN_USERID DROLSKY (Dave Rolsky <[email protected]>) 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 <[email protected]>) CONTAINSMODS Log::Dispatch::File::Locked [...]

Page 15: Painless Perl Ports with cpan2port

After “make“

Distribution id = D/DR/DROLSKY/Log-Dispatch-2.22.tar.gz CPAN_USERID DROLSKY (Dave Rolsky <[email protected]>) 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

Page 16: Painless Perl Ports with cpan2port

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

Page 17: Painless Perl Ports with cpan2port

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

Page 18: Painless Perl Ports with cpan2port

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);

Page 19: Painless Perl Ports with cpan2port

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

Page 20: Painless Perl Ports with cpan2port

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

Page 21: Painless Perl Ports with cpan2port

Conclusion

Page 22: Painless Perl Ports with cpan2port

‣ cpan2port does the routine workin porting Perl modules

‣ available in MirPorts, easy to port

‣ pkgsrc, FreeBSD, OpenBSD people: try it!

‣ Sources available athttp://cvs.mirbsd.de/ports/infrastructure/scripts/cpan2porthttp://cvs.mirbsd.de/ports/infrastructure/templates/perlmod.Makefile

Page 23: Painless Perl Ports with cpan2port

Thank you for your attention!

Questions?