Archive for March, 2010

Package your own Perl for CentOS (or RHEL) as RPM

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   A-Tags: ,
  • Comments Off on Package your own Perl for CentOS (or RHEL) as RPM

Build your own (faster) perl

March 27th, 2010

Using the perl that comes with your distribution is usually fine, but it has some limitations. When building a perl for a distribution it needs to be versatile and fit various needs. Therefor ithreads, the perl specific threading implemenation, is enabled there, to allow building modules that require threads to be available.

The downside is, that this threading code adds some quite low-level overhead, which usually means that a perl compiled with threads takes a performance hit of up to about 10%. So it sometimes makes sense to build your own perl, especially if you know it’s going to be used more on the server side, for long-running processes. Saving 10% in CPU cycles means potential for 10% in power saving or giving other processes a chance to run.

Building perl is really straightforward and usually just takes these steps:

  • Download the latest stable Perl from perl.org
  • Unpack it to a temporary directory
  • sh Configure -de -Dprefix=/opt/perl5
  • make && make test && make install
  • Perl is now installed in /opt/perl5

Now you can add any additional modules that you like, some recommended ones are:

  • App::cpanminus
  • Task::Kensho
  • Task::Plack
  • Task::KiokuDB
  • Mojolicious
  • Starman
  • Starlet
  • EV
  • AnyEvent
  • AnyEvent::MP
  • DBIx::Class
  • MongoDB
  • Data::FormValidator

Using the newly built perl just requires to update your path before starting your perl programs:

  • export PATH=/opt/perl5/bin:$PATH
  • /usr/local/bin/myperlprog

After setting the PATH just verify with perl -v that your perl include path points to /opt/perl5 (or any other path you chose).

Resolving LVM: Unrecognised LVM device type 259

March 20th, 2010

Trying to create a md raid1 device for 2 phyiscal 1TB disks failed unexpectedly with a strange (and very undescriptive error, that is only revealed when running with the verbose option (-vvv):

Wiping internal VG cache
/dev/md0p2: Skipping: Unrecognised LVM device type 259
Device /dev/md0p2 not found (or ignored by filtering).

The problem seems to be that the type 259 is simply not recognized, although it is defined in /proc/devices and known as blkext there.
So adding this to /etc/lvm/lvm.conf in the devices section:

types = [ "blkext", 64 ]

After adding this the mdadm command to create the md device succeeds:

mdadm --create /dev/md0 --level=1 --raid-disks=2 /dev/sda /dev/sdb

primary