Can I update software installed from source code directly
Though its nearly a year since I started using Ubuntu, I have not attempted installing software from source. I didn't actually find the need to do so. But now I am working on a software which is at the release candidate stage in the repositories but the latest stable version's source code is available at the software home page.
I learnt that installing from source code may be difficult if the software has many dependencies. However if I tackle that, I can be happy with the latest version. But I keep wondering if such a software can automatically update itself or will I have to run some scripts to update the package. Or still worse will I have to reinstall each update from scratch?
Also I am eager to know if there is any specific advantage of installing from source other than the above.
Solution 1:
It is best to note that a software's dependencies rarely change. If you have successfully compiled the software once, any subsequent versions should be easy to compile - all dependencies should be satisfied already.
If you compiled from source, there is no .deb
or similar package that you would be able to use to update, unless you wait for the distribution to include that software into their repositories, or wait until the developers' PPA is updated.
Simply put, someone has to compile it first to make it into a deb. Compiling an old version would not give you the ability to update automatically, you still have to go through the whole "download-configure-compile-install" process.
However, if you want to install the same version on multiple computers, it would make sense to package your compiled version as a .deb
(or similar) and distribute it to those computers. If done right, the dependencies would be pulled into automatically.
As to the advantages of installing from source, the only two I can think of are:
- You get access to the latest revision of the code, and you have a choice of a stable version or the cutting-edge version (usually called nightly builds, latest revision, etc.)
- Ubuntu/other-distribution might not want to include the software into their repositories. In that case, you're stuck with the source code or packages provided by the developers or the community. That is, you have no choice but to use the sources.
Solution 2:
According to this post you can generate a .deb package after you compile the sources. Then instead of "make install", you can install from the .deb package. That makes it easier to update (if it was in a some repository) because the package will be managed by the package manager which tracks update.
In case for building package "some-package" from sources, and there are dependencies, you can try "apt-get build-dep some-package" to automatically install all the dependencies needed for you to compile your package, without manually tracking each dependency yourself. That way, the dependencies are also managed by the package manager and should be updated automatically as well.
Solution 3:
Another alternative for git
users is worth mentioning:
You can also use git pull
after an earlier git clone
to update your source code and then recompile your program if desired. (You can also use git
to further keep track of the files: see the answer here.)
If you originally used git clone
to get the source code, as in, for example,
git clone git://github.com/person/programname.git
and you retained the folder after compiling and installing, you can cd to the folder and run git pull
to get the latest commits. Then remove any build directories you might have created and/or run make clean
(if appropriate) and then compile the software again and install it with checkinstall
, which also creates a package for you (though not suitable for distribution).
However, if you are helping with development of a program and need to recompile after each daily git pull
then you probably would install to the home folder, as it would be unnecessary to install to the /usr/local/
hierarchy each time.
As an example, if I am testing and so regularly recompiling a program, I would cd to my build folder after getting the latest commits with git pull
and run (for this particular program):
cmake .. -DCMAKE_BUILD_TYPE=Debug -DLAYOUT=home -DPREFIX=home
and then compile the debug version to test.
However, if you merely wanted to compile a new version of your git cloned program every month or so (and weren't testing or debugging it) you would usually install to the /usr/local/
hierarchy with checkinstall
.