CPAN::P...:Sysdeps(3)
π CPAN::Plugin::Sysdeps π
okay bestie, so this is CPAN::Plugin::Sysdeps(3) β a User Contributed Perl Documentation page β and it's literally the plug for installing your system deps while CPAN does its thing. sit down, grab a strawberry π, we're getting into it.
β¨ NAME β¨
CPAN::Plugin::Sysdeps β a CPAN.pm plugin for installing system dependencies
πΈ SYNOPSIS πΈ
in the CPAN.pm shell, babes:
o conf plugin_list push CPAN::Plugin::Sysdeps
o conf commit
that's it. that's the whole vibe. π
π¦ DESCRIPTION π¦
CPAN::Plugin::Sysdeps is a plugin for CPAN.pm (version >= 2.07) that installs your non-CPAN dependencies automatically, so you don't have to go hunting through apt repos like it's 2009. currently, the list of required system dependencies lives in a static data structure inside CPAN::Plugin::Sysdeps::Mapping. the operating systems and distributions that are supported are FreeBSD and Debian-like Linux distributions. there are also some module rules for Fedora-like Linux distributions, Windows (through chocolatey), and Mac OS X (through homebrew).
you can configure the plugin like this:
o conf plugin_list CPAN::Plugin::Sysdeps=arg1,arg2,...
and the possible arguments are... π₯
"apt-get","aptitude","pkg","yum","dnf","homebrew"β force a particular installer for system packages. if you don't set one, the plugin finds a default for the current operating system or linux distribution:- Debian-like distributions:
"apt-get" - Fedora-like distributions:
"yum"or"dnf" - FreeBSD:
"pkg" - DragonFly BSD:
"pkg" - Windows:
"chocolatey" - Mac OS X:
"homebrew"
- Debian-like distributions:
additionally, sudo(8) gets prepended before the installer program if the current user is not a privileged one, and the installer requires elevated privileges. π
"batch"β don't ask any questions. no thoughts, just install. π"interactive"β be interactive, especially ask for confirmation before installing a system package."dryrun"β only log installation actions. window shopping, basically."debug"β turn debugging on. alternatively the environment variable"CPAN_PLUGIN_SYSDEPS_DEBUG"may be set to a true value."mapping=perlmod|file"β prepend another static mapping from cpan modules or distributions to system packages. this should be specified as a perl module (Foo::Bar) or an absolute file name. the mapping file is supposed to just return the mapping data structure as described below.
π MAPPING π
!This implementation is subject to change!
a mapping is a tree-like data structure expressed as nested arrays. the top-level nodes usually specify a cpan module or distribution to match, and a leaf should specify the dependent system packages.
a sample mapping may look like this:
(
[cpanmod => ['BerkeleyDB', 'DB_File'],
[os => 'freebsd',
[package => 'db48']],
[linuxdistro => '~debian',
[linuxdistrocodename => 'squeeze',
[package => 'libdb4.8-dev']],
[linuxdistrocodename => 'wheezy',
[package => 'libdb5.1-dev']],
[package => 'libdb5.3-dev']]],
);
the nodes are key-value pairs. the values may be strings, arrays of strings (meaning that any of the strings may match), or compiled regular expressions. β¨
the supported keywords are:
cpanmod => $valueβ match a CPAN module name (e.g."Foo::Bar").cpandist => $valueβ match a CPAN distribution name (e.g."Foo-Bar-1.23"). note that currently only the base_id is matched; this may change! πos => $valueβ match a operating system (perl's$^Ovalue).linuxdistro => $valueβ match a linux distribution name, as specified in the"ID"field in/etc/os-release, or returned by"lsb_release -is". the distribution name is lowercased.
there are special values "~debian" to match Debian-like distributions (Ubuntu and LinuxMint) and "~fedora" to match Fedora-like distributions (RedHat, CentOS and Rocky Linux).
linuxdistrocodename => $valueβ match a linux distribution version using its code name (e.g."jessie").
TODO: it should be possible to express comparisons with code names, e.g. '>=squeeze'.
linuxdistroversion => $valueβ match a linux distribution versions. comparisons like'>=8.0'are possible.package => $valueβ specify the dependent system packages.
for some distributions (currently: debian-like ones) it is possible to specify alternatives in the form "package1 | package2 | ...".
π PLUGIN HOOKS π
the module implements the following CPAN plugin hooks:
newpost_get
π USE CASES π
π§ͺ CPAN TESTERS π§ͺ
install system packages automatically while testing CPAN modules. if the smoke system runs under an unprivileged user, then a sudoers rule has to be added. for such a user named "cpansand" on a Debian-like system this could look like this (two rules for batch and non-batch mode):
Defaults env_keep += "DEBIAN_FRONTEND"
cpansand ALL=(ALL) NOPASSWD: /usr/bin/apt-get -y install *
cpansand ALL=(ALL) NOPASSWD: /usr/bin/apt-get install *
for batch operation, it's advisable to run the following commandline before starting the smoker:
export DEBIAN_FRONTEND=noninteractive
to avoid possible interactive configuration of some packages. (we do NOT want a surprise prompt mid-smoke, fr fr π)
π USE WITHOUT CPAN.PM π
it's possible to use this module also without CPAN.pm through the cpan-sysdeps script.
for example, just list the system prereqs for Imager on a FreeBSD system:
$ cpan-sysdeps --cpanmod Imager
freetype2
giflib-nox11
png
tiff
jpeg
on a Debian system the output will look like:
libfreetype6-dev
libgif-dev
libpng12-dev
libjpeg-dev
libtiff5-dev
just show the packages which are yet uninstalled:
$ cpan-sysdeps --cpanmod Imager --uninstalled
show what CPAN::Plugin::Sysdeps would execute if it was run:
$ cpan-sysdeps --cpanmod Imager --dryrun
and actually run and install the missing packages:
$ cpan-sysdeps --cpanmod Imager --run
ate. π₯
πΈ USE WITH CPAN_SMOKE_MODULES πΈ
"cpan_smoke_modules" is another "CPAN.pm" wrapper specially designed for CPAN Testing (to be found at <https://github.com/eserte/srezic-misc>. if "CPAN.pm" is already configured to use the plugin, then "cpan_smoke_modules" will also use this configuration. but it's also possible to use "cpan_smoke_modules" without changes to "CPAN/MyConfig.pm", and even with an uninstalled "CPAN::Plugin::Sysdeps". this is especially interesting when testing changes in the Mapping.pm file. a sample run:
cd .../path/to/CPAN-Plugin-Sysdeps
perl Makefile.PL && make all test
env PERL5OPT="-Mblib=$(pwd)" cpan_smoke_modules -perl /path/to/perl --sysdeps Imager
or alternatively without any interactive questions:
env PERL5OPT="-Mblib=$(pwd)" cpan_smoke_modules -perl /path/to/perl --sysdeps-batch Imager
π NOTES, LIMITATIONS, BUGS, TODO π
- Minimal requirements
CPAN.pm supports the plugin system since 2.07. if the CPAN.pm is older, then still the "cpan-sysdeps" script can be used.
it is assumed that some system dependencies are still installed: a "make", a suitable C compiler, maybe "sudo", "patch" (e.g. if there are distroprefs using patch files) and of course "perl". on linux systems, the file /etc/os-release is required, otherwise fallbacks using "lsb-release" and /etc/redhat-release and /etc/issue are trued.. on Mac OS X systems "homebrew" has to be installed.
- Batch mode
make sure to configure the plugin with the "batch" keyword (but read also "Conflicting packages"). in CPAN/MyConfig.pm:
'plugin_list' => [q[CPAN::Plugin::Sysdeps=batch]],
installation of system packages requires root priviliges. therefore the installer is run using sudo(8) if the executing user is not root. to avoid the need to enter a password either make sure that running the installer program ("apt-get" or so) is made password-less in the sudoers file, or run a wrapper like sudo_keeper <https://github.com/eserte/srezic-misc/blob/master/scripts/sudo_keeper>.
- Install local directories using
"cpan ."
"CPAN.pm" has limited support for installing locally available directories. a possible use case is to do a "git clone" of a module repository and install it directly from the cloned directory. however, in this scenario "CPAN::Plugin::Sysdeps" has no information about the installed software, especially not the distribution name and its contained modules, and therefore cannot apply its mapping. to work around this limitation it's possible to set the environment variable "CPAN_PLUGIN_SYSDEPS_MODULE" to the primary module of the distribution.
- Error handling
failing things in the plugin are causing die() calls. this can happen if packages cannot be installed (e.g. because of a bad network connection, the package not existing for the current os or distribution, package exists only in a "non-free" repository which needs to be added to /etc/apt/sources.list, another installer process having the exclusive lock...).
- Conflicting packages
system prerequisites specified in the mapping may conflict with already installed packages. please note that with the "batch" configuration already installed conflicting packages are actually removed, at least on Debian systems.
β οΈ bestie this one is real β batch mode will literally yeet packages that conflict. be aware. π
- Support for more OS and Linux distributions
best supported systems are FreeBSD and Debian-like systems (but details may be missing for distributions like Ubuntu or Mint). support for Fedora-like systems and Mac OS X systems is fair, for Windows quite limited and for other systems missing.
- Support for cpanm
to my knowledge there's no hook support in cpanm. maybe things will change in cpanm 2.0. but it's always possible to use the cpan-sysdeps script.
- Should gnukfreebsd be handled like debian?
maybe gnukfreebsd should be included in the "like_debian" condition?
π CREDITS π
Okay so bestie, this whole module was born at the Perl QA Hackathon 2016 (http://act.qa-hackathon.org/qa2016/), and that lil' event only happened because a lot of extremely generous sponsors said "yes, take my money, go make Perl better." π«Ά Iconic behaviour, honestly.
Shoutout time β every single one of these legends:
https://www.fastmail.comβ FastMailhttps://www.ziprecruiter.comβ ZipRecruiterhttp://www.activestate.comβ ActiveStatehttp://www.opusvl.comβ OpusVLhttps://www.strato.comβ Stratohttp://www.surevoip.co.ukβ SureVoIPhttp://www.cv-library.co.ukβ CV-Libraryhttps://www.iinteractive.com/β Infinityhttps://opensource.careers/perl-careers/β Perl Careershttps://www.mongodb.comβ MongoDBhttps://www.thinkproject.comβ thinkproject!https://www.dreamhost.com/β Dreamhosthttp://www.perl6.org/β Perl 6http://www.perl-services.de/β Perl Serviceshttps://www.evozon.com/β Evozonhttp://www.booking.comβ Bookinghttp://eligo.co.ukβ Eligohttp://www.oetiker.ch/β Oetiker+Partnerhttp://capside.com/en/β CAPSiDEhttps://www.procura.nl/β Procurahttps://constructor.io/β Constructor.iohttps://metacpan.org/author/BABFβ Robbie Bowhttps://metacpan.org/author/RSAVAGEβ Ron Savagehttps://metacpan.org/author/ITCHARLIEβ Charlie Gonzalezhttps://twitter.com/jscook2345β Justin Cook
Not a single one skipped, not a single one forgotten. The whole squad. β¨
π CONTRIBUTORS π
The girlies (gender neutral) who rolled up and made it better:
- Max Maischein (CORION) β Windows/chocolatey support π«
- David Dick (DDICK) β OpenBSD, DragonFly BSD and Fedora support π‘
π AUTHOR π
Slaven Rezic
π COPYRIGHT AND LICENSE π
Copyright (C) 2016,2017,2018,2019,2024,2025,2026 by Slaven ReziΔ
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
Basically: go forth, remix, redistribute, do your thing β just keep it under the same Perl terms, starting at Perl 5.8.8 or anything newer you've got lying around. π
π SEE ALSO π
cpan-sysdepsCPANapt-get(1)aptitude(1)pkg(8)yum(1)dnf(1)
And that's a wrap on this absolute unit of a manpage, bestie π You just read CPAN::P...:Sysdeps(3) as shipped with perl v5.42.2, dated 2026-06-29. Go forth and let it figure out your system deps so you don't have to. Slay, periodt. πβ¨π¦
π¦ where this page comes from
- fedora 43: perl-CPAN-Plugin-Sysdeps 0.84-1.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- fedora 44: perl-CPAN-Plugin-Sysdeps 0.84-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms