NAME
cpan2rpm - A Perl module packager
SYNOPSIS
cpan2rpm [options] <module>
This script generates an RPM package from a Perl module. It uses the standard RPM file structure and creates a spec file, a source RPM, and a binary, leaving these in their respective directories.
The script can operate on local files, urls and CPAN module names. Install this package if you want to create RPMs out of Perl modules.
DESCRIPTION
The syntax for cpan2rpm requires a single module name, which can take one of three different forms: 1) a CPAN module name (e.g. XML::Simple), 2) a URL (both http:// and ftp:// style locators will work), and 3) a local filename reference to a tarball (e.g. /tmp/XML-Simple-1.05.tar.gz). The module name may be preceded by a number of optional arguments which modify the behaviour of the script.
If the <module> passed is either a CPAN module name or a URL the script automatically does a download (when CPAN module names are specified, the latest distribution is used), putting it in the SOURCES directory. If <module> is given as a local filename, the tarball gets copied to the SOURCES directory. NOTE: at present the script will not handle .bz2 tarballs.
The spec file generated will generally assume header values as configured in the RPM macro files which are evaluated in the following order: /usr/lib/rpm/macros, /etc/rpm/macros and ~/.rpmmacros. Most of these headers can, however, be overridden through options. Whenever a header is neither configured in the RPM macro files nor is passed at the command line, the script will seek to calculate a proper value and supplies a default as stated for each option below. It is thus typicall sufficient to provide only the <module> name.
The options
available are as follows:
- --pkgname=
string-value
-
The RPM package name. This is the
Name
header in the RPM's spec file. Please note that the stringperl-
will be prepended to any value passed here. If no value is supplied, the script will use the NAME field found in the module's Makefile.PL - --version=
float-value
-
The script determines the version number of the module by parsing the tarball name.
- --release=
integer-value
-
The package release number. Defaults to 1.
- --summary=
string-value
-
A one-line description of the package. If left unspecified the script will use the module name, appending an abstract whenever available.
- --description=
string-value
-
This text describes the package/module. This value is picked up from the POD's Synopsis section in the module. Defaults to "None.".
- --url=
string-value
-
The home url for the package. Defaults to http://www.cpan.org.
- --group=
string-value
-
This is the RPM group. For further information on available groups please see your RPM documentation. Defaults to
Applications/CPAN
. -
This is the name and address of the person who authored the module. Typically it should be in the format: Name <e-mail-address>. If left unspecified, the script will attempt to extract it from the tarball's MakeMaker file, failing to build the package otherwise. There is no default for this option.
- --packager=
string-value
-
This is you (if you're packaging someone else's module). The string should be in the same format as for --author and defaults to:
Arix International <cpan2rpm@arix.com>
unless the RPM macro files provide a value. - --license=
string-value
-
The license header specified in the spec file. This field is also sometimes referred to as Copyright, but License is a more suitable name and has become more common. Defaults to
Artistic
, Perl's own license. - --distribution=
string-value
-
The script will use the %{distribution} tag defined in the RPM macros file. If this tag is not set, the script will attempt to determine the distribution name by looking at the /etc/issue file. If this file does not exist, the distribution will be left blank.
- --buildarch=
string-value
-
Allows specification of an architecture for building the RPM. Currently defaults to
i386
. - --buildroot=
string-value
-
Allows specifying a directory to use as a BuildRoot. Don't mess with this is you don't know what it is. Defaults to:
%{_tmppath}/%{name}-%{version}
. - --provides=
string-value
-
Indicates that a package should be provided by the module being built. RPM will generate an appropriate list of provided dependencies and any passed here will be in addition to those calculated.
- --requires=
string-value
-
Indicates packages that should be required for installation. This option works precisely as --requires above.
- --no-requires=
string-value
-
Suppresses generation of a given required dependency. Sometimes authors create dependencies on modules the packager can't find, sometimes RPM generates spurious dependencies. This option allows the packager to arbitrarily supress a given requirement. The value may be a comma-separated list.
- --spec-only
-
This option instructs the script to not build the RPM package but instead to oly display the generated spec file on stdout.
- --make-maker=
string-value
-
This option allows passing a string to the MakeMaker process (i.e. perl Makefile.PL <your-arguments-here>)
- --nopkgprfx
-
Suppresses prefixing the package name with the string
perl-
. - --force
-
By default the script will do as little work as possible i.e. if it has alreaddy previously retrieved a module from CPAN, it will not retrieve it again. If it has already generated a spec file it will not generate it again. This option allows the packager to force all actions, starting from scratch.
- --debug[=n]
-
This option produces debugging output. An optional integer increases the level of verbosity for this output. If no integer is given, 1 is assumed.
- --help, -h
-
Displays a terse syntax message.
NOTES
This script requires that RPM be installed. Both rpm and rpm-build must be installed on the local machine. Please see the RPM documentation (man rpm) for further information.
Additionally, the Perl module will be needed :) and the CPAN module (which is bundled with the Perl distribution) will need to be configured. For further information please refer to the CPAN manpage.
TODO
I'm happy to work on any feature requests you may have :)
BUGS
Same goes for bugs.
AUTHOR & LICENSE
Written by Erick Calder <perl@arix.com>. This utility is free and distributed under GPL, the Gnu Public License.
The script was inspired by cpanflute which is distributed with the rpm-build package from RedHat. Many thanks to Robert Brown <bbb@cpan.org> for all his cool tricks, advice and patient support.
AVAILABILITY
The latest version may always be found at:
http://perl.arix.com/
CHANGES
$Log: cpan2rpm,v $ Revision 1.49 2002/06/03 14:17:11 bbb Add username to buildroot to avoid multi-user machine conflicts.
Revision 1.48 2002/06/01 01:07:38 ekkis minor POD change
Revision 1.47 2002/06/01 01:04:24 ekkis - now uses the POD's Synopsis section for the RPM Description tag. This is the way it should be since POD Descriptions typically contain large amounts of text. - Rewrote Synopsis and Description sections of the POD
Revision 1.46 2002/05/31 23:59:33 ekkis - changed shebang line to make MakeMaker happy (thx Hook BOT)
Revision 1.45 2002/05/31 23:35:40 ekkis - redesigned the %files section (at the suggestion of Eric Kolve [ekolve@corp.classmates.com]) to fix problems with modules that contain XS e.g. DBI - added a smart %doc section which picks up documentation from the tarball (with help from Hook-BOT (Bob Brown <bbb@cpan.org>) for file regexp) - now uses %{_prefix} to list files which is better than /usr since it allows redefinition e.g. _prefix=/usr/local (Hook-BOT) - trimmed descriptions and reformatted ad banner - improved %clean section with code that wipes the extracted source tree structure after building (which can bloat disk badly when doing a lot of rpms) - thx Hook-BOT! - fixed --spec-only (thx Eric Kolve)
Revision 1.44 2002/05/29 16:32:10 bbb ~/.rpmmacros
Revision 1.43 2002/05/28 23:32:29 ekkis changed e-mail addresses
Revision 1.42 2002/05/28 23:13:28 bbb Same as second round "1.3" but in the right place now.
Revision 1.5 2002/05/23 02:55:37 ekkis adding "use strict" forces Makefile.PL to be eval()uated that way so had to add "no strict" to eval string. Also added warning in case eval fails.
Revision 1.4 2002/05/23 02:43:43 ekkis added use strict
Revision 1.3 2002/05/23 02:14:04 ekkis oops, small patch
Revision 1.2 2002/05/23 02:13:07 ekkis added --nopkgprfx in case we want to build RPMs without a prepended "perl-" (as in the case of cpan2rpm<g>)
Revision 1.1 2002/05/22 23:47:59 ekkis Moved from dist to .
Revision 1.40 2002/05/22 23:03:35 ekkis since we're no longer including the package version number in the spec filename when building multiple versions of the same package we're force to --force. this makes no sense to the script will now _always_ build the spec file
Revision 1.39 2002/05/19 01:04:44 ekkis still haveing problem with DBI - couldn't figure out how to eval() Makefile.PL so assuming pkgname from module (or passed)
Revision 1.38 2002/05/18 22:55:00 ekkis - patched to allow calls like "use ExtUtils::MakeMaker qw(WriteMakefile)"... note this currently only works with () and will fail with qw//. Due to DBI calls. - also changed MyExit() to die() instead since we really do need for the script to exit but without exiting us! - patched to allow for calls like ExtUtils::MakeMaker::WriteMakefile() as found in DBD::mysql
Revision 1.37 2002/05/07 04:21:49 ekkis added --make-maker parameter
Revision 1.36 2002/04/23 00:29:24 ekkis - implemented protection of my variables from Makefile.PL being eval()d by surrounding that code with a package. Considered the Safe module but decided against another dependency.
Revision 1.35 2002/04/22 23:19:13 ekkis --provides and --requires weren't working
Revision 1.34 2002/04/18 08:32:53 ekkis - put back code to generate name/e-mail addr of packager (uses hostname()) - added END {} code to make sure we clean up. $SIG{__DIE__} works only for die() calls - now picks up AUTHOR from tarball POD when possible - modified version parsing code to allow versions with alpha - redesigned tarls(). now context sensitive, much better way to determine embedded directory - writefile() now checks for existence
Revision 1.33 2002/04/17 08:52:43 ekkis - some bug fixes - {force} implementation for get_url()
Revision 1.32 2002/04/17 08:40:50 ekkis - added --no-requires, --find-provides, --find-requires and --install options - now can receive a URL to download from - reimplemented MyExit for eval()ing Makefile.PL - enhancements to writefile()
Revision 1.31 2002/04/16 04:06:53 ekkis ripped out all dependency (provides,requires) generation code as the newer rpm-buid generates this correctly
Revision 1.30 2002/04/12 17:22:35 ekkis - filelist is now abstracted - cool new method for extracting CVS version without breaking emacs - new regexp for splitting path/filename from given $info{module}
Revision 1.29 2002/04/09 23:00:16 ekkis took out %define version and release as it causes recursive behaviour
Revision 1.28 2002/04/09 22:20:41 ekkis - better relative path handling - now prepends url to Source: field when available via CPAN - BuildRoot more automated now
Revision 1.27 2002/04/09 08:25:00 ekkis - now requires version 0.59 or greater of CPAN as previous versions are problema tic - implemented use of RPM macros to figure outdirectory structures. script now p arses the various macro definition files and does recursive expansions to figure out correct values... see docs. - added support for a full-path tarball specification. this allows the user to call cpan2rpm with any tarball anywhere. The tarball will be copied to SOURCES. - defined %version, %release - added Rob Brown's perlver %defines - BuildRoot now defaults to the standard %{_tmpdir} - removed version number from spec filename - now scans only usr/lib in tmpdir for modules (should give better Provides headers since we don't pick up .pm files in other directories like examples/) - added code to figure out real module dependencies (PREREQ_PM is unreliable) - now attempts to read VERSION_FROM if neither ABSTRACT nor ABSTRACT_FROM is provided. failing that it will take the module name (minus any parent info, plus appropriate extension e.g. Ping.pm from Net::Ping), and if that file exists will scan it for POD
Revision 1.26 2002/04/08 22:30:35 ekkis now requires CPAN version 0.59 as previous versions seem broken added to TODO list
Revision 1.25 2002/04/07 09:18:19 ekkis hijacked exit() for the Makefile.PL eval since certain modules exit on us (not very exciting) e.g. POE
Revision 1.24 2002/04/07 02:31:00 ekkis fixed generation of dependencies on Perl core modules (not allowed)
Revision 1.23 2002/04/07 01:15:33 ekkis removed dashed lines from CHANGES section... don't konw thy CVS does use this in keyword expansion!
Revision 1.22 2002/04/07 01:12:24 ekkis added old Log info
Revision 1.21 2002/04/07 01:09:01 ekkis tarball maker now calls system() instead of qx// so user can see prompts added CHANGES section
revision 1.20 date: 2002/04/07 00:06:20; author: ekkis; state: Exp; lines: +4 -1 added back author info retrieval from CPAN when possible
revision 1.19 date: 2002/04/06 23:45:25; author: ekkis; state: Exp; lines: +4 -2 added availability section to pod
revision 1.18 date: 2002/04/06 23:43:00; author: ekkis; state: Exp; lines: +6 -8 changed default for license to "Artistic" as most modules are released under Perl's own license.
revision 1.17 date: 2002/04/06 23:13:31; author: ekkis; state: Exp; lines: +2 -2 removed spaces before =head1 NAME - he cares!!
revision 1.16 date: 2002/04/06 23:03:28; author: ekkis; state: Exp; lines: +2 -2 a fix for a fix
revision 1.15 date: 2002/04/06 22:51:36; author: ekkis; state: Exp; lines: +2 -2 fixed docs
revision 1.14 date: 2002/04/06 22:47:40; author: ekkis; state: Exp; lines: +33 -19 added --debug added -n in calls to silence questions from Makefile.PL (may not always work) now makes sure /tmp/cpan2rpm exists, creates as needed
revision 1.13 date: 2002/04/06 02:34:15; author: ekkis; state: Exp; lines: +18 -1 status info
revision 1.12 date: 2002/04/06 01:57:31; author: ekkis; state: Exp; lines: +8 -5 enhancement for f2mod() to generate RPM dependencies
revision 1.11 date: 2002/04/06 01:51:22; author: ekkis; state: Exp; lines: +71 -68 various fixes incorporated provides() into get_meta() correctly generates Provides header
revision 1.10 date: 2002/04/06 00:01:15; author: ekkis; state: Exp; lines: +55 -22 added f2mod() enhancements to untar() now generates Provides headers
revision 1.9 date: 2002/04/05 22:37:05; author: ekkis; state: Exp; lines: +167 -102 major code reorg now uses ExtUtils::Installed for platform independent module listings added --provides and --spec-only
revision 1.8 date: 2002/04/05 05:29:57; author: ekkis; state: Exp; lines: +2 -2 fixed regexp for tardir
revision 1.7 date: 2002/04/05 02:07:25; author: ekkis; state: Exp; lines: +33 -20 now eval()s Makefile.PL instead of parsing it also looks up DESCRIPTION from module file for spec file
revision 1.6 date: 2002/04/04 03:55:27; author: ekkis; state: Exp; lines: +2 -2 fixed embedded >s in tags
revision 1.5 date: 2002/04/04 03:47:34; author: ekkis; state: Exp; lines: +15 -5 added author support
revision 1.4 date: 2002/04/04 02:20:32; author: ekkis; state: Exp; lines: +105 -83 general cleanup now excepts core Perl modules from RPM dependencies now supports ABSTRACT_FROM improved PREREQ_PM handling (with Provides: clause)
revision 1.3 date: 2002/04/03 12:33:14; author: ekkis; state: Exp; lines: +38 -18 various bug fixes
revision 1.2 date: 2002/04/03 11:08:32; author: ekkis; state: Exp; lines: +144 -142 now retrieves metadata from tarball
revision 1.1 date: 2002/04/03 10:57:00; author: ekkis; state: Exp; branches: 1.1.1; Initial revision
revision 1.1.1.1 date: 2002/04/03 10:57:00; author: ekkis; state: Exp; lines: +0 -0 Initial import