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.

When using the apt-get install method to install a package onto ubuntu, is there any fundamental difference between obtaining the source code for that package and building it from scratch? Does the apt-get install functionality simply download source and build it on your machine to a specified directory or is there more going on behind the scenes ?

Finally (maybe this has no answer) is one method better than the other? What I am angling at here is does the build it yourself from source code have any advantages or is it better to let apt-get do its thing?

share|improve this question

4 Answers 4

up vote 23 down vote accepted

The advantages of a package management system such as apt, yum, pacman, emerge, etc include:

  • It's easy to query what version of a package is installed or available.
  • It's easy to remove a package entirely, making sure all its files are gone.
  • It's easy to verify the integrity of the packages files, so you can see if it's been corrupted or tampered with.
  • It's easy to upgrade a package by installing the new version and removing all the old versions files. This will make sure not to leave any lingering files from the old package around to confuse or break things.
  • It's easy to see what packages require or provide things that other packages provide or require, so you can be sure to have the needed items for the package to function correctly.
  • It's easy to install or remove groups of packages.
  • In many cases it's possible to downgrade back to a previous version of a package, for example when a new version has a bug.

Although it is for Fedora, see also:

https://fedoraproject.org/wiki/Package_management_system

Installing from source may have advantages

  • You can customize the binaries (enable / disable options)
  • More up to date package then is available in the repositories
  • Sometimes necessary for bug fixes

But the disadvantages are that you will have to then manually update the package when a new version is available and you will often loose support.

IMO if you wish to compile all or most of your packages, I would advise Gentoo.

share|improve this answer
1  
To clarify this excellent answer, if you compile yourself, Update Manager will be left unaware and so will not update your application for you when updates are released. Also, apt (Ubuntu's chosen package manager) does not compile; it downloads the ready-made compiled binaries. Finally, apt automatically maintains your menu system when you install or remove programs. When you manually compile, you would have to do that yourself. –  Paddy Landau Jul 18 '12 at 9:06
1  
One other usually small advantage of compiling packages yourself is that they will be compiled with more knowledge of your exact hardware and may run faster. If you go this route, consider using checkinstall. asic-linux.com.mx/~izto/checkinstall It keeps track of what was installed and helps to cleanly remove it later if necessary. –  Joe Jul 18 '12 at 22:12
    
I stand corrected about the running faster part. –  Joe Jul 18 '12 at 22:20

Apt-get is APT package handling utility (CLI), back-end to Synaptic and Aptitude.

The apt-get method on triggering from your system checks the official sources or repositories listed in the file

etc/apt/sources.list

For eg. on running sudo apt-get update && sudo apt-get upgrade (which i use) , runs something like

enter image description here

where the Ign (Ignore) in-front of the Link states that no change is made since last visit to that repositories , and the Get states the retrieval of Sources file stating the changes of newly available package in that Repository .

No , apt-get utility doesn't downloads the Source File , it rather downloads the .deb package packed and released by the Official Ubuntu Packagers which has been tested for Stability and Integration with your system.

The apt-get downloaded packages can be found in

/var/cache/apt

where you can see all the Updates as .deb packages , and you can even compare to cross-check their version by visiting this Precise-updates packages.

As far as Compiling from source packages is concerned , it is not advisable and not even recommended for Ubuntu 12.04 as it a LTS Release ,you can view the reasons here

Is it better to compile from source or to install from a .deb package?

Does compiling programs from source speed up my operating system?

Advantages/Disadvantages of installing from source code

For further References : apt-get, sources.list.

share|improve this answer
    
actually the 3 programs, apt-get, aptitude and synaptic are back-ends for dpkg –  chilicuil Jul 12 '12 at 2:50
1  
Aptitude is front-end for dpkg. Whereas dpkg can be used as a front-end to dpkg-deb and dpkg-query –  atenz Jul 12 '12 at 4:58

I think you can use apt-get to install sources of packages.

  1. You need to activate source code repositories

    Open /etc/apt/sources.list file, you will see commented out lines (starts with #) which have "source" on them.

    Uncomment them

  2. Install dependencies of the program you want:

    sudo apt-get build-dep "program"

  3. Download and compile your program:

    sudo apt-get -b source "program"

After that you get a .deb package on your home directory.

share|improve this answer

If you build from source, you have more options in what's included. Installing from apt-get just installs a pre-built package.

As for which is better, it depends on what you need it for. I've never needed to compile from source but I don't do anything very extensive on my ubuntu laptop.

share|improve this answer
    
So apt-get doesnt build anything - just downloads a binary essentially? –  mathematician1975 Jul 11 '12 at 17:54
3  
Exactly. It's downloading a pre-built binary for your architecture (amd64, i386, armel, etc). –  tgm4883 Jul 11 '12 at 17:59

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.