How to use 'apt' to get source code and then do separate compile

42,120

Solution 1

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.

Sources:

Solution 2

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.

Solution 3

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 .

Share:
42,120

Related videos on Youtube

Berlin Brown
Author by

Berlin Brown

Updated on September 18, 2022

Comments

  • Berlin Brown
    Berlin Brown almost 2 years

    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'

  • Berlin Brown
    Berlin Brown over 11 years
    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'.
  • meda
    meda over 11 years
    sorry, just updated the question!
  • josinalvo
    josinalvo about 9 years
    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?
  • desgua
    desgua almost 4 years
    Nice instructions thank you so much! It would be advisable to cd into a "working" directory before grabbing the source code though :-)