Packaging Perl Modules

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    7 Favorites & 2 Groups

    Packaging Perl Modules - Presentation Transcript

    1. Packaging Perl Modules Kirrily Robert
    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
    3. Today... • How CPAN modules are packaged • Why it rocks • Why you should use it everywhere • How to integrate it with release mgt
    4. Creating CPAN modules • Always use h2xs • Always use h2xs • ALWAYS use h2xs
    5. Wrong.
    6. Two main options • h2xs • module-starter
    7. h2xs • Old-school • Comes with Perl • Few modern features • Good XS stubs, though
    8. module-starter • Module::Starter on CPAN • Modern features • Better stubs • Higher Kwalitee
    9. module-starter $ module-starter --module Gift::Basket Created starter directories and files $ ls Gift-Basket/ Build.PL MANIFEST lib Changes README t
    10. Configuration $ cat ~/.module-starter/config builder: Module::Build author: Kirrily Robert email: skud@cpan.org
    11. Module layout Build.PL MANIFEST lib Changes README t
    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();
    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.
    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
    15. README • Description • Installation • Support • License
    16. lib/ $ find lib lib lib/Gift lib/Gift/Basket.pm
    17. t/ $ find t t t/00-load.t t/boilerplate.t t/pod-coverage.t t/pod.t
    18. Building modules • ./Build dist • ./Build disttest • Upload to PAUSE • http://pause.perl.org • cpaninject
    19. Why this rocks • Standard build/install tools • Metadata and tests included by default • Encourages modularity
    20. Non-CPAN CPAN Modules
    21. Standard build tools • Save time and effort • Already familiar to many developers • Easy release path to CPAN
    22. Metadata and tests • Encourage testing • Specify dependencies
    23. Modularity • Reduce spaghetti • Share code between projects • Easy release path to CPAN
    24. Example $ ls code/ GiftCo-Core GiftCo-Payments GiftCo-DB GiftCo-Reporting GiftCo-MailTools GiftCo-Website
    25. Web Server GiftCo::Website GiftCo::Core GiftCo::DB GiftCo::Payments
    26. Backend GiftCo::Reporting GiftCo::Payments GiftCo::DB GiftCo::Core GiftCo::MailTools
    27. Installation • Local CPAN • Distro packages
    28. Local CPAN • MiniCPAN • Add local packages • Configure CPAN.pm
    29. MiniCPAN • perl -MCPAN -e ‘install CPAN::Mini’ • minicpan -l $LOCAL -r $REMOTE
    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
    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/]
    32. Distro packages • Integrates with non-Perl packages • Standardised install procedure • Sysadmins like them
    33. Dependencies GiftCo::DB DBI DBD::mysql mysql-lib
    34. Packaging • cpan2rpm • dh-make-perl
    35. cpan2rpm • Creates RPMs from CPAN modules • Redhat-derived distros • cpan2rpm -U GiftCo::DB • Creates full RPM package
    36. dh-make-perl • Comes with Debian/Ubuntu • Creates .deb packages • dh-make-perl GiftCo-DB-0.01/ • Creates debian/ directory
    37. Issues • Neither follows CPAN dependencies • You must walk the dep tree (once) • Can specify deps thereafter
    38. Example GiftCo::Website GiftCo::DB requires becomes becomes libgiftco-website-perl libgiftco-db-perl requires
    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]?
    40. Kirrily Robert http://infotrope.net skud@infotrope.net

    + SkudSkud, 2 years ago

    custom

    5525 views, 7 favs, 2 embeds more stats

    A talk from the Open Source Developers' Conference more

    More Info

    CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

    Go to text version
    • Total Views 5525
      • 5510 on SlideShare
      • 15 from embeds
    • Comments 0
    • Favorites 7
    • Downloads 126
    Most viewed embeds
    • 12 views on http://thomas-fahle.blogspot.com
    • 3 views on http://blogs.unixfu.net

    more

    All embeds
    • 12 views on http://thomas-fahle.blogspot.com
    • 3 views on http://blogs.unixfu.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as innappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel

    Categories

    Groups / Events