apt-get build-dep 包名,這條命令用於在編譯安裝軟件時,自動安裝相關的編譯環境。比如我要編譯nginx,當然可以從網上找到需安裝哪些庫,用apt-get install XXXX XXXX XXXX ... 來進行安裝。但是有時候裝了一堆庫,可能有幾個是用不到的。而是用apt-get build-dep命令可以更好的管理這些庫文件和編譯環境。
先更新軟件源列表:
apt-get update
以編譯nginx為例,安裝所需的編譯環境:
apt-get build-dep nginx
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: autopoint autotools-dev binutils build-essential bzip2 cpp cpp-4.4 debhelper dpkg-dev fakeroot g++ g++-4.4 gcc gcc-4.4 gettext git html2text intltool-debian libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libc-dev-bin libc6-dev libcroco3 libcurl3-gnutls libdpkg-perl liberror-perl libgeoip-dev libglib2.0-0 libglib2.0-data libgmp3c2 libgomp1 libmail-sendmail-perl libmpfr4 libpcre3-dev libpcrecpp0 libssl-dev libstdc++6-4.4-dev libsys-hostname-long-perl libtimedate-perl libunistring0 linux-libc-dev make manpages-dev po-debconf rsync shared-mime-info zlib1g-dev The following packages will be upgraded: libc-bin libc6 libc6-i686 libc6-xen libssl0.9.8 5 upgraded, 48 newly installed, 0 to remove and 54 not upgraded. Need to get 52.7 MB of archives. After this operation, 122 MB of additional disk space will be used. Do you want to continue [Y/n]? Y ...
由於關系包有很多,如果想卸載可以在安裝前先記錄下build-dep安裝的包:
apt-get build-dep nginx | tee nginx-build-dep.txt
Debian系統可以用Deborphan清理沒有被依賴的軟件包:
apt-get install deborphan
查找沒有被依賴的軟件包:
deborphan -sPz
刪除找到的包:
apt-get autoremove `deborphan`
參考資料:
http://wiki.linux.org.hk/w/Deborphan