11

I used to download everything to /tmp, because after make; sudo make install I usually don't need those files anymore.

But now I realized the only way to uninstall programs installed from source, is to use make uninstall (when available). So I should probably keep my downloads in case I need them later.

So where should I store them? Is there a designed place for that in linux?

2
  • Avoid the problem: install from packages when possible. Feb 3, 2013 at 2:21
  • 1
    @MichaelHampton Sometimes that's not an option (I think), eg: nginx requires being installed form source if you want to add third party modules. Feb 3, 2013 at 2:35

2 Answers 2

16

The location defined by the Filesystem Hierarchy Standard to keep source code is /usr/src. I suppose you could also use /usr/local/src, as that is a bit more descriptive of where the software came from (that is, you built it; the distro didn't).

Note, however, that the FHS actually mentions that source code should not be built from this directory, likely because you're not supposed to compile things as root, so I suppose that you'd move the source tree there after installation. In practice, though, I don't bother; I keep everything I build in ~/Code, which is on a roomier partition. Basically, there isn't a widely accepted convention; you just do what works for you.

You should also look at checkinstall, a great little piece of software that makes a rudimentary package from a command. (It will probably be in your distribution's repository.) Essentially, instead of running

sudo make install

you would run something along the lines of

sudo checkinstall make install

which quizzes you about the package you're making, watches make install install everything, then builds a package that can then be cleanly installed and uninstalled with a package manager. I believe that checkinstall can build packages for dpkg-based systems (Ubuntu, Debian, etc.), RPM-based systems (Fedora, RHEL, etc.) and Slackware-based systems. If you're running Arch, don't bother with checkinstall; instead, consider using a PKGBUILD.

Hope that helps!

3
  • +1 for mentioning packages. Which I think is the answer that was needed (but not asked).
    – Hennes
    Feb 2, 2013 at 23:49
  • Thanks! I'm using checkinstall now, looks great so far. One last question: I don't need to keep the .deb, right? dpkg will know how to uninstall it even if it's gone Feb 3, 2013 at 3:19
  • That's correct. All package managers keep a list of files installed by the package, so you can delete the built package after you install it. Feb 3, 2013 at 16:59
5

There is not designated place for source files; everybody has his or her own habits.

However, consider these three options:

  1. In roots homedir (works, but it is on / which is usually rather small).
  2. /usr/local/src/ (or actually anything under /usr/local/
  3. Install via a package and use the package manager to uninstall.

For long term maintenance I really recommend option 3. Even if you have to build the packages yourself (from source). In which case you do get to: untar / configure / make / make package via some syntax depending on your package choice / install package

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .