| 1 | [wiki:howto <- Back to the HOWTO section] |
| 2 | |
| 3 | = TODO: title = |
| 4 | |
| 5 | * Audience: Perl users |
| 6 | * Requires: MacPorts >=TODO |
| 7 | |
| 8 | == Introduction == |
| 9 | |
| 10 | When you find you need a Perl modules from CPAN that does not yet have a MacPorts port, cpan2port can help you create a port file. |
| 11 | |
| 12 | === Step 1: '''Set up cpan client''' === |
| 13 | |
| 14 | You must have a properly configured cpan client for cpan2port to work. |
| 15 | You can either step throught the questions, or let it auto-configure. |
| 16 | {{{ |
| 17 | $ cpan |
| 18 | CPAN is the world-wide archive of perl resources. It consists of about |
| 19 | [...] |
| 20 | Would you like me to configure as much as possible automatically? [yes] ''yes'' |
| 21 | [...] |
| 22 | cpan shell -- CPAN exploration and modules installation (v1.9301) |
| 23 | ReadLine support available (maybe install Bundle::CPAN or Bundle::CPANxxl?) |
| 24 | |
| 25 | cpan[1]> ^D |
| 26 | }}} |
| 27 | === Step 2: '''Find the CPAN package name''' === |
| 28 | {{{ |
| 29 | $ perl -MCPAN -e shell |
| 30 | cpan[1]> m Date::Parse |
| 31 | Module id = Date::Parse |
| 32 | DESCRIPTION ASCII Date parser using regexp's |
| 33 | CPAN_USERID GBARR (Graham Barr <gbarr@pobox.com>) |
| 34 | CPAN_VERSION 2.30 |
| 35 | CPAN_FILE G/GB/GBARR/TimeDate-1.20.tar.gz |
| 36 | DSLIP_STATUS Rdpf? (released,developer,perl,functions,) |
| 37 | MANPAGE Date::Parse - Parse date strings into time values |
| 38 | INST_FILE /opt/local/lib/perl5/vendor_perl/5.8.9/Date/Parse.pm |
| 39 | INST_VERSION 2.27 |
| 40 | }}} |
| 41 | |
| 42 | So you want the TimeDate module. |
| 43 | |
| 44 | === Step 3: '''Check that port is not available''' === |
| 45 | |
| 46 | Perl modules have names of the form p5-modulename. |
| 47 | |
| 48 | {{{ |
| 49 | $ port search p5-timedate |
| 50 | }}} |
| 51 | |
| 52 | This particular port actually is available, but we'll pretend it isn't. |
| 53 | |
| 54 | === Step 4: '''Create MacPorts directory === |
| 55 | |
| 56 | {{{ |
| 57 | $ mkdir ~/macports |
| 58 | $ cd ~/macports |
| 59 | $ curl http://trac.macports.org/export/69899/contrib/cpan2port/cpan2port > cpan2port |
| 60 | $ chmod u+x cpan2port |
| 61 | }}} |
| 62 | |
| 63 | === Step 5: '''Create the port file''' === |
| 64 | {{{ |
| 65 | $ ./cpan2port -t Date::Parse |
| 66 | [...] |
| 67 | TimeDate-1.20/ |
| 68 | TimeDate-1.20/ChangeLog |
| 69 | [...] |
| 70 | trying to find dist in /Users/dtls/.cpan/build/TimeDate-1.20* |
| 71 | --- |
| 72 | md5: 7da7452bce4c684e4238e6d09b390200 |
| 73 | rmd160: 513094a2d2fb3678c1ad893abc28c94d344ec7b8 |
| 74 | sha1: 6394cd243e05c3c2073fa73348a4ad90d8d5963e |
| 75 | creating perl/p5-timedate/Portfile |
| 76 | }}} |
| 77 | |
| 78 | === Step 6: '''Build the port''' === |
| 79 | First you can review the portfile: |
| 80 | {{{ |
| 81 | $ cd perl/p5-timedate |
| 82 | $ cat Portfile |
| 83 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf8:ft=tcl:et:sw=4:ts=4:sts=4 |
| 84 | # $Id$ |
| 85 | |
| 86 | PortSystem 1.0 |
| 87 | PortGroup perl5 1.0 |
| 88 | |
| 89 | perl5.setup TimeDate 1.20 |
| 90 | platforms darwin |
| 91 | maintainers cpan2port |
| 92 | description ASCII Date parser using regexp's |
| 93 | extract.suffix .tar.gz |
| 94 | master_sites http://search.cpan.org/CPAN/authors/id/G/GB/GBARR |
| 95 | checksums sha1 6394cd243e05c3c2073fa73348a4ad90d8d5963e md5 7da7452bce4c684e4238e6d09b390200 rmd160 513094a2d2fb3678c1ad893abc28c94d344ec7b8 |
| 96 | }}} |
| 97 | |
| 98 | The build it: |
| 99 | {{{ |
| 100 | $ port build |
| 101 | Warning: MacPorts running without privileges. You may be unable to complete certain actions (e.g. install). |
| 102 | ---> Computing dependencies for p5-timedate |
| 103 | ---> Fetching p5-timedate |
| 104 | ---> Attempting to fetch TimeDate-1.20.tar.gz from http://distfiles.macports.org/perl5 |
| 105 | ---> Attempting to fetch TimeDate-1.20.tar.gz from http://lil.fr.distfiles.macports.org/perl5 |
| 106 | ---> Attempting to fetch TimeDate-1.20.tar.gz from http://aarnet.au.distfiles.macports.org/pub/macports/mpdistfiles/perl5 |
| 107 | ---> Attempting to fetch TimeDate-1.20.tar.gz from http://search.cpan.org/CPAN/authors/id/G/GB/GBARR |
| 108 | ---> Verifying checksum(s) for p5-timedate |
| 109 | ---> Extracting p5-timedate |
| 110 | ---> Configuring p5-timedate |
| 111 | ---> Building p5-timedate |
| 112 | }}} |
| 113 | |
| 114 | === Step 7: '''Read up on local port repositories''' === |
| 115 | |
| 116 | [http://guide.macports.org/chunked/development.local-repositories.html] |
| 117 | |
| 118 | ---- |
| 119 | |
| 120 | [wiki:howto <- Back to the HOWTO section] |