有时候我们需要获得某个可执行程序的源码,而不仅仅是一个可执行程序,比如我们想获取tree这个工具的源码,这时候就可以采用下面的命令:
sudo apt-get source tree
pengdl@debian:~$ sudo apt-get source tree
Reading package lists... Done
Building dependency tree
Reading state information... Done
NOTICE: 'tree' packaging is maintained in the 'Git' version control system at:
git://git.debian.org/collab-maint/tree.git
Need to get 49.8 kB of source archives.
Get:1 http://mirrors.163.com/debian/ wheezy/main tree 1.6.0-1 (dsc) [1,145 B]
Get:2 http://mirrors.163.com/debian/ wheezy/main tree 1.6.0-1 (tar) [42.7 kB]
Get:3 http://mirrors.163.com/debian/ wheezy/main tree 1.6.0-1 (diff) [5,916 B]
Fetched 49.8 kB in 0s (78.9 kB/s)
gpgv: keyblock resource `/root/.gnupg/trustedkeys.gpg': file open error
gpgv: Signature made Sat 04 Feb 2012 08:33:55 AM EST using DSA key ID 514B3E7C
gpgv: Can't check signature: public key not found
dpkg-source: warning: failed to verify signature on ./tree_1.6.0-1.dsc
dpkg-source: info: extracting tree in tree-1.6.0
dpkg-source: info: unpacking tree_1.6.0.orig.tar.gz
dpkg-source: info: unpacking tree_1.6.0-1.debian.tar.gz
dpkg-source: info: applying 01_Makefile_fix
dpkg-source: info: applying 02_PATH_MAX
执行完成之后,就会在当前目录生成如下几个文件:
tree-1.6.0
tree_1.6.0-1.dsc
tree_1.6.0-1.debian.tar.gz
tree_1.6.0.orig.tar.gz
其中目录tree-1.6.0中就是想要的tree的源码了,根据其中的提示可以手工编译生成目标机器上的tree命令。