cpan_multi-spec - Ansible Automation to create multiple RPM .spec Files from Perl Module Names
Create Packages for a List of Perl Module Names
$ ansible-playbook -i 'localhost,' created_sources.yml --connection=local \
-e '{"module_search":["Namespace1::Module1", "Namespace2::Module2", "Namespace1::Module3"]}'
Search for Perl Module Name Suggestions for a File Name
$ ansible-playbook -i 'localhost,' created_sources.yml --connection=local \
-e 'file_search="some/missing/file.pm"'
This Ansible Automation
will search Perl Packages with the MetaCPAN API, download the Sources and build the RPM .spec Files from their Project Configurations
Create missing Packages that are required for the Installation of some Software but have not been published yet
# yum -y install perl-Moose
CentOS Linux 8 - AppStream 7.6 kB/s | 4.3 kB 00:00
CentOS Linux 8 - AppStream 6.7 MB/s | 8.2 MB 00:01
CentOS Linux 8 - BaseOS 4.3 kB/s | 3.9 kB 00:00
CentOS Linux 8 - BaseOS 2.2 MB/s | 4.5 MB 00:02
CentOS Linux 8 - Extras 1.5 kB/s | 1.5 kB 00:00
Extra Packages for Enterprise Linux Modular 8 - 12 kB/s | 37 kB 00:03
Extra Packages for Enterprise Linux Modular 8 - 457 kB/s | 798 kB 00:01
Extra Packages for Enterprise Linux 8 - x86_64 60 kB/s | 23 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 2.9 MB/s | 10 MB 00:03
Error:
Problem: conflicting requests
- nothing provides perl(Sub::Name) needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Package::Stash) needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Sub::Identify) needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Dist::CheckConflicts) needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Eval::Closure) needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Devel::StackTrace) >= 2.03 needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Dist::CheckConflicts) >= 0.02 needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Eval::Closure) >= 0.04 needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Package::DeprecationManager) >= 0.07 needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Package::DeprecationManager) >= 0.11 needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Package::Stash) >= 0.32 needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Package::Stash::XS) >= 0.24 needed by perl-Moose-2.2011-9.el8.x86_64
- nothing provides perl(Sub::Name) >= 0.20 needed by perl-Moose-2.2011-9.el8.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
The Command for this given Use Case would be: (It does not assume that Package::Stash
and Package::Stash::XS
are part of the same distribution. And actually they are not.)
$ ansible-playbook -i 'localhost,' created_sources.yml --connection=local \
-e '{"module_search":["Sub::Name", "Package::Stash", "Sub::Identify", "Dist::CheckConflicts", "Eval::Closure", "Devel::StackTrace", "Eval::Closure", "Package::DeprecationManager", "Package::Stash", "Package::Stash::XS"]}'
As a Result the Distributions that are downloaded are:
TASK [Result - Modules Found List] *****************************************************************
ok: [localhost] => {
"modules_found": {
"Devel::StackTrace": "Devel-StackTrace",
"Dist::CheckConflicts": "Dist-CheckConflicts",
"Eval::Closure": "Eval-Closure",
"Package::DeprecationManager": "Package-DeprecationManager",
"Package::Stash": "Package-Stash",
"Package::Stash::XS": "Package-Stash-XS",
"Sub::Identify": "Sub-Identify",
"Sub::Name": "Sub-Name"
}
}
Search Perl Modules by File Names: (This is useful to understand Project Dependencies in Software created by others)
$ perl -MTwiggy::Writer -e 'use Twiggy::Writer; print "Hello Twiggy\n";'
Can't locate Twiggy/Writer.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.
The Search Query for this File would be:
$ ansible-playbook -i 'localhost,' created_sources.yml --connection=local -e 'file_search="Twiggy/Writer.pm"'
Although the exact coincidence cannot be known it gives hints where to continue searching
TASK [Result - Modules Found List] *****************************************************************
ok: [localhost] => {
"modules_found": {}
}
As a Result a List of possible Modules is displayed
TASK [module-search : Map List Module Packages] ****************************************************
ok: [localhost] => (item=[u'Twiggy::TLS', u'lib/Twiggy/TLS.pm'])
ok: [localhost] => (item=[u'Twiggy::TLS::Info', u'lib/Twiggy/TLS/Info.pm'])
ok: [localhost] => (item=[u'Plack::Handler::Twiggy', u'lib/Plack/Handler/Twiggy.pm'])
ok: [localhost] => (item=[u'Twiggy::Server', u'lib/Twiggy/Server.pm'])
ok: [localhost] => (item=[u'Twiggy::Writer', u'lib/Twiggy/Server.pm'])
ok: [localhost] => (item=[u'Twiggy::Server::TLS', u'lib/Twiggy/Server/TLS.pm'])
ok: [localhost] => (item=[u'Twiggy::Prefork::Server::SS', u'lib/Twiggy/Prefork/Server/SS.pm'])
ok: [localhost] => (item=[u'Twiggy::Prefork::Metabolic::Server', u'lib/Twiggy/Prefork/Metabolic/Server.pm'])
ok: [localhost] => (item=[u'Plack::Handler::Twiggy::Prefork::Metabolic', u'lib/Plack/Handler/Twiggy/Prefork/Metabolic.pm'])
ok: [localhost] => (item=[u'Twiggy::Server::SS', u'lib/Twiggy/Server/SS.pm'])
ok: [localhost] => (item=[u'Plack::Handler::Twiggy::TLS', u'lib/Plack/Handler/Twiggy/TLS.pm'])