Archive for December, 2009
T’info about Dash
Thursday, December 24th, 2009Once upon a time there was the Bourne command shell. sh as it is known is core at the heart of any UNIXy type operating system and others too. However for some it didn’t do enough so the Bourne Again shell, bash, was written and nearly every system ships with that. These shells are not the same. The have similar syntax but do not behave similarly.
There are other shells which have a completely different syntax and other scripting languages such as Perl and PHP so when writing a shell script you can indicate the correct interpreter using the ‘hash bang bin bash’ comment to indicate you are using bash. I.e.
#!/bin/bash
Some lazy programmers don’t indicate the exact shell they require and use
#!/bin/sh
to mean bash when it means sh.
Ubuntu, in their wisdom, have decided to go for dash as their shell. It is an evolution of the Almquist shell and is smaller and lighter weight than bash however they install bash anyway. dash and bash have the common subset of sh commands but are different. So if you find you have a problem building or similar on Ubuntu it may be that the wrong shell is being used. Ubuntu has a symlink as follows:
lrwxrwxrwx 1 root root 4 Mar 29 2009 sh -> dash
You may need to change this to point to dash as follows:
$ cd /bin $ sudo rm sh $ sudo ln -s bash sh
While we’re handling Ubuntu oddities building against NCurses, the terminal output library, can also be problematical. A little while ago NCurses was split in to two libraries, libncurses.so and libtinfo.so. Some badly written software will try and link explicitly with libtinfo.so directly rather than trying libncurses.so first. Ubuntu does not split these two libraries but provides just the one libncurses.so library so if you have an issue with a missing libtinfo.so you will need to add symlinks in to your library directory as follows:
$ cd /usr/lib $ ln -s libncurses.so.5 libtinfo.so.5 $ ln -s libtinfo.so.5 libtinfo.so
iPhone cosy
Tuesday, December 1st, 2009A short while ago I went down with the ‘flu’. Usually in these cases the best thing for me to do is rest and sleep. But eventually I get bored so I have to find something to do. So this time I sat in a recliner, watching a movie, whilst teaching myself to Purl. I wanted a project I could finish in an evening to use my new found skill so I modified the “Cricket’s Cell Phone Cozy” design and learnt to do stockinette stitch and add and remove stitches in rows. Below is the result.
It has a couple of things I could improve on. I put the cutout for the headphone cable on the wrong side and you have to take it out to charge. The next one will have a button hole type slot in the bottom for the charging cable.
Knowing Purl has meant I can do ribbing so I’ve started knitting a ribbed scarf out of some great multicolour yarn.
Building PHP C extensions on Ubuntu 9.10
Tuesday, December 1st, 2009I have just taken over maintenance of the PECL Direct IO extension as it has been unmaintained for a while. Naturally the first thing I did before writing any new code was to check out the extension from SVN and try and build it. Building the source was fine but when I tried make test it failed producing output like the following:
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/gd.so' - modules/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library 'modules/gd.so' - modules/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
The default PHP package on Ubuntu 9.10 is fairly minimalist. Most extensions are provided as separate packages which include an INI file and a dynamic library. The dynamic library is stored in:
/usr/lib/php5/20060613+lfs
And the INI file for each extension is in:
/etc/php5/conf.d.
The make tests rule in the generated Makefile in the extension you are compiling modifies the path that PHP searches for extensions by to point to the modules directory within the extension source. So PHP, which is used to run the tests, cannot find the extensions.
I’ve found the easiest way (if slightly hacky) to fix the make test failure is just to copy the .so files from the PHP5 extension directory in to the modules directory within the extension source.







