Slideshare.net (beta)

 
Post to TwitterPost to Twitter
Post: 
Myspace Hi5 Friendster Xanga LiveJournal Facebook Blogger Tagged Typepad Freewebs BlackPlanet gigya icons

All comments

Add a comment on Slide 1

If you have a SlideShare account, login to comment; else you can comment as a guest


Showing 1-50 of 7 (more)

Packaging Perl Modules

From Skud, 10 months ago

A talk from the Open Source Developers' Conference 2007. How to p more

3360 views  |  0 comments  |  5 favorites  |  91 downloads  |  2 embeds (Stats)
 

Categories

Add Category
 
 

Groups / Events

 
Embed
options

More Info

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License
This slideshow is Public
Total Views: 3360
on Slideshare: 3345
from embeds: 15

Slideshow transcript

Slide 1: Packaging Perl Modules Kirrily Robert

Slide 2: Look familiar? ~skud/.cpan/build/Archive-Any-0.093 $ ls Build.PL META.yml README pm_to_blib Changes Makefile blib t MANIFEST Makefile.PL lib

Slide 3: Today... • How CPAN modules are packaged • Why it rocks • Why you should use it everywhere • How to integrate it with release mgt

Slide 4: Creating CPAN modules • Always use h2xs • Always use h2xs • ALWAYS use h2xs

Slide 5: Wrong.

Slide 6: Two main options • h2xs • module-starter

Slide 7: h2xs • Old-school • Comes with Perl • Few modern features • Good XS stubs, though

Slide 8: module-starter • Module::Starter on CPAN • Modern features • Better stubs • Higher Kwalitee

Slide 9: module-starter $ module-starter --module Gift::Basket Created starter directories and files $ ls Gift-Basket/ Build.PL MANIFEST lib Changes README t

Slide 10: Configuration $ cat ~/.module-starter/config builder: Module::Build author: Kirrily Robert email: skud@cpan.org

Slide 11: Module layout Build.PL MANIFEST lib Changes README t

Slide 12: Build.PL use strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'Gift::Basket', license => 'perl', dist_author => 'Kirrily Robert <skud@cpan.org>', dist_version_from => 'lib/Gift/Basket.pm', build_requires => { 'Test::More' => 0, }, add_to_cleanup => [ 'Gift-Basket-*' ], ); $builder->create_build_script();

Slide 13: Changes Revision history for Gift-Basket 0.03 2007-11-20 Added support for shipping gift baskets to addresses within Australia and NZ. 0.02 2007-11-05 Fixed a bug with adding chocolates to the basket. 0.01 2007-11-01 Initial release. Includes methods for building a gift basket and calculating prices. Not ready for production.

Slide 14: MANIFEST Build.PL Changes MANIFEST META.yml # Will be created by \"make dist\" README lib/Gift/Basket.pm t/00-load.t t/boilerplate.t t/pod-coverage.t t/pod.t

Slide 15: README • Description • Installation • Support • License

Slide 16: lib/ $ find lib lib lib/Gift lib/Gift/Basket.pm

Slide 17: t/ $ find t t t/00-load.t t/boilerplate.t t/pod-coverage.t t/pod.t

Slide 18: Building modules • ./Build dist • ./Build disttest • Upload to PAUSE • http://pause.perl.org • cpaninject

Slide 19: Why this rocks • Standard build/install tools • Metadata and tests included by default • Encourages modularity

Slide 20: Non-CPAN CPAN Modules

Slide 21: Standard build tools • Save time and effort • Already familiar to many developers • Easy release path to CPAN

Slide 22: Metadata and tests • Encourage testing • Specify dependencies

Slide 23: Modularity • Reduce spaghetti • Share code between projects • Easy release path to CPAN

Slide 24: Example $ ls code/ GiftCo-Core GiftCo-Payments GiftCo-DB GiftCo-Reporting GiftCo-MailTools GiftCo-Website

Slide 25: Web Server GiftCo::Website GiftCo::Core GiftCo::DB GiftCo::Payments

Slide 26: Backend GiftCo::Reporting GiftCo::Payments GiftCo::DB GiftCo::Core GiftCo::MailTools

Slide 27: Installation • Local CPAN • Distro packages

Slide 28: Local CPAN • MiniCPAN • Add local packages • Configure CPAN.pm

Slide 29: MiniCPAN • perl -MCPAN -e ‘install CPAN::Mini’ • minicpan -l $LOCAL -r $REMOTE

Slide 30: Inject • perl -MCPAN -e ‘install CPAN::Mini::Inject’ • mcpani --add --module GiftCo::DB --authorid SKUD --modversion 0.01 --file GiftCo::DB-0.01.tar.gz

Slide 31: Configure cpan[1]> o conf urllist urllist 0 [file:///Users/skud/mirrors/cpan/] 1 [ftp://cpan.pair.com/pub/CPAN/] 2 [ftp://cpan.hexten.net/]

Slide 32: Distro packages • Integrates with non-Perl packages • Standardised install procedure • Sysadmins like them

Slide 33: Dependencies GiftCo::DB DBI DBD::mysql mysql-lib

Slide 34: Packaging • cpan2rpm • dh-make-perl

Slide 35: cpan2rpm • Creates RPMs from CPAN modules • Redhat-derived distros • cpan2rpm -U GiftCo::DB • Creates full RPM package

Slide 36: dh-make-perl • Comes with Debian/Ubuntu • Creates .deb packages • dh-make-perl GiftCo-DB-0.01/ • Creates debian/ directory

Slide 37: Issues • Neither follows CPAN dependencies • You must walk the dep tree (once) • Can specify deps thereafter

Slide 38: Example GiftCo::Website GiftCo::DB requires becomes becomes libgiftco-website-perl libgiftco-db-perl requires

Slide 39: apt-get install $ sudo apt-get install giftco-website Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: libgiftco-website-perl libgiftco-db-perl libgiftco-core-perl libgiftco-payments-perl libdbi-perl libdbd-mysql-perl libmysql The following NEW packages will be installed: giftco-website libgiftco-website-perl libgiftco-db-perl libgiftco-core-perl libgiftco-payments-perl libdbi-perl libdbd-mysql-perl libmysql 0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded. Need to get 8.3MB of archives. After unpacking 25MB of additional disk space will be used. Do you want to continue [Y/n]?

Slide 40: Kirrily Robert http://infotrope.net skud@infotrope.net