How to use 'apt' to get source code and then do separate compile
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 .
Related videos on Youtube
Berlin Brown
Updated on September 18, 2022Comments
-
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 over 11 yearsThat 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 over 11 yearssorry, just updated the question!
-
josinalvo about 9 yearsthat 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 almost 4 yearsNice instructions thank you so much! It would be advisable to cd into a "working" directory before grabbing the source code though :-)