LinuxCommandLibrary

cpan2dist

Create a distribution from CPAN modules

SYNOPSIS

cpan2dist [options] <module_name | directory_path>

PARAMETERS

-t, --type
    Specify the desired distribution type (e.g., rpm, deb, tgz, native).

-v, --verbose
    Enable verbose output to show detailed information during the build process.

-f, --force
    Force operations, such as rebuilding modules even if they appear up-to-date.

--test
    Run the module's test suite before proceeding with the distribution build.

--install
    Attempt to install the generated distribution package immediately after creation.

--builddir
    Define a custom directory for temporary build files and intermediate outputs.

--no-deps
    Prevent cpan2dist from resolving or installing module dependencies.

--mirror
    Specify a particular CPAN mirror URL to fetch modules from.

--sudo
    Use sudo for commands requiring elevated privileges during build or installation.

--perl
    Specify an alternative Perl executable to be used for the build process.

--help
    Display a brief help message and exit.

DESCRIPTION

cpan2dist is a powerful command-line utility designed to simplify the packaging of Perl modules from CPAN into system-native distribution formats. It acts as an essential bridge between the vast Perl module ecosystem and your operating system's package management system (e.g., RPM for Red Hat-based systems, DEB for Debian-based systems).

The command automates the entire process: it resolves and fetches module dependencies, downloads the specified CPAN module, configures it using standard Perl build tools (like ExtUtils::MakeMaker or Module::Build), and finally compiles and packages it into the chosen distribution format. This allows system administrators and developers to deploy Perl modules consistently and manage them alongside other system software, simplifying updates and ensuring environmental stability.

Beyond simply creating packages, cpan2dist can also test modules before packaging and even attempt to install the resulting distribution directly, providing a comprehensive solution for Perl module deployment.

CAVEATS

cpan2dist relies heavily on the presence and correct configuration of underlying system packaging tools (e.g., rpmbuild for RPMs, dpkg-buildpackage for DEBs). These tools must be installed on your system for cpan2dist to function for their respective package types. Some Perl modules with complex external (non-Perl) dependencies or non-standard build processes might not package correctly. Root privileges may be required for installing the generated packages or for certain build steps.

SUPPORTED DISTRIBUTION TYPES

cpan2dist supports a variety of output formats, specified using the --type option:
rpm: Creates a Red Hat Package Manager (.rpm) file, widely used on RHEL, CentOS, Fedora.
deb: Generates a Debian package (.deb) file, standard for Debian, Ubuntu, and derivatives.
tgz: Produces a compressed tarball (.tar.gz), a common generic archive format.
native: Performs a direct make install without creating a separate package file, installing the module directly into the Perl installation prefix.

CONFIGURATION AND INTEGRATION

cpan2dist leverages the robust configuration system of CPANPLUS. Users can customize various aspects of module fetching, building, and installation through the CPANPLUS shell or its configuration files, ensuring that cpan2dist operates according to specific project or system requirements, including preferred CPAN mirrors and build toolchain options.

HISTORY

cpan2dist is an integral part of the CPANPLUS project, which was developed as a more modern, extensible, and user-friendly alternative to the traditional CPAN.pm shell. Its inception addressed the growing need for better integration between Perl's vast module ecosystem and standard operating system package management tools. The core packaging logic is provided by the CPANPLUS::Dist::Build module, allowing cpan2dist to adapt to various distribution formats and streamline the deployment of Perl applications in controlled environments.

SEE ALSO

cpan(1), cpanp(1), perl(1), rpmbuild(8), dpkg-buildpackage(1)

Copied to clipboard