Monday, 21 March 2011

Installing RPM software without admin privileges

I'll kick off by saying this post is probably only going to be useful to other grad students in my department. I hope that no-one else is cursed by being without privilege or up-to-date software on a centrally administered RHEL 5 system. It works well enough but it's really old and not really supported by developers. (I'm looking at you, Chrome...)

So, the setup is this. The computer in my office runs RHEL. I can't install software because I don't have admin or sudo rights. Fortunately, there's a pretty neat way around all this: create your own, additional, RPM database and install software in your space. I've drawn heavily from this guide with a few tweaks.

Create Your Database

First thing is to make the folder that will store your database. I decided to build my own quasi-filesystem under ~/local, so I made this folder ~/local/var/lib/rpm. It then needs to be initialized as a database. Finally, we copy the main database so that new packages know what's already installed. These three things are accomplished by
mkdir -p \$HOME/local/var/lib/rpm
rpmdb \$HOME/local/var/lib/rpm
cp /var/lib/rpm/*  /local/var/lib/rpm/


where /var/lib/rpm/ is a usual location for the RPM database.

Installing RPM Packages

To install a new package, in theory all we have to enter is
rpm -i --db-path \$HOME/local/var/lib/rpm package.rpm

In reality, this will probably give a load of dependency errors and a failure to write to certain locations.

To solve the dependency problem, we add the --no-deps flag. This doesn't really solve the problem as much as it blatantly ignores it. Not a great strategy, broadly speaking, but it works. Just keep it in mind so that you can manually install the dependencies yourself.

To solve the location problem, we need to tell the package to use different locations. To get a list of locations that need relocating, type

rpm -qip package.rpm

and have a look at the "Relocations" information. For each necessary relocation, include a flag like

--relocate /old=/new

Details...

That more or less covers it but here are a few extra things I needed to do. saw many of these when trying to install Google Earth, so I'll refer to it as an example.

Firstly, the installers may try to execute programs that are in your local database, rather than the overall system. To find them successfully, you should add the additional path for executables to your default shell script. I added /home/wball/local/usr/bin/ to my \$PATH variable. In the Google Earth setup, this was necessary when it tried to execute xdg-icon-resource, which I'd installed through this whole method.

Secondly, any given installation might need some fine tuning. After installing Google Earth, I discovered that the executable (/local/usr/bin/google-earth) is actually just a symbolic link to the real executable in the depths of /opt. I had to recreate the link to point to the right place.

Thirdly, I found myself using a whole whack of --relocate flags, so I just created an alias for rpmlocal which included everything I kept typing. In my tcsh setup, it looks like this

alias rpmlocal 'rpm -ivh --dbpath ~/local/lib/rpm/ \
--relocate /opt=/home/wball/local/opt \
--relocate /etc=/home/wball/local/etc \
--relocate /usr=/home/wball/local/usr \
--relocate /usr/bin/=/home/wball/local/usr/bin \
--relocate /etc/default=/home/wball/local/etc/default \
--nodeps \!*'

and I add to it each time I find a new relocation is necessary. The hardcoded user directory is probably a bad idea. I suggest using \$HOME or ~ instead. If you're wondering the -v and -h flags give verbose output and a # progress bar.

The Unsolvables

After all this, there's still only so much that works and a few handy things that don't. Google Earth and irssi worked fine. LibreOffice just wanted way too much space: it claimed to need 7GB! Skype and Google Chrome didn't work after installing but this might just be a compatibility error with an ageing infrastructure. Maybe RHEL 6 will be on these machines before I finish my PhD.

Thursday, 17 March 2011

Scintilla, Nature's Curious News Aggregator

I can't quite remember what wandering on the interwebs brought me to it. Whatever the path that led me to it, I recently discovered Nature's Scintilla service. I haven't entirely worked out what its purpose is but if you click on the "Top Stories", it aggregates articles on a common subject from a number of sources (based on how many mentions you request).

It does solidify my opinion that many news sources are horribly uncreative. They even have the same article titles at times. That said, this might be a selection effect based on how Scintilla's algorithm works and which page it places on top. Make of this tool what you will.