Original posts: http://lesca.me/blog/2011/06/23/copile-source-package-on-ubuntu/
Take the tree utility as an example of how to manage the source package in Ubuntu, including querying, obtaining, compiling the source package, and installing it. 1. Preparation
Ensure that the DEB-SRC entry is added to the software source configuration file/etc/apt/sources.list before you obtain the source package
Use the following command to get more information about the tree source package:
sudo apt-cache showsrc tree
This is used to query whether the source package is present in the current mirror site.
2. Get the source file
The source package usually contains 3 files, respectively, with DSC,orig.tar.gz , and diff.gz as suffix names. Use the Apt-get Source command to get the source package, it will download the source package to the user's current directory, and during the execution of the command, call the Dpkg-source command, according to the information in the DSC file, extract the source package into the same name directory, the application source code is here.
sudo apt-get source tree
It is important to emphasize that before downloading the source package, you must ensure that Dpkg-dev(execute "apt-get install Dpkg-dev") is installed, otherwise, only the source package will be downloaded 3 files, but will not extract the source package. Of course, you can also use the Dpkg-source command to extract the source package: (Note: You must ensure that Dpkg-dev is installed, if not installed will prompt permission denied)
Dpkg-source-x TREE-1.5.1.2.DSC
3. Getting dependent files
Before compiling the source package, you need to install the relevant package with dependencies. Use the Apt-get BUILD-DEP command to proactively obtain and install all relevant packages.
sudo apt-get build-dep tree
4. Compiling the source package
First enter the source directory, using the Dpkg-buildpackage command to compile the source package, it will be the resulting Deb package placed in the upper directory.
CD tree-1.5.1.2
sudo dpkg-buildpackage
This will generate the executable file in the current directory compilation and generate Tree-1.5.1.2-1_i386.deb 5 in the upper directory . Install package
Use the Dpkg–i command to install the generated Deb package.
sudo dpkg–i tree-1.5.1.2-1_i386.deb
6. Test the Tree program
We use it to view the contents of the working directory where the compilation is made.
Tree–l 2
References:
[1] Ubuntu compiled source package DSC Diff.gz Orig.tar.gz
[2] excuse me. How does DSC work?
[3] Man Dpkg-source
[4] Man Dpkg-buildpackage
[5] Man dpkg