Erick Calder > cpan2rpm > cpan2rpm

Download:
cpan2rpm-2.028.tar.gz

Annotate this POD

CPAN RT

New  7
Open  5
View/Report Bugs
Source   Latest Release: cpan2rpm-2.028_02

NAME ^

cpan2rpm - A Perl module packager

SYNOPSIS ^

To download the tarball from CPAN and create an RPM package, its source package and the specfile:

    cpan2rpm Proc::Daemon /tmp/String-Canonical-1.2.tar.gz

To install from a URL:

    cpan2rpm -i http://.../Proc-Daemon-0.03.tar.gz

To make a package out of the current directory (that contains a module):

    cpan2rpm .

To create a list of packages stored in a file:

    cpan2rpm -f module-list

DESCRIPTION ^

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, directories, urls and CPAN module names. Install this package if you want to create RPMs out of Perl modules.

The syntax for cpan2rpm supports multiple distribution names, which can take one of four different forms:

1. a CPAN module name (e.g. XML::Simple) - When a module name is passed, the script will "walk" search.cpan.org to determine the latest distribution. If an exact match is not found, the CPAN module is used to make this determination. If you have not yet configured this module, please refer to the REQUIREMENTS section below for further instructions.
2. a URL (both http:// and ftp:// style locators will work) - In this and the above case, an automatic download of the needed tarball is performed (see notes for how). The tarball is deposited in the SOURCES directory.
3. a path to a tarball (e.g. /tmp/XML-Simple-1.05.tar.gz) - In this case, the tarball indicated gets copied to the SOURCES directory.
4. a directory path - The directory specified must contain a Makefile.PL. If the user intends to build a package from a directory (i.e. user does NOT specify --spec-only), the commands:
    perl Makefile.PL
    make
    make dist

will be performed in that directory in order to create the tarball necessary for package creation.

NOTES ^

At present the script will handle .tar.gz, .tgz, .bz2 and .zip tarballs but each of these types requires the appropriate decompression programs installed on the system.

Spec files 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 typically sufficient to provide only the distribution name.

OPTIONS ^

The distribution name may be preceded by a number of optional arguments which modify the behaviour of the script. These options are grouped into three main categories as described below. Additionally, options may be stored in a configuration file - see the CONFIGURATION FILE section below.

SPEC Options

The following options control the contents of the specification file generated. They come in four flavours as follows:

Simple Tags

These represent all tags which get inserted in the package with single values. The option may be used on the command line only once.

--name=string-value

This option corresponds to the Name tag in the spec file. As is customary with Perl RPMs, the string perl- 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

--no-prfx

Even though this script is meant to build RPM packages from CPAN modules, it may be used on a more generic basis, thus the perl- prefix in a package may be undesirable. As an example, cpan2rpm generates itself but is not called perl-cpan2rpm. This option suppresses the aforementioned prefix in the package name.

--no-depchk

At times the user may want to package a module that depends on other CPAN modules not presently installed. This is generally not possible since cpan2rpm does an up-front check for modules listed in the PREREQ_PM field of the Makefile.PL. This switch turns this checking off so that the process may continue and implies the --make-no-test since testing with missing module dependencies will certainly fail.

--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.

--version=float-value

The script determines the version number of the module by consulting the Makefile.PL's VERSION or VERSION_FROM fields. If neither is specified, it parses the tarball name. Note: If you're looking to get the version of cpan2rpm itself, see the -V option.

--release=integer-value

The package release number. Defaults to 1. Allows alphanumerics.

--epoch=integer-value

By default, this tag is not written to the spec file. Enter a value here when needed.

--author=string-value

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.

--distribution=string-value

This key overrides the %{distribution} tag as defined in the macros files. There is no default for this tag and will be left out unless specified.

--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.

--group=string-value

This is the RPM group. For further information on available groups please see your RPM documentation. Defaults to Applications/CPAN.

--url=string-value

The home url for the package. Defaults to http://www.cpan.org.

--buildarch=string-value

The architecture for a package is determined by whether the tarball includes files matching *.xs or *.c. If it does, %_arch macro from rpm is used as the target architecture, otherwise noarch is used. This value may be overridden with this parameter. Typically the package build will be found in the RPMS directory, under the indicated architecture.

--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}.

--defattr=-,root,root

Upon installation of a package created with cpan2rpm, the files installed are owned according to the contents of the %defattr tag inserted into the %files section of the spec file. The value of this tag may be passed using this switch and defaults to the value shown above.

--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..

Aggregate Tags

These represent tags which may be repeated in the spec file. With all of the following, users may either specify a single option with a comma-delimited string of values, or multiple options, each with a single value.

exempli gratia

  --requires="rpm, rpm-build"
  --requires="rpm" --requires="rpm-build"
--provides=string-value

Indicates that a package is provided by the module being built. RPM will generate an appropriate list of provide 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 --provides 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.

--buildrequires=string-value

This option indicates dependencies at build time.

--patch=string-value

Allows for specifying patch files to be inserted into the spec file and applied when building the source.

--define=name body

Works much like the rpm --define syntax to define rpm macro initializations. A comma-delimited list of macro definitions is not supported, but ut may be used multiple times to define more than one macro.

exempli gratia

  --define="suidperl 1"
  --define "usethreads 1"
  --define admindir=/var/www/html/admin
--doc=string-value

This option may be used to add values to the %doc line in the spec's %files section. By default, cpan2rpm examines the contents of a tarball, using a regular expression to pick up files it recognises as belonging to the /usr/share/doc directory. If your module contains files cpan2rpm does not recognise, they may be added with this option.

Additionally, the user may replace the calculated list by providing values prepended with an equal sign. In the following example, ONLY the Changes file is added to the list, dismissing any files found by the script:

--doc "=Changes"

Section options

These represent tags which may be repeated in the spec file. Users may specify these either with a single option and a comma-delimited string of values, or by repeating the option, each with a single value.

--prologue=<section>:<code>

This option allows the user to insert arbitrary code at the top of a given section of the spec file. The section is named in the value passed to the option as the first word followed by a colon. At present, the following sections are supported: prep, build, install, clean, changelog.

--epilogue=<section>:<code>

As with the previous option, this may be used to insert code at the end of a given section. This option also supports the tag and files sections which allow for the user to insert extra tags or files to the spec file.

exempli gratia

--epilogue="tag:epoch: 1"

Building options

The following options control the package making process.

--spec-only

This option instructs the script to only generate a spec file and not build the RPM package.

--spec=path

This option allows the user to specify the full-path of the spec file to produce. By default, the specfile is placed in the SPECS directory and is named after the module with a .spec extension. Please note that cpan2rpm will overwrite existing files, so if you care about your current spec file, save it!

--make-maker=string-value

This option allows passing a string to the MakeMaker process (i.e. perl Makefile.PL <your-arguments-here>). At present there is no support for passing parameters to Module::Build->new() - if this is either possible or desired, please mail the author.

--make=string-value

Arguments supplied here get passed directly to the make process. (As with the above, no support is offered for Module::Build).

--make-no-test

Use this option to suppress running a module's test suite during build.

--make-install=string-value

Allows user to supply arguments to the make install process. (As with the above, no support is offered for Module::Build).

--find-provides=string-value
--find-requires=string-value

These two options allow for redefining the RPM macros of the same name in the spec file.

--tempdir=string-value

Specify a temporary working directory instead of utilizing File::Temp.

--req-scan-all

By default, the rpm-build requirements script scans all files in a tarball for requirements information. As this may on occasion generate requirements on the produced rpm that belong only to sample programs or other files not critical to the module being installed, we provide a patch the user may apply (included in this distribution as perl.req.patch) which causes dependencies to be harvested from only .pm files. When this patch is installed, this switch reverses the behaviour, causing cpan2rpm to scan all files as originally intended.

--no-clean

By default, the system passes --clean to rpmbuild, thus removing the unpacked sources from the BUILD directory. This option suppresses that functionality.

--shadow-pure

Forces installation under installarchlib even if the module is pure perl. This is significant because it is first in the @INC search for module determination. This will not do any good for modules with XS code or those that are already installed into an architecture dependent path. This is most useful for those pure perl modules that come stock with the perl rpm itself (i.e. Test::Harness) but you wish to try another version without having to be forced to use "rpm --replacefiles" and destroying the old files. Using this option will allow both versions of the module to be installed, but the new version will just mask the old version later in the @INC. Additionally, the new man pages will mask the old man pages even though the man pages for both version will be installed. This option should only be used as a last resort to install a module when "conflicts" errors occur on rpm installation such as the following: file from install of perl-Module-1.11-1 conflicts with file from package perl-5.x.x User may be required to use --force (see below) in conjuction with this option to build a fresh rpm before attempting to --install again.

--force

By default the script will do as little work as possible i.e. if it has already 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.

--no-sign

Suppresses package signatures. By default, cpan2rpm will sign the packages it generates IF the the RPM macros file has been configured to use signatures - this option prevents this behaviour. See also the --sign-setup option below.

--install | -i

Install the RPM after building it. If non-root user, you must have "sudo rpm" privileges to use this option.

Miscellaneous options

The options below perform functions not closely related to the quotidien process of building a package.

--fetch=string-value

One of cpanplus, cpan or web, this parameter specifies which method to use when retrieving a module from CPAN. Web retrievals are by parsing the CPAN website and may be faster though more error prone. To use either the CPAN or CPAN+ modules, these must be installed. Default: web.

If your environment requires the use of a proxy, simply set the environment variable as indicated below in (bash format):

export HTTP_PROXY=http://user:password@host.org:8080

--modules, -f =string-value

Lists of modules to be processed can be stored in a file. Pass this parameter the name of your file. The file should contain the name of each module in a single line and the modules can be specified in any of their many forms (e.g. url, path to tarball, CPAN module name, etc.). Comments (begining with #) will be ignore and so will empty lines.

--mk-rpm-dirs=string-value

This option allows the non-root user to easily set up his account for building packages. The option requires a directory path where the RPMS, SPECS, etc. subdirectories will be created. These directories will contain the spec files, binaries and the source packages generated. Additionally the %_topdir macro will be defined in the ~/.rpmmacros file. If this file doesn't exist it will be created, if it does but does not contain a definition for this macro, it will be appended to it. Suggested value is ~/rpm but it's up to user.

Additionally, the script will create architecture directories i386, i686 and noarch and allows the user to pass --buildarch to also create a directory for that architecture.

--sign-setup=[type:user]

This option sets up your RPM macros file to support the signing of packages. The option may be passed a value consisting of the signature type to use (currently only gpg and pgp are valid but consult the RPM man pages), a colon, and the user name to sign with. If no value is passed gpg is used for the signature type and the first key listed in the secure keyring is taken for signing.

Note: unless you know what you're doing, do not pass any arguments to this option! Also, make sure not to pass a module name as an argument.

To further tailor your macros file please refer to the GPG SIGNATURES section of the RPM man page.

--upgrade

Whenever a new version of this program becomes available, an automatic notification will be issued to the user of this fact. The user may then choose to upgrade via this option. The option takes no parameters.

--no-upgrade-chk|-U

During version checks, the script will time out within 5 seconds if the arix.com server is unavailable (when working offline or if the server is down). Should the 5 seconds become annoying, users may pass this option to skip the version check.

--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.

-V

This option displays the version number of cpan2rpm itself.

-D

This option runs cpan2rpm in the Perl debugger. Useful for anyone willing to dig on my behalf.

CONFIGURATION FILE ^

In addition to reading options from the command line, cpan2rpm will slurp the configuration file ~/.cpan2rpm, if it exists. Please note that for this functionality to work, the module Getopt::ArgvFile must be installed. If the config file exists but the module is not available, cpan2rpm will puke.

Additionally, please note that if no config file exists in the $HOME directory, one may be passed explicitly on the command line as shown in the example below:

    # cpan2rpm @options-file -V

Note that options from command line will override options from config file.

The configuration file should contain options in same format as they would be used in command line. Place one option per line.

Example:

    --packager="John Doe <john.doe@example.com>"
    --url="http://example.com/johndoe/perlmodules/"

REQUIREMENTS ^

This script requires that RPM be installed. Both the rpm and rpm-build packages must be installed on the local machine. Please see the RPM documentation (man rpm) for further information.

Additionally, the Perl package will be needed :) and the CPAN module (which is bundled with the Perl distribution) will need to be configured. To configure CPAN (CPAN.pm or CPAN/MyConfig.pm) use the following:

    perl -MCPAN -e shell

For further information please refer to the CPAN manpage.

SUPPORTED PLATFORMS ^

At present, cpan2rpm has been tested and is known to work under the following environments:

Operating Systems

The script has been tested under the OS list below:

    - Linux RedHat: 6.1, 6.2, 7.0, 7.2, 7.3, 8.0, 9.0
    - Redhat Enterprise v3 (RHELv3), AS4 (Nahant)
    - SuSE 8.1, 9.0

Rumour has it it's been tested on Solaris and FreeBSD as well but I don't know for sure. See README.redhat6 for 6.x issues to be aware of.

Perl

The script is known to work with Perl versions 5.005_03, 5.6.0, 5.6.1 and 5.8.0.

ExtUtils::MakeMaker

This module is used for making and installing the CPAN modules. However many of MakeMaker's versions are broken and incompatible with other versions. For that reason, cpan2rpm works well with versions < 5.91 and > 6.05 but in between it requires an upgrade.

Module::Build

This module replaces the old and crusty MakeMaker. At present not all modules yet use this new install method so cpan2rpm autodetects the install method and supports both. Please note that some of the meta-data retrieval functions may not work as well with this module as it requires less information to be present in the initial script than does MakeMaker.

Redhat Package Manager

The RPM system has undergone a lot of change. At present, cpan2rpm runs on version 4.0.4-7x but requires certain special attention (see README for more information). Earlier versions of RPM are borked in various ways and are not currently supported, though on SuSE version 3.0.6 appears to work.

If you are running on a platform not listed above, do drop us a note and let us know!

AUTHOR ^

Erick Calder <ecalder@cpan.org>

ACKNOWLEDGEMENTS ^

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.

SUPPORT/BUGS ^

Thank you notes can be mailed directly to the author :)

For help, you can subscribe to our mailing list at:

http://lists.sourceforge.net/lists/listinfo/cpan2rpm-general

or send a message to cpan2rpm-general-request@lists.sourceforge.net with help as the subject header. Please note, when submitting patches, please first retrieve the latest (unreleased version of the script from the home page).

Feature requests, bug reports and patch submissions should also be handled through SourceForge.

TODO ^

Some things we're working on/thinking about:

1. extract all functionality into a perl module and make cpan2rpm a thin script 2. allow macro definitions like %_sourcedir %_topdir/%name in .rpmmacros file (%name isn't defined till later) 3. a --recursive option to install perl rpm dependencies 4. Provides: requirements are generated in the form "perl(POE::Filter) = 1.12" but not "perl-POE-Filter = 1.12" which is for SuSE. 5. PREREQ_PM should be added to the unique list of requirements for the RPM 6. look into --make-test-continue to move past failed testing 7. rethink --force

AVAILABILITY ^

The latest version of the tarball, RPM and SRPM may always be found at:

http://perl.arix.com/

Additionally, the module is available on CPAN at:

http://search.cpan.org/author/ECALDER/cpan2rpm/

and the project is also hosted on SourceForge at:

http://sourceforge.net/projects/cpan2rpm/

CHANGES ^

The distribution includes a Changes file which details the evolution of this utility. For your convenience, this file may also be found online at:

http://perl.arix.com/cpan2rpm/Changes

LICENCE AND COPYRIGHT ^

Copyright (c) 2002-2003 Erick Calder <ecalder@cpan.org>

This product is free and distributed under the Gnu Public License (GPL). A copy of this license was included in this distribution in a file called LICENSE. If for some reason, this file was not included, please see http://www.gnu.org/licenses/ to obtain a copy of this license.

$Id: cpan2rpm,v 2.301 2005/06/18 05:06:54 ekkis Exp $

syntax highlighting: