Package your own Perl for CentOS (or RHEL) as RPM
Random March 28th, 2010
Of course perl is easy to build and you can build your own Perl is nice, but it needs to be managed on the target host where it is deployed. As internet access to CPAN is not available everywhere (we are talking about enterprise and carrier deployments here) updates need to be managable. At least on a basic level.
Excactly this can be done by just packaging up your contents of /opt/perl5 using a quite simple RPM spec file. It’s important to use the AutoReqProv: no
flag to avoid rpmbuild thinking too much and trying to find out which modules are packaged here. On the other hand this requires, that you add certain libs that this perl depends on manually. There is a chance that you could just override %__findrequires
macro here, but that does not work for me, as setting it on the package level yielded strange errors for me.
Here is an shortened example of how this specfile perl5-custom.spec should look. Your perl is expected to be found in /opt/perl5:
Summary: Perl 5 custom install to /opt/perl5
Name: perl5-custom
Version: 5.10.1
Release: 1
Vendor: quikit.at
License: Artistic 2.0
Provides: perl5-custom
Group: Languages
BuildRoot: /tmp/%name-root
Requires: MySQL-client-community >= 5.0.18
Requires: shared-mime-info >= 0.19
Requires: libxslt >= 1.1.17
AutoReqProv: no
%changelog
* Sun Mar 28 2010 5.10.1-1
- Initial packaging of Perl 5.10.1 in /opt/perl5
- Included Modules:
Task::Moose, Task::KiokuDB, Task::Plack
EV, AnyEvent, AnyEvent::*
DateTime, Log4perl, DBI, DBIx::Class, DBD::mysql
Starman, Starlet, Tatsumaki
%description
Custom Perl 5 with server-specific modules pre-installed
%prep
%build
%install
SRCDIR=/opt/perl5
rm -rf $RPM_BUILD_ROOT
echo "Copy complete perl5 base directry to buildroot"
mkdir -p $RPM_BUILD_ROOT/$SRCDIR
cp -Rp $SRCDIR/* $RPM_BUILD_ROOT/$SRCDIR/
%clean
rm -rf $RPM_BUILD_ROOT
%pre
%post
%preun
%postun
%files
%defattr(644,root,root)
%attr(755,root,root) /opt/perl5/bin/*
/opt/perl5/lib/*
/opt/perl5/man/*
%dir %attr(755, root, root) /opt/perl5/bin
%dir %attr(755, root, root) /opt/perl5/lib
%dir %attr(755, root, root) /opt/perl5/man
Then just run rpmbuild -ba perl5-custom.spec
and you get an installable package, which can be updated over time by updating modules on your build host and repackaging it.
- Category: Bits & Bytes S-Tags: CPAN, Perl
- Comments Off on Package your own Perl for CentOS (or RHEL) as RPM