I want to get the source code for a project and then build it the same way that apt would. E.g. I want the working source code and be able to run 'make' or similar command on the source.

How can I do that?

Specifically I want to get this source 'icedtea-6-jre-jamvm'


For this example I'll use icedtea-6-jre-jamvm as the package you want to rebuild.

First install all the dependencies and build essential:

sudo apt-get build-dep icedtea-6-jre-jamvm
sudo apt-get install build-essential

Then grab the source:

apt-get source icedtea-6-jre-jamvm

Then cd in the openjdk directory directory and build the deb, the -us and -uc here skip the GPG checks if you're just rebuilding it for yourself:

cd openjdk-6-6b24-1.11.5
dpkg-buildpackage -us -uc

Then go up a directory and you should have .deb files.


  • that is very nice! one big hurdle to start contributing to a free software program is "getting it to compile", and it is nice to see this automated. It would be neat, however, if we could generate the binaries and stop there (i.e. not generate the debs) since this is a bit more convenient for developers who are editing and compiling frequently... Do you happen to know a way to do that?
    – josinalvo
    Jun 18 '15 at 20:03
  • Nice instructions thank you so much! It would be advisable to cd into a "working" directory before grabbing the source code though :-)
    – desgua
    Sep 12 '20 at 10:59

to just compile the package use the debian/rules script which is provided in each debain package:

sudo apt-get build-dep <package>
apt-get source <package>
cd <package>_<version>
./debian/rules binary

this just does the configure and the compile part.


You can use the follwing :

apt-get source <package>

you need to make sure you install the build dependencies :

sudo apt-get build-dep <package> 

for more info run :

man apt-get

Alternative option :First you need to know the location of the package. then download the tar file using :

sudo wget <url>

You can then untar it and compile it using make

if your not sure about the specific command look inside of the folder, there should be a README file or INSTALL which will tell you the appropriate command .

  • That is get from the host site. Is there a way to do it with 'apt. Completely through 'apt' minus the actual compile. E.g. can I do 'apt get source' and then navigate to that directory and then 'make'. Jan 23 '13 at 17:19
  • sorry, just updated the question!
    – meda
    Jan 23 '13 at 17:28

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