Installing software from source

From Netsoc Wiki
Jump to: navigation, search

Most files belonging to Debian packages are arranged into the filesystem by rough type: programs go in /usr/bin, libraries in /usr/lib, static data (like icons, documentation, etc) in /usr/share, dynamic data (like logs, databases) in /var, and so on. When programs are installed from source, by default they will put themselves either in these folders or the corresponding ones in /usr/local or /var/local.

This has a few problems for netsoc machines:

  • If files go into /usr, they risk screwing up future Debian package installs (which will fail if similarly-named files exist in /usr)
  • It's difficult to uninstall a program installed this way, since the files scatter themselves all over the place
  • This leads to difficulties in upgrading programs (often you end up with half the original program files still there)
  • It's difficult to figure out which program owns a given file (Debian packages don't have this problem because of dpkg, but programs installed from source have no manifest of which files they own).

So, the preferred place to put such pieces of software is in /opt. /opt is a folder which is created by Debian but never used, so it's a place for the admin to put whatever software doesn't have a debian package.

To install foobarbaz version 1.1, create a directory /opt/foobarbaz-1.1. If compiling from source, unpack the source into /opt/foobarbaz-1.1/sourcecode or similar and leave it there after the program is installed. For both source and binary installs, make sure all files get installed into /opt/foobarbaz-1.1. For Autoconf projects, this can be done with ./configure --prefix=/opt/foobarbaz-1.1 && make; make install. Only the make install stage should be done as root.

To make things work nicely, sometimes files are needed in specific directories under /usr/local (a particular example is .desktop files needed to add items to the menu). This should be done by putting the files in /opt/foobarbaz-1.1 and adding symbolic links to /usr/local/share/applications or wherever.

Uninstalling a program can then by done by rm -rf'ing its folder in /opt.

Upgrades should be done as a clean install of the newer version into /opt/foobarbaz-2.0 followed by a rm -rf of the older version.

If you need to change system-wide environment variables (particularly $PATH), /etc/security/pam_env.conf is probably the best way of doing it. /etc/profile and friends are specific to particular shells and will not work for people who use tcsh and the like. Configuration files in /etc are preferred over environment variables as they're easier to change (no waiting for people to log out and log in again). Messing with /etc/ld.so.conf is easier than messing with $LD_PATH, and adding symlinks to /usr/local/bin may be easier than messing with $PATH.