Originaly published 2010-07-06 14:29:11

Installing Debian Packages Locally

My department is planning to install Ubuntu on all our lab machines, and probably take away sudo access from everyone who doesn't truly need it (i.e. anyone who isn't a sysadmin). I'm looking forward to having Ubuntu, but it's less useful if I can't install the software I want with apt-get. Thus, I started wondering whether it's possible to install Debian packages in a non-standard location, without being root.

dpkg has a --root option that lets you change the installation prefix, but it still won't let you install anything without being root. apt-get will fetch packages, but, again, only as root. So I figured I'd write a script to do it all.

The script is here. It takes as arguments either the name of a package (like you'd pass to apt-get install) or the filename of a .deb, and the prefix to which you'd like to install it. It fetches dependencies (and the package itself if necessary), then unpacks the debs and installs them. I'm planning to use it in combination with stow to install packages to $HOME/.local.

Caveats

  • If you install more than one package with the same dependency, that dependency will be installed more than once. This will cause problems with stow. Hopefully common dependencies are already installed on your system.
  • It only installs one level of dependencies, so the dependencies might be missing dependencies, causing things not to work.
  • There is probably some terrible bug I don't know about. Let me know if you find one!