Revert to PHP 5.2 in Ubuntu 10.04 (Lucid Lynx)

Despite suppressing updates of my LAMP stack, the upgrade to Ubuntu 10.04 ignored that, and as such I now have PHP 5.3.X installed.  Ordinarilly this woud be fine, but one of the open source web applications I work with doesn’t play well with PHP 5.3.X.  I needed a simple way to revert to a previous 5.2.X version of PHP.  The version in the Ubuntu 9.10 (Karmic) repositories would do the trick, so it was jsut a case of forcing Ubuntu to honour the 9.10 versions of various PHP packages over the 10.04 versions.

First, we get a list of all the currently installed PHP packages:

sudo dpkg -l | grep php > /tmp/php.packages

Next we remove the currently installed PHP packages:

sudo apt-get remove --purge $(dpkg -l | grep php)

Now we need to create an alternative sources list:

sed s/lucid/karmic/g /etc/apt/sources.list |\
sudo tee /etc/apt/sources.list.d/karmic.list

Having done that, we need to generate an aptitude preferences file for PHP:

awk '{print "Package: " $0; print "Pin: release a=karmic\nPin-Priority: 991\n"}' /tmp/php.packages |\
sudo tee /etc/apt/preferences.d/php

This preferences file tells aptitude that for each listed package, we want to pin down the installation candidate to that from the Karmic repositories. We can now install the packages that we previously removed, but this time the versions from the Karmic repositories:

sudo apt-get update && apt-get install $(cat /tmp/php.packages | tr "\n" " ")

A quick restart of Apache and everything seems to be working with the older version of PHP!

Continue in Interactive Bash Loop

Came across a useful keyboard shortcut to continue to the next iteration of an interactive bash for loop.  Let’s say you have something like:

for i in $(cat server_list.txt); do
   ssh -q $i hostname
done

If one of the servers is unresponsive, you can continue to the next iteration with

ctrl + \

Ubuntu 8.10 Intrepid Ibex

Having upgraded my Hardy distribution to Intrepd, I can say that I’m impressed.  The changes to the desktop, although subtle, are very much welcome.  I haven’t had any teething troubles with any of my hardware; the only ‘glitch’ I’ve noticed involves the title bars of open applications, it goes transparent now and then – but I’m sure I can put up with it until it gets fixed.  Good work Ubuntu!

Find Excluding SVN

So, you need to take a copy of a subversion working copy, but it has local changes that you also need to copy.  This precludes the use of `svn export` since the local changes won’t be included.  One option is to do an `svn export` anyway, and then `cp -ra` the local changes.  Another solution is to use a find command that excludes subversion metadata, and then copy the resulting files:

`find . -path ‘*/.svn’ -prune -o -type f -print`

I did something similar some time ago, but forgot the command, so here it is for posterity.

Playing With Perl Sockets

At work, I have a Snom 360 IP phone that is hooked up to our internal Asterisk PBX.  If I’m listening to music with my headphones in, I’m not always aware that my phone is ringing – some Perl and PHP hacking later, I’ve got a crude (and work-in-progress) solution.

Continue reading