轉自:http://blog.csdn.net/yuanlu837/article/details/7750492
如何獲取ubuntu源碼包裏面的源碼?
1、在獲取源碼包之前,確保在軟件源配置文件/etc/apt/sources.list中添加了deb-src項
2、使用如下命令獲取xxx源碼包的詳細信息:
sudo apt-cache showsrc xxx 這用來查詢當前鏡像站點中是否有該源碼包。
3、源碼包中通常包含3個文件,分別以dsc,orig.tar.gz和diff.gz爲後綴名。
sudo apt-get source xxx 命令來獲取源碼包,它會將源碼包下載到用戶當前目錄
並在命令執行過程中,調用dpkg-source命令,根據dsc文件中的信息,將源碼包解壓到同名目錄中,應用程序的源代碼就在這裏面。
sudo apt-get source xxx
要強調的是,在下載源碼包前,必須確保安裝了dpkg-dev(執行”apt-get install dpkg-dev”來安裝),
否則,只會下載源碼包的3個文件,但不會解壓縮源碼包。當然你也可以自己用dpkg-source命令去解壓縮源碼包。
4、在編譯源碼包前,需要安裝具有依賴關係的相關軟件包。使用”apt-get build-dep”命令可以主動獲取並安裝所有相關的軟件包。
sudo apt-get build-dep xxx
5、現在可以來編譯源碼包了,首先進入源碼所在目錄,使用dpkg-buildpackage命令來編譯源碼包,它會將生成的Deb軟件包放置在上層目錄中。
cd xxx
sudo dpkg-buildpackage
這樣就會編譯生成xxx_i386.deb
6、安裝軟件包。使用”dpkg –i”命令來安裝生成的Deb軟件包。
sudo dpkg -i xxx_i386.deb
如果出現:Error :: You must put some 'source' URIs in your sources.list
說明沒有再/etc/apt/source.list中添加 deb-src uri
如何添加deb-src
方法一:直接將原來的deb-src 路徑前的 '#'註釋去掉。
方法二:使用新的源,我使用的是阿里的源,好處就是比國外的源下載更新速度快!
直接將 下邊deb-src開頭的源 複製到/etc/apt/source.list中
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
以上兩個方法任選其一,然後執行:
sudo apt-get update
就可以了
參考:https://www.debian.org/doc/manuals/apt-howto/ch-sourcehandling.zh-cn.html
參考:http://www.10tiao.com/html/346/201607/2651089764/1.html