2.10. Adding Additional Software to Pyramid Linux

Pyramid doesn't come with everything you want; how can you add more software? It doesn't have any of the usual Ubuntu package management tools, nor any package management tools at all, so you're at a bit of a loss.

The process is a bit fiddly, but not that bad. You can add user-space applications, kernel modules, and even customized kernels. You need an Ubuntu liveCD and a PC to run it on. You don't need to install it to a hard drive; just boot it up on any PC, and then copy off any files you want. I know in Recipe 2.8 I said to disable root log-ins over SSH, but for this task, you need to re-enable them, because the Ubuntu liveCD does not include an SSH server.

Suppose you want to install the Fortune program. Fortune displays a random fortune every time you run it, like this:

	$ fortune
	You will gain money by a fattening action.

Fortune comes with a number of different fortune databases, and you can easily create your own custom fortunes. It's a nice way to display a different Message of the Day every time users log in.

First boot up the Ubuntu liveCD. Then, find out what packages you need with the dpkg command:

	ubuntu@ubuntu:~$ dpkg -l| grep fortune
	ii  fortune-mod 1.99.1-3   provides fortune cookies on demand
	ii  fortunes-min 1.99.1-3  Data files containing fortune cookies

Next, find out what files are in the Fortune packages:

	ubuntu@ubuntu:~$ dpkg -L fortune-mod
	/.
	/usr
	/usr/games
	/usr/games/fortune
	/usr/bin
	/usr/bin/strfile
	/usr/bin/unstr
	/usr/share
	/usr/share/man
	/usr/share/man/man6
	/usr/share/man/man6/fortune.6.gz
	/usr/share/man/man1
	/usr/share/man/man1/strfile.1.gz
	/usr/share/doc
	/usr/share/doc/fortune-mod
	/usr/share/doc/fortune-mod/README.Debian
	/usr/share/doc/fortune-mod/copyright
	/usr/share/doc/fortune-mod/changelog.gz
	/usr/share/doc/fortune-mod/README.gz
	/usr/share/doc/fortune-mod/changelog.Debian.gz
	/usr/share/menu
	/usr/share/menu/fortune-mod
	/usr/share/man/man1/unstr.1.gz

The only files you need are the executables and any libraries they depend on. Don't bother with manpages because Pyramid Linux has no manpage viewer. You may omit all documentation and example files to save space.

For the Fortune program, all you need are fortune, strfile, and unstr. How do you know? Because they are in /usr/bin. Anything in a /bin or /sbin directory is an executable. Use the du command to see how big they are:

	ubuntu@ubuntu:~$ du - /usr/games/fortune
	21k     /usr/games/fortune

The others are equally dinky, so there is no problem finding room on our little 60 MB Pyramid image.

We also need to know how much space the Fortune databases require. They are all in a single directory, which is convenient:

	ubuntu@ubuntu:~$ du -sh /usr/share/games/fortunes
	127k    /usr/share/games/fortunes

OK, now you know what files to copy. Next, configure the network card on Ubuntu, using an address suitable for your own LAN addressing scheme:

	ubuntu@ubuntu:~$ sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 broadcast
	192.168.1.255

Then, log in to Pyramid, and make the Pyramid filesystem writable:

	ubuntu@ubuntu:~$ ssh root@pyramid
	The authenticity of host '192.168.1.1 (192.168.1.1)' can't be established.
	RSA key fingerprint is 6b:4a:6b:3c:5e:35:34:b2:99:34:ea:9d:dc:b8:b1:d7.
	Are you sure you want to continue connecting (yes/no)? yes
	Warning: Permanently added '192.168.1.1' (RSA) to the list of known hosts.
	root@192.168.1.1's password:
	pyramid:~# /sbin/rw

Now, you can copy files to Pyramid with the scp command. Open a second terminal on Ubuntu, and run the scp command. Ubuntu does not come with an SSH server, so you cannot log in to Ubuntu from Pyramid. This example copies the files to the /sbin directory on Pyramid:

	ubuntu@ubuntu:~$ scp /usr/games/fortune /usr/bin/strfile /usr/bin/unstr root@192.168.
	1.1:/sbin/
	root@192.168.1.1's password:
	fortune     100%   18KB  17.8KB/s   00:00
	strfile     100%   11KB  11.4KB/s   00:00
	unstr       100% 5596     5.5KB/s   00:00

Mind your slashes and colons. Now, try running Fortune on Pyramid:

	pyramid:~# fortune
	fortune: error while loading shared libraries: librecode.so.0: cannot open shared
	object file: No such file or directory

This tells you that you need librecode.so.0. Find it with the locate command on Ubuntu, then copy it over:

	ubuntu@ubuntu:~$ locate librecode.so.0
	/usr/lib/librecode.so.0.0.0
	/usr/lib/librecode.so.0ubuntu@ubuntu:~$ scp /usr/lib/librecode.so.0 root@192.168.1.1:/usr/lib/

Try it again:

	pyramid:~# fortune
	question = ( to ) ? be : ! be;
	          -- Wm. Shakespeare

Remember to run /sbin/ro on Pyramid when you're finished.

Pyramid is mostly unmodified Ubuntu binaries, so sticking with Ubuntu binaries and source files is the safest and easiest method for modifying it. As long as your Ubuntu CD is the same release as your Pyramid installation (Breezy, Dapper, and so forth) you shouldn't experience any compatibility problems.

You can copy applications and they will work. All you need are all the relevant binaries or scripts, and whatever libraries the applications depend on.

Run df-h/ to see how much available space you have on Pyramid.

You can use ldd to see what libraries your application depends on before you start copying files:

	$ ldd /usr/games/fortune
	        linux-gate.so.1 => (0xffffe000)
	        librecode.so.0 => /usr/lib/librecode.so.0 (0xb7df7000)
	        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7cc8000)
	        /lib/ld-linux.so.2 (0xb7f42000)

To see a new fortune every time you log in, place the Fortune command in your personal ~/.bash_profile, or the systemwide /etc/profile, like this:

	fortune

That's right, a single word on a line by itself. You may modify this with any of the Fortune command's options.