Version 6 (modified by mf2k (Frank Schima), 12 years ago) (diff) |
---|
How to create portfiles for CPAN Perl modules
- Audience: Perl users
- Requires the following MacPorts perl ports: p5-list-moreutils p5-parse-cpan-meta p5-module-depends p5-cpan-meta-yaml
Introduction
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.
Step 1: Set up cpan client
You must have a properly configured cpan client for cpan2port to work. You can either step through the questions, or let it auto-configure.
$ cpan CPAN is the world-wide archive of perl resources. It consists of about [...] Would you like me to configure as much as possible automatically? [yes] ''yes'' [...] cpan shell -- CPAN exploration and modules installation (v1.9301) ReadLine support available (maybe install Bundle::CPAN or Bundle::CPANxxl?) cpan[1]> ^D
Step 2: Find the CPAN package name
$ perl -MCPAN -e shell cpan[1]> m Date::Parse Module id = Date::Parse DESCRIPTION ASCII Date parser using regexp's CPAN_USERID GBARR (Graham Barr <gbarr@pobox.com>) CPAN_VERSION 2.30 CPAN_FILE G/GB/GBARR/TimeDate-1.20.tar.gz DSLIP_STATUS Rdpf? (released,developer,perl,functions,) MANPAGE Date::Parse - Parse date strings into time values INST_FILE /opt/local/lib/perl5/vendor_perl/5.8.9/Date/Parse.pm INST_VERSION 2.27
So you want the TimeDate module.
Step 3: Check that port is not available
Perl modules have names of the form p5-modulename.
$ port search p5-timedate
This particular port actually is available, but we'll pretend it isn't.
Step 4: Create MacPorts directory
$ mkdir ~/macports $ cd ~/macports $ curl -O https://svn.macports.org/repository/macports/contrib/cpan2port/cpan2port $ chmod u+x cpan2port
Step 5: Create the port file
$ ./cpan2port -t Date::Parse [...] TimeDate-1.20/ TimeDate-1.20/ChangeLog [...] trying to find dist in /Users/dtls/.cpan/build/TimeDate-1.20* --- md5: 7da7452bce4c684e4238e6d09b390200 rmd160: 513094a2d2fb3678c1ad893abc28c94d344ec7b8 sha1: 6394cd243e05c3c2073fa73348a4ad90d8d5963e creating perl/p5-timedate/Portfile
Step 6: Build the port
First you can review the portfile:
$ cd perl/p5-timedate $ cat Portfile # -*- 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 # $Id$ PortSystem 1.0 PortGroup perl5 1.0 perl5.setup TimeDate 1.20 platforms darwin maintainers cpan2port description ASCII Date parser using regexp's extract.suffix .tar.gz master_sites http://search.cpan.org/CPAN/authors/id/G/GB/GBARR checksums sha1 6394cd243e05c3c2073fa73348a4ad90d8d5963e md5 7da7452bce4c684e4238e6d09b390200 rmd160 513094a2d2fb3678c1ad893abc28c94d344ec7b8
The build it:
$ port build Warning: MacPorts running without privileges. You may be unable to complete certain actions (e.g. install). ---> Computing dependencies for p5-timedate ---> Fetching p5-timedate ---> Attempting to fetch TimeDate-1.20.tar.gz from http://distfiles.macports.org/perl5 ---> Attempting to fetch TimeDate-1.20.tar.gz from http://lil.fr.distfiles.macports.org/perl5 ---> Attempting to fetch TimeDate-1.20.tar.gz from http://aarnet.au.distfiles.macports.org/pub/macports/mpdistfiles/perl5 ---> Attempting to fetch TimeDate-1.20.tar.gz from http://search.cpan.org/CPAN/authors/id/G/GB/GBARR ---> Verifying checksum(s) for p5-timedate ---> Extracting p5-timedate ---> Configuring p5-timedate ---> Building p5-timedate
Step 7: Read up on local port repositories
http://guide.macports.org/chunked/development.local-repositories.html