Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

From time to time, we may have to install something from source due to various reasons. While it is fairly standard how to install software given appropriate dependencies, it is not clear to me how to manage such installation for future convenience.

More specifically:

  1. What can we do to ensure an easy and clean uninstallation (including those dependencies that are installed just before and just for the software installed from source)?

  2. What can we do to ensure an easy and clean upgrade of the same software, which will likely be installed from source again?

  3. What can we do to minimize potential conflict if there are a default package (installed using apt-get) as well as the (newer) version of the package (installed from source)?

share|improve this question

4 Answers 4

Using checkinstall make install will create a temporary package and install it. This means it is recorded in the package manager and can be uninstalled.

share|improve this answer

The best thing to do would be to make Debian packages of the newer versions yourself. dpkg and the apt tools do all three things that you mention and are intended for that purpose. Use them instead of reinventing the wheel. There are plenty of guides on packaging available. If the software already exists in the repositories, you can probably get the source package (apt-get src) which you can use to study and kick start your own package.

This answer to http://askubuntu.com/a/485230/158442 might be useful as a general guideline.

While checkinstall is great for a quick and dirty solution, long term you should use proper packaging.

share|improve this answer
    
thanks for the suggestions. When you said 'the software already exists in the repositories', I assume that you mean the official repositories maintained by Ubuntu. If so, in many cases these repositories do not provide newer versions especially on older Ubuntu releases. So apt-get src probably cannot help in such cases. –  skyork Jun 26 at 15:22
    
@skyork maybe they don't. But you can use packages of older versions to study. There might be some customisation the packagers had done, some custom maintenance scripts. There's no reason why you should ignore all of that and start from scratch. Reinventing the wheel seems to be a theme here. –  muru Jun 26 at 15:35

First of all, much depends upon how you manage your source codes. I make a directory like ~/sources and put every program in it's subdirectories, while others will create a new directory for every program.

Similarly some like me, create a new sub-sub-directory for every new version, and remove older versions only when it's ensured that there are no significant bugs in new version that would stop my work.

There is no single way to do this, but whichever way you choose, choose a way that would be easiest for you to manage.

  1. Clean Uninstallation

    • I would suggest creating a rem_dep.sh script which would look like this.

      #! /bin/bash
      sudo apt-get remove dep1 dep2 ... depn
      

      where dep1, dep2, depn are dependencies.

  2. Clean & easy upgrade

    • if you get source code from a automated versioning system like git or bazaar or if the links are predictable you can create a shell script which will

      #1 make a backup of earlier version
      #2 get new source
      #3 configure, build/make the source
      #5 if make went correctly, remove earlier version.
      #6 make install new version, update dependencies if required.
      
    • In other cases too, you can create such scripts with manual work to some extent.

  3. Conflict management

    • The best way is to use the --prefix option while install softwares and there dependencies.
    • Other important thing is to keep your system updated so as to minimize conflicts.

NOTE: If you find yourself compiling more software than you should(set a max_limit for yourself, like 5 or 10 or 100) it's best you leave Ubuntu and move to Arch Linux.

share|improve this answer

Build dependencies:

  • AFAIK they should be recorded manually. You can create a file like README to keep list of manually installed dependencies.

  • If that software has already a built binary in Ubuntu or PPA repositories. Tracking dependencies while installation should easier:

    sudo apt-get build-dep target_package
    

Clean uninstall:

Keep the configured&installed source folder. Better if you collect all sources in specific folder with the file of installed dependencies.

Clean upgrade & installed files isolation:

Install them in specific --prefix (preferably --prefix=/opt/software_name-version/).

This will solve many problems: concurrent versions with the one from repository; clean upgrade; easier for dirty uninstall in case source was deleted.

More sophisticate or the best way, as @muru answer, Build a Debian package (For packages available in Ubuntu/PPA repositories)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.