in reply to Install perl packages using yum

If your OS package manager doesn't have the modules/versions you need install them via cpan, or manually:

cpan Search-Elasticsearch

Manually (download, extract etc):

perl Makefile.PL make make test make install

Replies are listed 'Best First'.
Re^2: Install perl packages using yum
by mrdvt92 (Acolyte) on Apr 08, 2020 at 14:26 UTC

    I know this is an old post but this information is not readily available.

    On a packaged managed system like CentOS, please do not use cpan to install packages. It is not an enterprise solution since most companies will not let you install software from the Internet for production systems and you will just have to figure out some other way to package your software anyway. The correct method is to build your own RPMs with `cpanspec`.

    $ wget https://cpan.metacpan.org/authors/id/J/JM/JMCNAMARA/Excel-Write +r-XLSX-1.03.tar.gz $ cpanspec -b Excel-Writer-XLSX-1.03.tar.gz

    Unfortunately, for Excel-Writer-XLSX, cpanspec did not pick up the installed man page and script in /usr/bin.

    > error: Installed (but unpackaged) file(s) found: > /usr/bin/extract_vba > /usr/share/man/man1/extract_vba.1.gz

    So, I had to manually add those paths to the SPEC %files section and try again.

    %files %{_mandir}/man1/* %{_bindir}/*

    Then rebuild it

    $ rpmbuild -ba perl-Excel-Writer-XLSX.spec --define "_sourcedir $PWD"

    At this point you now have an RPM that you could put on your yum repository and it will be available for all of your systems.

    > Wrote: ~/rpmbuild/SRPMS/perl-Excel-Writer-XLSX-1.03-1.el7.stopllc.sr +c.rpm > Wrote: ~/rpmbuild/RPMS/noarch/perl-Excel-Writer-XLSX-1.03-1.el7.stop +llc.noarch.rpm
    Or install it with yum from the command line
    sudo yum install ~/rpmbuild/RPMS/noarch/perl-Excel-Writer-XLSX-1.03- +1.el7.stopllc.noarch.rpm #only command that needs root permissions

    Bonus points

    Sign your rpms

    rpm --addsign ~/rpmbuild/RPMS/noarch/perl-Excel-Writer-XLSX-1.03-1.e +l7.stopllc.noarch.rpm

    Build your own yumrepo with createrepo. If your path is /var/www/html/yumrepo then your yumrepo will be at http://127.0.0.1/yumrepo/ requires `yum install httpd`

    sudo mkdir -p /var/www/html/yumrepo/ #only first time sudo mv ~/rpmbuild/RPMS/noarch/perl-Excel-Writer-XLSX-1.03-1.el7.sto +pllc.noarch.rpm /var/www/html/yumrepo/ sudo createrepo /var/www/html/yumrepo # new or deleting rpm +s sudo createrepo --update /var/www/html/yumrepo # if only adding rpms

    Configure your yum repo on the client systems (change 127.0.0.1 to your host name)

    /etc/yum.repos.d/my.repo [my-repo] name=My Repo baseurl=http://127.0.0.1/yumrepo/ enabled=1 gpgcheck=0

    Clean up your older rpm repo versions with repomanage

    repomanage --keep=2 --old /var/www/html/yumrepo | xargs -P4 -I'{}' / +bin/rm '{}` # delete versions older than the last two versions createrepo /var/www/html/yumrepo + # rebuild the yum index

      I tend to avoid using the OS perl whenever possible. When dealing with the system perl, the OS package manager should use used.

      "It is not an enterprise solution since most companies will not let you install software from the Internet for production systems and you will just have to figure out some other way to package your software anyway."

      This depends upon your environment. We have no direct internet connections. A cpan mirror (crated using minicpan on a system which does have interwebs access) allows us to build what we need before deploying fleet wide.

      $ wget https://cpan.metacpan.org/authors/id/J/JM/JMCNAMARA/Excel-Write +r-XLSX-1.03.tar.gz $ cpanspec -b Excel-Writer-XLSX-1.03.tar.gz

      Here you are still just downloading software from the internet, repackaging it and later deploying it, albeit with the OS package manager, Archive::Zip isn't core so I think you'd have to use cpanspec --follow to ensure you satisfy dependencies:

      "If you are feeling really lucky (or maybe crazy), you can also have cpanspec build a binary rpm by passing the -b (or --build) option. As of version 1.66, you can also use --follow to have cpanspec fetch any build dependencies that aren't already available."

      https://fedoraproject.org/wiki/Perl/cpanspec.