iovation / rpmcpan

Create Modern Perl and CPAN RPMs
10 stars 3 forks source link

Modern Perl RPM Packager

This project manages the creation and maintenance of modern Perl 5 RPMs, and selected CPAN distributions. It's designed to be run directly from a Git clone. To build it, just run:

./bin/rpmcpan --version 5.20.1

This will build Perl and all of the modules. If it has been built previously from the same Git branch, then only updated CPAN modules or modules for which no RPM exists in the repo directory will be built. This is to keep the number of things that get built on each run to a minimum.

The RPMs built by rpmcpan will have names like perl520 and perl520-Try-Tiny and will all be installed in /usr/local/perl520. You can modify the version of Perl to build with the --version option, and the prefix with the --prefix options, e.g.:

./bin/rpmcpan --version 5.18.2 --prefix /opt/local/iovperl

But you probably won't want to mess with the prefix.

If you want to rebuild all of the RPMs, not just those that have been updated since the last run, pass --all.

./bin/rpmcpan --version 5.20.1 --all

Options

Adding CPAN Distributions

To add a CPAN distribution, simply add it to the etc/dists.json file, like so:

"App-Sqitch": {},

The JSON object after the distribution name supports a number of keys:

rpmcpan will use this information to download the required distributions, determine their dependencies, create RPM spec files in the SPECS directory, and build RPMs for all the distributions and their CPAN dependencies. Most of the time none of the object keys will be required.

Customizing Builds

In some cases, the installation will be more complicated than the generated RPM spec file can handle. In those cases, you can create a custom spec file named for the distribution in the etc directory. rpmcpan will use such included spec files in preference to generating one of its own. You can use any of the following macros in the spec file to customize the build:

When creating the spec file header section, these three values are recommended, assuming a spec file named My-Distribution.spec:

Name:           perl%{plv}-My-Distribution
Version:        %(echo %{version})
Release:        1.%{?dist}

Dependencies on other CPAN modules should use a perl%{plv} prefix, like so:

Requires:       perl%{plv}(App::Info)

CPAN Build dependencies should require RPMs rather than provided modules, again with the perl%{plv} prefix:

BuildRequires   perl%{plv}-DBD-Pg

Auto-generation of required and provided details should be filtered through the included bin/filter-requires and bin/filter-provides scripts, to ensure that all are properly prefixed, like so:

%define _use_internal_dependency_generator 0
%define __find_provides bin/filter-provides perl%{plv}
%define __find_requires bin/filter-requires perl%{plv}

Note that __find_requires can take an additional argument, a regular expression to be passed to grep to filter out any bogusly-detected prerequisites.

The build should generally use the vendor installation directories. A Makefile.PL-based build does it like this:

%{__perl} Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS"

While a Build.PL-based build does this:

%{__perl} Build.PL --installdirs=vendor --optimize="$RPM_OPT_FLAGS"

The simplest way to set up the %files section is to just require the whole prefix:

%files
%defattr(-,root,root,-)
%{_prefix}/*

But you can also use the %_bindir, %perl_vendorlib, %perl_vendorarch, and %vendormandir macros. If you did not do a vendor build (shame on you!), you can use the site versions of those macros, instead.

Copyright & License

Copyright 2014-2019 iovation, Inc.. Some Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Author