| 1 |
<!DOCTYPE debiandoc PUBLIC "-//DebianDoc//DTD DebianDoc//EN">
|
| 2 |
<!-- CVS revision of this document "$Revision: 1.1 $" -->
|
| 3 |
<!-- CVS revision of original english document "1.22" -->
|
| 4 |
<debiandoc>
|
| 5 |
|
| 6 |
<book>
|
| 7 |
|
| 8 |
<title>APT HOWTO (Obsolete Documentation)</title>
|
| 9 |
|
| 10 |
<author>
|
| 11 |
<name>Gustavo Noronha Silva</name> <email>kov@debian.org</email>
|
| 12 |
</author>
|
| 13 |
<translator>
|
| 14 |
<name>劉浩</name> <email>iamlyoo@163.com</email>
|
| 15 |
</translator>
|
| 16 |
|
| 17 |
<version>1.8.10.4 - 2005年3月</version>
|
| 18 |
|
| 19 |
<abstract>
|
| 20 |
這篇文件試圖讓使用者對於Debian包管理工具APT的工作方式有一個很好的理解。
|
| 21 |
它的目標是讓新的Debian使用者更容易上手,也讓那些想幫助那些想更深入理解
|
| 22 |
如何管理他們的系統的人。它為Debian項目而編寫,目的是提高此發行版對它
|
| 23 |
的使用者的支援水平。
|
| 24 |
</abstract>
|
| 25 |
|
| 26 |
<copyright>
|
| 27 |
<copyrightsummary>
|
| 28 |
版權所有 © 2001, 2002, 2003, 2004 Gustavo Noronha Silva
|
| 29 |
</copyrightsummary>
|
| 30 |
<p>
|
| 31 |
This manual is free software; you may redistribute it and/or modify it
|
| 32 |
under the terms of the GNU General Public License as published by the
|
| 33 |
Free Software Foundation; either version 2, or (at your option) any
|
| 34 |
later version.
|
| 35 |
</p>
|
| 36 |
|
| 37 |
<p>
|
| 38 |
This is distributed in the hope that it will be useful, but messageout
|
| 39 |
any warranty; messageout even the implied warranty of merchantability or
|
| 40 |
fitness for a particular purpose. See the GNU General Public License
|
| 41 |
for more details.
|
| 42 |
</p>
|
| 43 |
|
| 44 |
<p>
|
| 45 |
A copy of the GNU General Public License is available as
|
| 46 |
/usr/share/common-licenses/GPL in the Debian GNU/Linux distribution or
|
| 47 |
on the World Wide Web at the GNU General Public Licence. You can also
|
| 48 |
obtain it by writing to the Free Software Foundation, Inc., 59 Temple
|
| 49 |
Place - Suite 330, Boston, MA 02111-1307, USA.
|
| 50 |
</p>
|
| 51 |
</copyright>
|
| 52 |
|
| 53 |
<toc>
|
| 54 |
|
| 55 |
<chapt>導言
|
| 56 |
<p>
|
| 57 |
最初只有.tar.gz的打包檔案,使用者必須編譯每個他想在GNU/Linux上執行的軟體。
|
| 58 |
使用者們普遍認為系統很有必要提供一種方法來管理這些安裝在機器上的套裝軟體,
|
| 59 |
當Debian誕生時,這樣一個管理工具也就應運而生,它被命名為<prgn>dpkg</prgn>。
|
| 60 |
從而著名的“package”概念第一次出現在GNU/Linux系統中,稍後Red Hat才決定開
|
| 61 |
發自己的“rpm”包管理系統。
|
| 62 |
<p>
|
| 63 |
很快一個新的問題難倒了GNU/Linux製作者,他們需要一個快速、實用、高效的方
|
| 64 |
法來安裝套裝軟體,當套裝軟體更新時,這個工具應該能自動管理關聯檔案和維護已有
|
| 65 |
組態檔案。Debian在次率先解決了這個問題,APT(Advanced Packaging Tool)誕生
|
| 66 |
了。APT後來還被Conectiva改造用來管理rpm,並被其它Linux發行版本采用為它們
|
| 67 |
的套裝軟體管理工具。
|
| 68 |
<p>
|
| 69 |
本文件不打算講解apt-rpm相關知識,因為Conectiva移植的APT已很有名了,不過
|
| 70 |
提供有關這部分的補充文件還是歡迎的。
|
| 71 |
<p>
|
| 72 |
本文件是基於Debian下一個發行版<tt>Sarge</tt>的。
|
| 73 |
</chapt>
|
| 74 |
|
| 75 |
<chapt id="basico">基礎設定
|
| 76 |
|
| 77 |
<sect id="sources.list">/etc/apt/sources.list檔案
|
| 78 |
<p>
|
| 79 |
作為操作的一部分,APT使用一個檔案列出可獲得套裝軟體的鏡像站台位址,這個文
|
| 80 |
件就是<tt>/etc/apt/sources.list</tt>。
|
| 81 |
<p>
|
| 82 |
檔案中的各項資訊通常按如下格式列出:
|
| 83 |
|
| 84 |
<p>
|
| 85 |
<example>
|
| 86 |
deb http://host/debian distribution section1 section2 section3
|
| 87 |
deb-src http://host/debian distribution section1 section2 section3
|
| 88 |
</example>
|
| 89 |
|
| 90 |
<p>
|
| 91 |
當然,上面所列的位址項都是假設的且不應該使用它們。每行的第一個單字<tt>deb
|
| 92 |
</tt>或<tt>deb-src</tt>描述了檔案類型:目錄中包含的是二進位套裝軟體(<tt>deb
|
| 93 |
</tt>),
|
| 94 |
即我們通常使用的已編譯好的套裝軟體;或包含的是來源碼包(<tt>deb-src</tt>),來源碼
|
| 95 |
包包含來源程序編碼、Debian控制檔案(<tt>.dsc</tt>)和“Debian化”這個程式所做變更的
|
| 96 |
記錄檔案<tt>diff.gz</tt>。
|
| 97 |
<p>
|
| 98 |
在Debian預設的sources.list中通常是如下內容:
|
| 99 |
<p>
|
| 100 |
<example>
|
| 101 |
# See sources.list(5) for more information, especially
|
| 102 |
# Remember that you can only use http, ftp or file URIs
|
| 103 |
# CDROMs are managed through the apt-cdrom tool.
|
| 104 |
deb http://http.us.debian.org/debian stable main contrib non-free
|
| 105 |
deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
|
| 106 |
deb http://security.debian.org stable/updates main contrib non-free
|
| 107 |
|
| 108 |
# Uncomment if you want the apt-get source function to work
|
| 109 |
#deb-src http://http.us.debian.org/debian stable main contrib non-free
|
| 110 |
#deb-src http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free
|
| 111 |
</example>
|
| 112 |
|
| 113 |
<p>
|
| 114 |
這些是Debian基本安裝所需的套裝軟體來來源位址。第一個<tt>deb</tt>行指向官方正
|
| 115 |
式套裝軟體來來源,第二個行指向non-US套裝軟體來來源,第三行指向Debian安全補綴更新
|
| 116 |
包來來源。
|
| 117 |
<p>
|
| 118 |
最後兩行被註解掉了(在句首加“#”),所以apt-get將忽略它們。這些是<tt>deb-src
|
| 119 |
</tt>行指向Debian來源碼包來來源,如果你常下載程序來源碼來測試或重編譯,可取消對
|
| 120 |
它們的註解。
|
| 121 |
<p>
|
| 122 |
<tt>/etc/apt/sources.list</tt>檔案可包含多種類型的位址,APT知道如何處理這
|
| 123 |
些不同的位址類型:<tt>http</tt>、<tt>ftp</tt>、<tt>file</tt>(本地檔案,例
|
| 124 |
如:一個加載了ISO9600檔案系統的目錄)和<tt>ssh</tt>。
|
| 125 |
<p>
|
| 126 |
別忘了在修改完<tt>/etc/apt/sources.list</tt>檔案後執行<tt>apt-get</tt>使
|
| 127 |
變更生效。你必須完成這個步驟,以便讓APT從你指定的地方獲得新的套裝軟體列表。
|
| 128 |
</sect>
|
| 129 |
|
| 130 |
<sect id="dpkg-scanpackages">如何在本地使用APT
|
| 131 |
<p>
|
| 132 |
有時你硬碟上有許多.deb套裝軟體,你會希望通過APT來安裝它們,以便讓它去處理軟
|
| 133 |
件包間複雜的依賴關係。
|
| 134 |
<p>
|
| 135 |
想這麼做,就建一個目錄,將所有你想要安裝的.deb檔案放入其中。例如:
|
| 136 |
<p>
|
| 137 |
<example>
|
| 138 |
# mkdir /root/debs
|
| 139 |
</example>
|
| 140 |
<p>
|
| 141 |
你可以使用一個<tt>override</tt>檔案直接去修改套裝軟體中控制檔案中的定義,使
|
| 142 |
之符合你的軟體儲藏庫管理規則。在這個覆寫檔案中,你可能希望定義一些選項來覆
|
| 143 |
蓋那些套裝軟體的定義,如下所示:
|
| 144 |
<p>
|
| 145 |
<example>
|
| 146 |
package priority section
|
| 147 |
</example>
|
| 148 |
<p>
|
| 149 |
package是套裝軟體的名稱,priority有三個層級low、medium或high,section是軟體
|
| 150 |
包所屬的section,多載檔案可任意命名,檔案名稱將在接下來的步驟中做為參數傳遞
|
| 151 |
給<prgn>dpkg-scanpackages</prgn>。如果你不想寫多載檔案,只需在調用<tt>
|
| 152 |
dpkg-scanpackages</tt>時使用<tt>/dev/null</tt>就行了。
|
| 153 |
<p>
|
| 154 |
仍是在/root目錄下執行:
|
| 155 |
<p>
|
| 156 |
<example>
|
| 157 |
# dpkg-scanpackages debs <var>file</var> | gzip > debs/Packages.gz
|
| 158 |
</example>
|
| 159 |
<p>
|
| 160 |
在上述的命令行中,<var>file</var>為<tt>override</tt>檔案,命令產生一個<file>
|
| 161 |
Packages.gz</file>檔案,它包含了APT所需的各種套裝軟體資訊。最後,如果要使用
|
| 162 |
這些套裝軟體,加上:
|
| 163 |
<p>
|
| 164 |
<example>
|
| 165 |
deb file:/root debs/
|
| 166 |
</example>
|
| 167 |
<p>
|
| 168 |
完成了上面的工作,就可以通常那樣使用APT命令操作這些套裝軟體了。你可以使用同
|
| 169 |
樣的方法產生一個來源碼庫,但請記住你需要將<tt>.orig.tar.gz</tt>檔案、<tt>
|
| 170 |
.dsc</tt>檔案和<tt>.diff.gz</tt>檔案包含在目錄中,同時必須產生<tt>
|
| 171 |
Source.gz</tt>檔案而不是<tt>Packages.gz</tt>檔案。所使用的命令也不相同,
|
| 172 |
要使用<prgn>dpkg-scansources</prgn>,命令如下所示:
|
| 173 |
<p>
|
| 174 |
<example>
|
| 175 |
# dpkg-scansources debs | gzip > debs/Sources.gz
|
| 176 |
</example>
|
| 177 |
<p>
|
| 178 |
Notice that <prgn>dpkg-scansources</prgn> doesn't need an
|
| 179 |
<tt>override</tt> file. The sources.list's line is:
|
| 180 |
<p>
|
| 181 |
<example>
|
| 182 |
deb-src file:/root debs/
|
| 183 |
</example>
|
| 184 |
</sect>
|
| 185 |
|
| 186 |
<sect id="netselect">選擇最佳鏡像發佈站台加入source.list檔案:netselect,netselect-apt
|
| 187 |
<p>
|
| 188 |
一個新使用者經常問到的問題:“該將哪個Debian鏡像發佈站台加入<tt>source.list
|
| 189 |
</tt>檔案?”。有很多方法來選擇鏡像發佈站台,專家們可能會寫一個腳本去測試
|
| 190 |
不同站台的ping時間。不過其實有一個程序可以幫你:
|
| 191 |
<strong>netselect</strong>。
|
| 192 |
<p>
|
| 193 |
要安裝netselect,通常使用:
|
| 194 |
<p>
|
| 195 |
<example>
|
| 196 |
# apt-get install netselect
|
| 197 |
</example>
|
| 198 |
<p>
|
| 199 |
不帶參數執行它時會顯示它的幫助資訊。執行它時加上以空格分隔的鏡像主機列表,
|
| 200 |
它會傳回一個分值和列表中的一個主電腦名稱。這個分值通過評估ping時間和hops數(一
|
| 201 |
個網路請求報文到達目標主機所經過的轉發主機的個數)得出,它與鏡像站台預計下
|
| 202 |
載速度成反比(數值越小越好)。傳回的主電腦名稱是主機列表中得分最低的那個(檢視列
|
| 203 |
表中所以主機的得分情況可使用-vv選項)。看出下的例子:
|
| 204 |
<p>
|
| 205 |
<example>
|
| 206 |
# netselect ftp.debian.org http.us.debian.org ftp.at.debian.org download.unesp.br ftp.debian.org.br
|
| 207 |
365 ftp.debian.org.br
|
| 208 |
#
|
| 209 |
</example>
|
| 210 |
<p>
|
| 211 |
它表示,在netselect後列出的所有主機中,<tt>ftp.debian.org.br</tt>是下載速
|
| 212 |
度最快的主機,其得分為365。(注意!!這是在我電腦上的測試結果,不同的網路
|
| 213 |
節點网速會大不相同,所以這個分值不一定適用於其它電腦)
|
| 214 |
<p>
|
| 215 |
現在將netselect找到的連線速度最快的鏡像站台加入<tt>/etc/apt/sources.list
|
| 216 |
</tt>檔案(參考<ref id="sources.list">)並按照<ref id="apt-get">中的技巧來做。
|
| 217 |
<p><strong>注意:</strong>鏡像站台列表通常包含在檔案
|
| 218 |
<url id="http://www.debian.org/mirror/mirrors_full"
|
| 219 |
name="http://www.debian.org/mirror/mirrors_full">中。
|
| 220 |
<p>
|
| 221 |
從0.3.ds1版開始,netselect來源碼包中包含了<strong>netselect-apt</strong>二
|
| 222 |
進制包,它使上述操作自動完成。只需將發佈目錄樹做為參數(預設為stable)輸入,
|
| 223 |
<tt>sources.list</tt>檔案就會產生速度最快的main和non-US鏡像站台列表,並保
|
| 224 |
存在目前目錄下。下面的例子產生一個包含stable發佈鏡像站台列表的sources.list:
|
| 225 |
<p>
|
| 226 |
<example>
|
| 227 |
# ls sources.list
|
| 228 |
ls: sources.list: File or directory not found
|
| 229 |
# netselect-apt stable
|
| 230 |
(...)
|
| 231 |
# ls -l sources.list
|
| 232 |
sources.list
|
| 233 |
#
|
| 234 |
</example>
|
| 235 |
<p>
|
| 236 |
<strong>記住:</strong><tt>sources.list</tt>產生在目前目錄下,必須將其移
|
| 237 |
至<tt>/etc/apt</tt>目錄。
|
| 238 |
<p>
|
| 239 |
接著,按照<ref id="apt-get">中的技巧來做。
|
| 240 |
</sect>
|
| 241 |
|
| 242 |
<sect id="cdrom">將CD-ROM加入source.list檔案
|
| 243 |
<p>
|
| 244 |
如果你用APT從CD-ROM上安裝及升級套裝軟體,你可以將它加入到<tt>sources.list
|
| 245 |
</tt>檔案中。完成該操作,可使用<prgn>apt-cdrom</prgn>程序:
|
| 246 |
|
| 247 |
<p>
|
| 248 |
<example>
|
| 249 |
# apt-cdrom add
|
| 250 |
</example>
|
| 251 |
|
| 252 |
<p>
|
| 253 |
將Debian光碟放入光碟機,它將加載光碟目錄,並在光碟上尋找套裝軟體資訊。如果你
|
| 254 |
的光碟機需要額外設定,可使用以下選項:
|
| 255 |
|
| 256 |
<p>
|
| 257 |
<example>
|
| 258 |
-h - program help
|
| 259 |
-d directory - CD-ROM mount point
|
| 260 |
-r - Rename a recognized CD-ROM
|
| 261 |
-m - No mounting
|
| 262 |
-f - Fast mode, don't check package files
|
| 263 |
-a - Thorough scan mode
|
| 264 |
</example>
|
| 265 |
|
| 266 |
<p>
|
| 267 |
例如:
|
| 268 |
|
| 269 |
<p>
|
| 270 |
<example>
|
| 271 |
# apt-cdrom -d /home/kov/mycdrom add
|
| 272 |
</example>
|
| 273 |
|
| 274 |
<p>
|
| 275 |
你還可以掃瞄一張光碟,但不將其加入列表:
|
| 276 |
|
| 277 |
<p>
|
| 278 |
<example>
|
| 279 |
# apt-cdrom ident
|
| 280 |
</example>
|
| 281 |
|
| 282 |
<p>
|
| 283 |
注意,只有當你在系統的<tt>/etc/fstab</tt>中正確設定了光碟機後,這個程式才會工作。
|
| 284 |
</sect>
|
| 285 |
|
| 286 |
</chapt>
|
| 287 |
|
| 288 |
<chapt id="apt-get">套裝軟體管理
|
| 289 |
<sect id="update">更新可用套裝軟體列表
|
| 290 |
<p>
|
| 291 |
套裝軟體管理系統使用一個私有資料庫追蹤列表中套裝軟體的目前狀態:已安裝、未安
|
| 292 |
裝或可安裝。<prgn>apt-get</prgn>通過該資料庫來確定如何安裝使用者想用的軟體
|
| 293 |
包以及正常執行該套裝軟體所必須的其它關聯包。
|
| 294 |
<p>
|
| 295 |
你可以使用<prgn>apt-get update</prgn>來更新資料庫列表。這個命令將掃瞄
|
| 296 |
<tt>/etc/apt/sources.list</tt>檔案中所指路徑中的套裝軟體列表檔案。有關該列
|
| 297 |
表檔案的更多資訊請參考<ref id="sources.list">。
|
| 298 |
<p>
|
| 299 |
定時執行這個程序是個好主意,它將使你和你的系統獲得最新的套裝軟體更新和安全
|
| 300 |
更新等資訊。
|
| 301 |
</sect>
|
| 302 |
|
| 303 |
<sect id="install">安裝套裝軟體
|
| 304 |
<p>
|
| 305 |
現在,終於到了你一直期待的階段!準備好了sources.list和最新版的的可用軟體
|
| 306 |
包,你所需做的就是執行<tt>apt-get</tt>來安裝你渴望已久的軟體了。例如,你
|
| 307 |
可以這樣:
|
| 308 |
|
| 309 |
<p>
|
| 310 |
<example>
|
| 311 |
# apt-get install xchat
|
| 312 |
</example>
|
| 313 |
|
| 314 |
<p>
|
| 315 |
APT會掃瞄它的資料庫找到最新的版本的套裝軟體,並將它從<tt>sources.list</tt>中
|
| 316 |
所指的地方下載到本地。如果該套裝軟體需要其它套裝軟體才能正常執行──如本例一樣
|
| 317 |
──APT會做關聯性檢查並自動安裝所關聯套裝軟體。如下所示:
|
| 318 |
|
| 319 |
<p>
|
| 320 |
<example>
|
| 321 |
# apt-get install nautilus
|
| 322 |
Reading Package Lists... Done
|
| 323 |
Building Dependency Tree... Done
|
| 324 |
The following extra packages will be installed:
|
| 325 |
bonobo libmedusa0 libnautilus0
|
| 326 |
The following NEW packages will be installed:
|
| 327 |
bonobo libmedusa0 libnautilus0 nautilus
|
| 328 |
0 packages upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
|
| 329 |
Need to get 8329kB of archives. After unpacking 17.2MB will be used.
|
| 330 |
Do you want to continue? [Y/n]
|
| 331 |
</example>
|
| 332 |
|
| 333 |
<p>
|
| 334 |
<tt>nautilus</tt>套裝軟體需要參照共享函式庫,因此APT會從鏡像來源處下載相關共
|
| 335 |
享函式庫,如果你在<tt>apt-get</tt>命令行中手動指定了這些共享函式庫的名稱,
|
| 336 |
APT不會詢問你是否要繼續;它會自動認為你希望安裝所有這些套裝軟體。
|
| 337 |
<p>
|
| 338 |
也就是說APT只會在安裝那些沒有在命令行中指定的套裝軟體時提示確認。
|
| 339 |
<p>
|
| 340 |
下列apt-get選項也許對你有用:
|
| 341 |
|
| 342 |
<p>
|
| 343 |
<example>
|
| 344 |
-h 這個幫助資訊
|
| 345 |
-d 只下載──不安裝或解壓檔案
|
| 346 |
-f 即便完整性檢查失敗了仍然繼續
|
| 347 |
-s 不做什麼。只是按順序類比
|
| 348 |
-y 對於所有問題都假定為Yes,不詢問
|
| 349 |
-u 顯示一系列已經將要更新的包
|
| 350 |
</example>
|
| 351 |
|
| 352 |
<p>
|
| 353 |
可以用一條命令安裝多個套裝軟體。包檔案從網路上下載到本地
|
| 354 |
<tt>/var/cache/apt/archives</tt>目錄,稍後再安裝。
|
| 355 |
<p>
|
| 356 |
你可以用同樣的命令行刪除指定套裝軟體,只需在套裝軟體名稱後緊跟一個“-”,如下所示:
|
| 357 |
|
| 358 |
<p>
|
| 359 |
<example>
|
| 360 |
# apt-get install nautilus gnome-panel-
|
| 361 |
Reading Package Lists... Done
|
| 362 |
Building Dependency Tree... Done
|
| 363 |
The following extra packages will be installed:
|
| 364 |
bonobo libmedusa0 libnautilus0
|
| 365 |
The following packages will be REMOVED:
|
| 366 |
gnome-applets gnome-panel gnome-panel-data gnome-session
|
| 367 |
The following NEW packages will be installed:
|
| 368 |
bonobo libmedusa0 libnautilus0 nautilus
|
| 369 |
0 packages upgraded, 4 newly installed, 4 to remove and 1 not upgraded.
|
| 370 |
Need to get 8329kB of archives. After unpacking 2594kB will be used.
|
| 371 |
Do you want to continue? [Y/n]
|
| 372 |
</example>
|
| 373 |
|
| 374 |
<p>
|
| 375 |
參考<ref id="remove">一節以獲得更多的關於刪除套裝軟體的資訊。
|
| 376 |
<p>
|
| 377 |
假如你不小心損壞了已安裝的套裝軟體而想修復它,或是只有只有想重新安裝套裝軟體中某
|
| 378 |
些檔案的最新版本,這是可以做到的,你可以用如下的<tt>--reinstall</tt>選項:
|
| 379 |
|
| 380 |
<p>
|
| 381 |
<example>
|
| 382 |
# apt-get --reinstall install gdm
|
| 383 |
Reading Package Lists... Done
|
| 384 |
Building Dependency Tree... Done
|
| 385 |
0 packages upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 1 not upgraded.
|
| 386 |
Need to get 0B/182kB of archives. After unpacking 0B will be used.
|
| 387 |
Do you want to continue? [Y/n]
|
| 388 |
</example>
|
| 389 |
</sect>
|
| 390 |
|
| 391 |
<sect id="remove">移除套裝軟體
|
| 392 |
<p>
|
| 393 |
如果你不再使用某些套裝軟體,你可以用APT將其從系統中刪除。要刪除套裝軟體只需
|
| 394 |
輸入:<tt>apt-get remove package</tt>。如下所示:
|
| 395 |
|
| 396 |
<p>
|
| 397 |
<example>
|
| 398 |
# apt-get remove gnome-panel
|
| 399 |
Reading Package Lists... Done
|
| 400 |
Building Dependency Tree... Done
|
| 401 |
The following packages will be REMOVED:
|
| 402 |
gnome-applets gnome-panel gnome-panel-data gnome-session
|
| 403 |
0 packages upgraded, 0 newly installed, 4 to remove and 1 not upgraded.
|
| 404 |
Need to get 0B of archives. After unpacking 14.6MB will be freed.
|
| 405 |
Do you want to continue? [Y/n]
|
| 406 |
</example>
|
| 407 |
|
| 408 |
<p>
|
| 409 |
由上例可知,APT會關注那些與被刪除的套裝軟體有依賴關係的套裝軟體。使用APT刪除
|
| 410 |
一個套裝軟體將會連帶刪除那些與該套裝軟體有依賴關係的套裝軟體。
|
| 411 |
|
| 412 |
<p>
|
| 413 |
上例中執行<prgn>apt-get</prgn>會刪除指定套裝軟體以及與之有依賴關係的軟體
|
| 414 |
包,但它們的組態檔案,如果有的話,會完好無損地保留在系統裡。如果想徹底刪
|
| 415 |
除這些包及其組態檔案,執行:
|
| 416 |
|
| 417 |
<p>
|
| 418 |
<example>
|
| 419 |
# apt-get --purge remove gnome-panel
|
| 420 |
Reading Package Lists... Done
|
| 421 |
Building Dependency Tree... Done
|
| 422 |
The following packages will be REMOVED:
|
| 423 |
gnome-applets* gnome-panel* gnome-panel-data* gnome-session*
|
| 424 |
0 packages upgraded, 0 newly installed, 4 to remove and 1 not upgraded.
|
| 425 |
Need to get 0B of archives. After unpacking 14.6MB will be freed.
|
| 426 |
Do you want to continue? [Y/n]
|
| 427 |
</example>
|
| 428 |
|
| 429 |
<p>
|
| 430 |
注意:套裝軟體名字後面的*表示該套裝軟體所有的組態檔案也將被刪除。
|
| 431 |
<p>
|
| 432 |
就像<tt>install</tt>時一樣,你可以在<tt>remove</tt>命令中用一個符號來指
|
| 433 |
定安裝某個套裝軟體。在刪除套裝軟體時,如果你在套裝軟體名字後面緊跟一個
|
| 434 |
“<tt>+</tt>”,那麼該套裝軟體就會被安裝而不是刪除。
|
| 435 |
|
| 436 |
<p>
|
| 437 |
<example>
|
| 438 |
# apt-get --purge remove gnome-panel nautilus+
|
| 439 |
Reading Package Lists... Done
|
| 440 |
Building Dependency Tree... Done
|
| 441 |
The following extra packages will be installed:
|
| 442 |
bonobo libmedusa0 libnautilus0 nautilus
|
| 443 |
The following packages will be REMOVED:
|
| 444 |
gnome-applets* gnome-panel* gnome-panel-data* gnome-session*
|
| 445 |
The following NEW packages will be installed:
|
| 446 |
bonobo libmedusa0 libnautilus0 nautilus
|
| 447 |
0 packages upgraded, 4 newly installed, 4 to remove and 1 not upgraded.
|
| 448 |
Need to get 8329kB of archives. After unpacking 2594kB will be used.
|
| 449 |
Do you want to continue? [Y/n]
|
| 450 |
</example>
|
| 451 |
|
| 452 |
<p>
|
| 453 |
注意,<prgn>apt-get</prgn>列出了那些將要被安裝的額外套裝軟體(即保證該軟體
|
| 454 |
包正常執行的其它套裝軟體)和將要被刪除關聯套裝軟體,然後,再次列出了將要被安
|
| 455 |
裝的套裝軟體(包括了額外的包)。
|
| 456 |
</sect>
|
| 457 |
|
| 458 |
<sect id="upgrade">更新套裝軟體
|
| 459 |
<p>
|
| 460 |
套裝軟體更新是APT最成功的特點。只需一條命令即可完成更新:
|
| 461 |
<tt>apt-get upgrade</tt>。你可以使用這條命令從相同版本號的發佈版中更新
|
| 462 |
套裝軟體,也可以從新版本號的發佈版中更新套裝軟體,盡管實作後一種更新的推薦
|
| 463 |
命令為<tt>apt-get dist-upgrade</tt>;詳情請參考<ref id="dist-upgrade">。
|
| 464 |
<p>
|
| 465 |
在執行該命令時加上<tt>-u</tt>選項很有用。這個選項讓APT顯示完整的可更新
|
| 466 |
套裝軟體列表。不加這個選項,你就只能盲目地更新。APT會下載每個套裝軟體的最新
|
| 467 |
更新版本,然後以合理的次序安裝它們。注意在執行該命令前應先執行
|
| 468 |
<tt>apt-get update</tt>更新資料庫。詳情請參考<ref id="update">。請看下
|
| 469 |
面的例子:
|
| 470 |
|
| 471 |
<p>
|
| 472 |
<example>
|
| 473 |
# apt-get -u upgrade
|
| 474 |
Reading Package Lists... Done
|
| 475 |
Building Dependency Tree... Done
|
| 476 |
The following packages have been kept back
|
| 477 |
cpp gcc lilo
|
| 478 |
The following packages will be upgraded
|
| 479 |
adduser ae apt autoconf debhelper dpkg-dev esound esound-common ftp indent
|
| 480 |
ipchains isapnptools libaudiofile-dev libaudiofile0 libesd0 libesd0-dev
|
| 481 |
libgtk1.2 libgtk1.2-dev liblockfile1 libnewt0 liborbit-dev liborbit0
|
| 482 |
libstdc++2.10-glibc2.2 libtiff3g libtiff3g-dev modconf orbit procps psmisc
|
| 483 |
29 packages upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
|
| 484 |
Need to get 5055B/5055kB of archives. After unpacking 1161kB will be used.
|
| 485 |
Do you want to continue? [Y/n]
|
| 486 |
</example>
|
| 487 |
|
| 488 |
<p>
|
| 489 |
整個更新程序非常簡單。注意在本例中頭幾行,<tt>apt-get</tt>報告有些套裝軟體
|
| 490 |
的更新被<tt>kept back</tt>,這表明這些套裝軟體的更新版本因故無法安裝,可能
|
| 491 |
的原因有關聯不同步(目前沒有供下載的新版本關聯包)或關聯延伸(需要安裝新的
|
| 492 |
關聯包以配合新版套裝軟體)。
|
| 493 |
<p>
|
| 494 |
對於第一種原因沒有很好的解決方法,對於第二次原因,執行<tt>apt-get intall
|
| 495 |
</tt>安裝所需的新關聯包就可以。另一個更好的解決方法就是使用<tt>dist-upgrade
|
| 496 |
</tt>。詳情請參考<ref id="dist-upgrade">。
|
| 497 |
</sect>
|
| 498 |
|
| 499 |
<sect id="dist-upgrade">升級到新版本
|
| 500 |
<p>
|
| 501 |
APT的絕活就是讓你一次就完成整個系統的更新,不論是通過Internet還是通過光
|
| 502 |
槃檔案(購買的碟片或下載的ISO鏡像檔案)。
|
| 503 |
<p>
|
| 504 |
它也可以用來更新那些關聯關係發生改變的套裝軟體。即如前所述的那些使用<tt>
|
| 505 |
apt-get upgrade</tt>時被不被更新(kept back)的套裝軟體。
|
| 506 |
<p>
|
| 507 |
例如,假設你目前使用的Debian為stable revision 0,而你購買了revision 3的
|
| 508 |
新版Debian,你可以使用APT從新光碟上升級你的系統。使用apt-cdrom(參考<ref
|
| 509 |
id="cdrom">)將光碟加載到<tt>/etc/apt/sources.list</tt>中,然後執行<tt>
|
| 510 |
apt-get dist-upgrade</tt>。
|
| 511 |
<p>
|
| 512 |
請注意,APT總是搜索最新版本的套裝軟體,因此,如果一個套裝軟體在你的
|
| 513 |
<tt>/etc/apt/sources.list</tt>中所列的版本比光碟上所列的版本要新,那麼
|
| 514 |
APT會下載其中的套裝軟體而不是使用光碟上的套裝軟體。
|
| 515 |
<p>
|
| 516 |
在<ref id="upgrade">節的例子中,我們看到有些包被<tt>kept back</tt>了,現
|
| 517 |
在我們就用<tt>dist-upgrade</tt>方法來解決這個問題:
|
| 518 |
|
| 519 |
<p>
|
| 520 |
<example>
|
| 521 |
# apt-get -u dist-upgrade
|
| 522 |
Reading Package Lists... Done
|
| 523 |
Building Dependency Tree... Done
|
| 524 |
Calculating Upgrade... Done
|
| 525 |
The following NEW packages will be installed:
|
| 526 |
cpp-2.95 cron exim gcc-2.95 libident libopenldap-runtime libopenldap1
|
| 527 |
libpcre2 logrotate mailx
|
| 528 |
The following packages have been kept back
|
| 529 |
lilo
|
| 530 |
The following packages will be upgraded
|
| 531 |
adduser ae apt autoconf cpp debhelper dpkg-dev esound esound-common ftp gcc
|
| 532 |
indent ipchains isapnptools libaudiofile-dev libaudiofile0 libesd0
|
| 533 |
libesd0-dev libgtk1.2 libgtk1.2-dev liblockfile1 libnewt0 liborbit-dev
|
| 534 |
liborbit0 libstdc++2.10-glibc2.2 libtiff3g libtiff3g-dev modconf orbit
|
| 535 |
procps psmisc
|
| 536 |
31 packages upgraded, 10 newly installed, 0 to remove and 1 not upgraded.
|
| 537 |
Need to get 0B/7098kB of archives. After unpacking 3118kB will be used.
|
| 538 |
Do you want to continue? [Y/n]
|
| 539 |
</example>
|
| 540 |
|
| 541 |
<p>
|
| 542 |
注意現在那些套裝軟體將會被更新,那些新的關聯套裝軟體也會被安裝。但是lilo仍被
|
| 543 |
<tt>kept back</tt>,可能還存在一些比建立新關聯更棘手的問題,我們通過如下
|
| 544 |
方法確定問題所在:
|
| 545 |
|
| 546 |
<p>
|
| 547 |
<example>
|
| 548 |
# apt-get -u install lilo
|
| 549 |
Reading Package Lists... Done
|
| 550 |
Building Dependency Tree... Done
|
| 551 |
The following extra packages will be installed:
|
| 552 |
cron debconf exim libident libopenldap-runtime libopenldap1 libpcre2
|
| 553 |
logrotate mailx
|
| 554 |
The following packages will be REMOVED:
|
| 555 |
debconf-tiny
|
| 556 |
The following NEW packages will be installed:
|
| 557 |
cron debconf exim libident libopenldap-runtime libopenldap1 libpcre2
|
| 558 |
logrotate mailx
|
| 559 |
The following packages will be upgraded
|
| 560 |
lilo
|
| 561 |
1 packages upgraded, 9 newly installed, 1 to remove and 31 not upgraded.
|
| 562 |
Need to get 225kB/1179kB of archives. After unpacking 2659kB will be used.
|
| 563 |
Do you want to continue? [Y/n]
|
| 564 |
</example>
|
| 565 |
|
| 566 |
<p>
|
| 567 |
檢視上述提示資訊可知,lilo與<package>debconf-tiny</package>包產生了一個
|
| 568 |
新衝突,這表明除非刪除debconf-tiny,否則將無法安裝(或更新)lilo。
|
| 569 |
<p>
|
| 570 |
想知道該保留或刪除哪些套裝軟體,你可以使用:
|
| 571 |
|
| 572 |
<p>
|
| 573 |
<example>
|
| 574 |
# apt-get -o Debug::pkgProblemResolver=yes dist-upgrade
|
| 575 |
Reading Package Lists... Done
|
| 576 |
Building Dependency Tree... Done
|
| 577 |
Calculating Upgrade... Starting
|
| 578 |
Starting 2
|
| 579 |
Investigating python1.5
|
| 580 |
Package python1.5 has broken dep on python1.5-base
|
| 581 |
Considering python1.5-base 0 as a solution to python1.5 0
|
| 582 |
Holding Back python1.5 rather than change python1.5-base
|
| 583 |
Investigating python1.5-dev
|
| 584 |
Package python1.5-dev has broken dep on python1.5
|
| 585 |
Considering python1.5 0 as a solution to python1.5-dev 0
|
| 586 |
Holding Back python1.5-dev rather than change python1.5
|
| 587 |
Try to Re-Instate python1.5-dev
|
| 588 |
Done
|
| 589 |
Done
|
| 590 |
The following packages have been kept back
|
| 591 |
gs python1.5-dev
|
| 592 |
0 packages upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
|
| 593 |
</example>
|
| 594 |
|
| 595 |
<p>
|
| 596 |
現在,你很容易就知道不能安裝python1.5-dev套裝軟體是因為無法滿足另一個軟體
|
| 597 |
包python1.5的關聯要求。
|
| 598 |
|
| 599 |
</sect>
|
| 600 |
|
| 601 |
<sect id="clean">移除無用套裝軟體檔案:apt-get clean and autoclean
|
| 602 |
<p>
|
| 603 |
當你需要安裝某個套裝軟體時,APT從/etc/apt/sources.list中所列的主機下載所
|
| 604 |
需的檔案,將它們保存到本機軟體庫(<file>/var/cache/apt/archives/</file>),
|
| 605 |
然後開始安裝,參考<ref id="install">。
|
| 606 |
<p>
|
| 607 |
本地軟體庫會不斷膨脹占用大量硬碟空間,幸運的是,APT提供了工具來管理本地
|
| 608 |
軟體庫:<prgn>apt-get</prgn>的<tt>clean</tt>方法和<tt>autoclean</tt>方法。
|
| 609 |
<p>
|
| 610 |
<prgn>apt-get clean</prgn>將刪除<file>/var/cache/apt/archives</file>目錄
|
| 611 |
和<file>/var/cache/apt/archives/partial</file>目錄下鎖檔案以外的所有檔案。
|
| 612 |
這樣以來,當你需要再次安裝某個套裝軟體時,APT將重新下載它。
|
| 613 |
<p>
|
| 614 |
<prgn>apt-get autoclean</prgn>只有刪除那些不需要再次下載的檔案。
|
| 615 |
<p>
|
| 616 |
下面這個例子顯示了apt-get autoclean如何工作:
|
| 617 |
|
| 618 |
<p>
|
| 619 |
<example>
|
| 620 |
# ls /var/cache/apt/archives/logrotate* /var/cache/apt/archives/gpm*
|
| 621 |
logrotate_3.5.9-7_i386.deb
|
| 622 |
logrotate_3.5.9-8_i386.deb
|
| 623 |
gpm_1.19.6-11_i386.deb
|
| 624 |
</example>
|
| 625 |
|
| 626 |
<p>
|
| 627 |
在/var/cache/apt/archives目錄下有兩個不同版本的<package>logrotate</package>
|
| 628 |
套裝軟體檔案以及一個<package>gpm</package>套裝軟體檔案。
|
| 629 |
|
| 630 |
<p>
|
| 631 |
<example>
|
| 632 |
# apt-show-versions -p logrotate
|
| 633 |
logrotate/stable uptodate 3.5.9-8
|
| 634 |
# apt-show-versions -p gpm
|
| 635 |
gpm/stable upgradeable from 1.19.6-11 to 1.19.6-12
|
| 636 |
</example>
|
| 637 |
|
| 638 |
<p>
|
| 639 |
<prgn>apt-show-versions</prgn>顯示<file>logrotate_3.5.9-8_i386.deb</file>
|
| 640 |
提供了<package>logrotate</package>的升級版本,所以
|
| 641 |
<file>logrotate_3.5.9-7_i386.deb</file>沒用了。同樣
|
| 642 |
<file>gpm_1.19.6-11_i386.deb</file>也沒有用了,因為可以下載該套裝軟體的更新
|
| 643 |
版本。
|
| 644 |
|
| 645 |
<p>
|
| 646 |
<example>
|
| 647 |
# apt-get autoclean
|
| 648 |
Reading Package Lists... Done
|
| 649 |
Building Dependency Tree... Done
|
| 650 |
Del gpm 1.19.6-11 [145kB]
|
| 651 |
Del logrotate 3.5.9-7 [26.5kB]
|
| 652 |
</example>
|
| 653 |
|
| 654 |
<p>總之,apt-get autoclean只有刪除那些過時的檔案。參考
|
| 655 |
<ref id="apt-show-versions">以了解apt-show-versions的更多詳情。
|
| 656 |
</sect>
|
| 657 |
|
| 658 |
<sect id="dselect-upgrade">在dselect中操作APT
|
| 659 |
<p>
|
| 660 |
<prgn>dselect</prgn>工具幫助使用者選取想要安裝的Debian套裝軟體。它有點複雜甚
|
| 661 |
至令人望而生厭,但經過實踐你就能掌握它恐怖的終端機界面。
|
| 662 |
|
| 663 |
<p>
|
| 664 |
dselect進階功能之一就是它知道利用Debian套裝軟體的“推薦”和“建議”能力。(Debian軟
|
| 665 |
件包有一種能力:推薦或建議系統在安裝自己的同時,安裝別的套裝軟體以配合自身的
|
| 666 |
工作,當然這些推薦的套裝軟體不一定是必須的;而dselect工具可以識別和利用這個能
|
| 667 |
力,使用dselect時你就能體會到。譯者注)以root身份執行<tt>dselect</tt>,進入程
|
| 668 |
序後選擇apt作為連線方式(access)。該步驟不是必須的,但如果你沒有光碟機而且想通
|
| 669 |
過Internet下載安裝套裝軟體,這是使用dselect的最好方法。
|
| 670 |
<p>
|
| 671 |
想深入學習dselect的使用方式,請到Debian网站查閱dselect文件頁面<url
|
| 672 |
id="http://www.debian.org/doc/ddp" name="http://www.debian.org/doc/ddp">.
|
| 673 |
<p>
|
| 674 |
|
| 675 |
在dselect中選好了套裝軟體後,執行:
|
| 676 |
|
| 677 |
<p>
|
| 678 |
<example>
|
| 679 |
# apt-get -u dselect-upgrade
|
| 680 |
</example>
|
| 681 |
|
| 682 |
<p>
|
| 683 |
如下例所示:
|
| 684 |
|
| 685 |
<p>
|
| 686 |
<example>
|
| 687 |
# apt-get -u dselect-upgrade
|
| 688 |
Reading Package Lists... Done
|
| 689 |
Building Dependency Tree... Done
|
| 690 |
The following packages will be REMOVED:
|
| 691 |
lbxproxy
|
| 692 |
The following NEW packages will be installed:
|
| 693 |
bonobo console-tools-libs cpp-3.0 enscript expat fingerd gcc-3.0
|
| 694 |
gcc-3.0-base icepref klogd libdigest-md5-perl libfnlib0 libft-perl
|
| 695 |
libgc5-dev libgcc300 libhtml-clean-perl libltdl0-dev libsasl-modules
|
| 696 |
libstdc++3.0 metamail nethack proftpd-doc psfontmgr python-newt talk tidy
|
| 697 |
util-linux-locales vacation xbill xplanet-images
|
| 698 |
The following packages will be upgraded
|
| 699 |
debian-policy
|
| 700 |
1 packages upgraded, 30 newly installed, 1 to remove and 0 not upgraded.
|
| 701 |
Need to get 7140kB of archives. After unpacking 16.3MB will be used.
|
| 702 |
Do you want to continue? [Y/n]
|
| 703 |
</example>
|
| 704 |
|
| 705 |
<p>
|
| 706 |
|
| 707 |
比較一下我們在相同系統上執行apt-get dist-upgrade時的情形:
|
| 708 |
|
| 709 |
<p>
|
| 710 |
<example>
|
| 711 |
# apt-get -u dist-upgrade
|
| 712 |
Reading Package Lists... Done
|
| 713 |
Building Dependency Tree... Done
|
| 714 |
Calculating Upgrade... Done
|
| 715 |
The following packages will be upgraded
|
| 716 |
debian-policy
|
| 717 |
1 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
|
| 718 |
Need to get 421kB of archives. After unpacking 25.6kB will be freed.
|
| 719 |
Do you want to continue? [Y/n]
|
| 720 |
</example>
|
| 721 |
|
| 722 |
<p>
|
| 723 |
我們看到在前例中許多套裝軟體被安裝是其它套裝軟體“推薦”或“建議”的結果。另外一
|
| 724 |
些套裝軟體被安裝或刪除(例如lbxproxy套裝軟體)是我們通過dselect工具作出的決定。
|
| 725 |
由此可見dselect與APT結合起來將是一個功能強大的工具。
|
| 726 |
</sect>
|
| 727 |
|
| 728 |
<sect id="default-version">如何保持一個混合系統
|
| 729 |
<p>
|
| 730 |
人們有時會對這種情況有興趣──使用一個版本的Debain作為其主發行版,但從另一
|
| 731 |
個分支上安裝一個或多個包。
|
| 732 |
<p>
|
| 733 |
要設定你的Debian主版本,應當修改<file>/etc/apt/apt.conf</file>檔案,並加
|
| 734 |
入:
|
| 735 |
<p>
|
| 736 |
<example>
|
| 737 |
APT::Default-Release "<var>version</var>";
|
| 738 |
</example>
|
| 739 |
<p>
|
| 740 |
其中<var>version</var>是你希望作為主發行版使用的Debian版本。你可以使用的
|
| 741 |
版本有<tt>stable</tt>、<tt>testing</tt>和<tt>unstable</tt>。
|
| 742 |
要從另外一個版本中安裝套裝軟體,你必須按照如下方式執行APT:
|
| 743 |
|
| 744 |
<p>
|
| 745 |
<example>
|
| 746 |
# apt-get -t <var>distribution</var> install <var>package</var>
|
| 747 |
</example>
|
| 748 |
<p>
|
| 749 |
|
| 750 |
為了使其可以個工作,在你的<file>/etc/apt/sources.list</file>中至少有一行
|
| 751 |
是關於你要使用的那個版本的,而且要使用的套裝軟體也必須存在於該版本中。
|
| 752 |
<p>
|
| 753 |
你也可以要求使用某個特定把本的套裝軟體,如下所示:
|
| 754 |
|
| 755 |
<example>
|
| 756 |
# apt-get install <var>package</var>=<var>version</var>
|
| 757 |
</example>
|
| 758 |
|
| 759 |
例如,下面的命令將會安裝<tt>2.2.4-1</tt>版的<package>nautilus</package>軟
|
| 760 |
件包:
|
| 761 |
|
| 762 |
<example>
|
| 763 |
# apt-get install nautilus=2.2.4-1
|
| 764 |
</example>
|
| 765 |
|
| 766 |
<p>
|
| 767 |
<em>重要資訊</em>:最新版的Debian套裝軟體首先會上傳到“unstable”發佈版中,
|
| 768 |
這個發佈版包含了套裝軟體所有變更階段,無論是小修小補還是影響到眾多套裝軟體
|
| 769 |
乃至整個系統的重大修改。所以,新手和那些強調系統穩定性的使用者<em>不</em>
|
| 770 |
會使用這個發佈版。
|
| 771 |
<p>
|
| 772 |
“testing”發佈版比起“unstable”發佈版,多注重了些系統穩定性,但正式執行的
|
| 773 |
系統應當使用“stable”發佈版。
|
| 774 |
</sect>
|
| 775 |
|
| 776 |
<sect id="apt-show-versions">如何從Debian的專用版本下升級套裝軟體
|
| 777 |
<p>
|
| 778 |
<prgn>apt-show-versions</prgn>提供了一個安全的途徑,讓那些使用混合系統的
|
| 779 |
使用者放心升級他們的系統,不必擔心升級會將原來屬於stable的包升級成了unstable包。
|
| 780 |
例如,在安裝了<package>apt-show-versions</package>套裝軟體之後,
|
| 781 |
使用這條命令將只升級你的unstable套裝軟體:
|
| 782 |
<p>
|
| 783 |
<example>
|
| 784 |
# apt-get install `apt-show-versions -u -b | grep unstable | cut -d ' ' -f 1`
|
| 785 |
</example>
|
| 786 |
</sect>
|
| 787 |
|
| 788 |
<sect id="pin">如何維護已安裝套裝軟體的多個版本(複雜)
|
| 789 |
How to keep specific versions of packages installed (complex)
|
| 790 |
<p>
|
| 791 |
你可能會遇到這種情況,變更了某個套裝軟體中的一些檔案,但你沒有時間或根本就
|
| 792 |
不想將這些變更引入到新版本中。或是,你將系統升級到3.0,但仍想繼續使用Debian
|
| 793 |
2.2下的某個套裝軟體。你可以“釘住”這個版本,這樣它就不會被更新了。
|
| 794 |
<p>
|
| 795 |
操作起來十分簡單,你只需編輯<tt>/etc/apt/preferences</tt>檔案。
|
| 796 |
<tt>/etc/apt/preferences</tt>.
|
| 797 |
<p>
|
| 798 |
檔案格式很簡單:
|
| 799 |
<p>
|
| 800 |
<example>
|
| 801 |
Package: <package>
|
| 802 |
Pin: <pin definition>
|
| 803 |
Pin-Priority: <pin's priority>
|
| 804 |
</example>
|
| 805 |
<p>
|
| 806 |
每個條目都要以空白行與其它條目分割開。例如,我對<package>sylpheed</package>
|
| 807 |
套裝軟體做了某些修改以使用“reply-to-list”功能,其版本為0.4.99。我想保留這
|
| 808 |
些修改不被更新,可加上:
|
| 809 |
<p>
|
| 810 |
<example>
|
| 811 |
Package: sylpheed
|
| 812 |
Pin: version 0.4.99*
|
| 813 |
</example>
|
| 814 |
<p>
|
| 815 |
注意我用了一個<tt>*</tt>(星號)。這是一個“萬用字元”;它表明我希望“釘住”所有
|
| 816 |
以0.4.99打頭的版本(以防它們被下載並安裝到我機器上。pin控制的是伺服器端的
|
| 817 |
更新套裝軟體而非本地的已安裝套裝軟體。譯者注)。因為Debian使用“Debian版本號”
|
| 818 |
為其套裝軟體定版本,我不想進行所有這些版本的升級,如果不用萬用字元,
|
| 819 |
那麼0.4.99-1版或0.4.99-10版只要一出爐系統就會安裝它們。如果你修改了套裝軟體,
|
| 820 |
你一定不希望這麼做。
|
| 821 |
<p>
|
| 822 |
Pin的優先等級幫助我們檢查一個與“Packages:”和“Pin:”相符合的套裝軟體是否應該被
|
| 823 |
安裝。當優先等級比較高時,符合的套裝軟體將會被安裝。你可以查閱<manref
|
| 824 |
name="apt_preferences" section="7">,其中有關於優先等級的詳細討論,但通過
|
| 825 |
一些簡單的例子也可以了解基本的概念。下面就說明了在上面的sylpheed例子中設
|
| 826 |
定優先等級網域的效果。
|
| 827 |
</p>
|
| 828 |
<p>
|
| 829 |
<taglist>
|
| 830 |
<tag>1001</tag>
|
| 831 |
<item>
|
| 832 |
Sylpheed 0.4.99永遠不會被apt取代。如果可能,apt甚至會用0.4.99版取代已經
|
| 833 |
安裝的更高的版本呢。只有那些優先等級比1000大的套裝軟體才會降級。
|
| 834 |
</item>
|
| 835 |
<tag>1000</tag>
|
| 836 |
<item>
|
| 837 |
除了不會將高版本降級以外,與1001的效果相同。
|
| 838 |
</item>
|
| 839 |
<tag>990</tag>
|
| 840 |
<item>
|
| 841 |
版本0.4.99只會被偏好發佈系列中高版本的的套裝軟體取代,偏好發行版由變數
|
| 842 |
“APT::Default-Release”定義(參考<ref id="default-version">。
|
| 843 |
</item>
|
| 844 |
<tag>500</tag>
|
| 845 |
<item>
|
| 846 |
任何發佈系列中比0.4.99版本高的sylpheed都會被安裝,但相對於低版本而言,仍然
|
| 847 |
建議使用0.4.99。
|
| 848 |
</item>
|
| 849 |
<tag>100</tag>
|
| 850 |
<item>
|
| 851 |
任何發佈系列中高版本的sylpheed都會被安裝;因此只有沒有其它版本可以安裝時
|
| 852 |
才會安裝0.4.99。已安裝包的優先等級。
|
| 853 |
</item>
|
| 854 |
<tag>-1</tag>
|
| 855 |
<item>
|
| 856 |
負的優先等級也是允許的,它會組織0.4.99版被安裝。
|
| 857 |
</item>
|
| 858 |
</taglist>
|
| 859 |
<p>
|
| 860 |
釘子也可以用來指定套裝軟體的<tt>version</tt>、<tt>release</tt>或
|
| 861 |
<tt>origin</tt>。
|
| 862 |
<p>
|
| 863 |
我們已經看到,釘在一個<tt>version</tt>上,可以使用具體的版本號,也可以使
|
| 864 |
用萬用字元一次指定多個版本。
|
| 865 |
<!-- what's available? standard shell globs? ?*[] or more? -->
|
| 866 |
<p>
|
| 867 |
<tt>release</tt>選項依賴於APT倉庫上的或是CD中的Release檔案。如果你使用的
|
| 868 |
APT倉庫並沒有提供這個檔案,這個選項就沒有任何用處了。你可以在
|
| 869 |
<tt>/var/lib/apt/lists/</tt>中看到Release檔案的內容。release的參數是:
|
| 870 |
<tt>a</tt>(存檔)、<tt>c</tt>(部件)、<tt>v</tt>(版本)、<tt>o</tt>(起來源)
|
| 871 |
和<tt>l</tt>(標籤)。
|
| 872 |
<p>
|
| 873 |
例如:
|
| 874 |
<p>
|
| 875 |
<example>
|
| 876 |
Package: *
|
| 877 |
Pin: release v=2.2*,a=stable,c=main,o=Debian,l=Debian
|
| 878 |
Pin-Priority: 1001
|
| 879 |
</example>
|
| 880 |
<p>
|
| 881 |
在這個例子中,我們選擇了Debian版本2.2*(可以是2.2r2、2.2r3──這些版本中通常
|
| 882 |
包含了對安全問題的修復和其它重要更新),<tt>stable</tt>倉庫,<tt>main</tt>
|
| 883 |
(相應的還有<tt>contrib</tt>或是<tt>non-free</tt>)區段、起來源和標籤都是
|
| 884 |
Debian。origin(o=)定義了誰製作了這個Release檔案,label(l=)定義了發行版的
|
| 885 |
名字:Debian自己就使用Debian而Progeny則使用Progeny。Release檔案的例子如下
|
| 886 |
所示:
|
| 887 |
<p>
|
| 888 |
<example>
|
| 889 |
$ cat /var/lib/apt/lists/ftp.debian.org.br_debian_dists_potato_main_binary-i386_Release
|
| 890 |
Archive: stable
|
| 891 |
Version: 2.2r3
|
| 892 |
Component: main
|
| 893 |
Origin: Debian
|
| 894 |
Label: Debian
|
| 895 |
Architecture: i386
|
| 896 |
</example>
|
| 897 |
</sect>
|
| 898 |
</chapt>
|
| 899 |
|
| 900 |
<chapt id="helpers">幾個非常有用的工具
|
| 901 |
<sect id="equivs">如何安裝本地編譯的套裝軟體:equivs
|
| 902 |
<p>
|
| 903 |
有時,使用者想使用某些軟體的特殊版本,它們只以來源程式碼的形式存在,沒有現成
|
| 904 |
的Debian套裝軟體。套裝軟體管理系統在處理這類事務時可能會出問題。假設你想編
|
| 905 |
譯新版本的信件伺服器,所有的事情都很正常,但是Debian中的很多套裝軟體是依
|
| 906 |
賴於MTA(信件傳輸代理)的。由於你是自己手動編譯安裝軟體,套裝軟體管理系統
|
| 907 |
對此一無所知。
|
| 908 |
<p>
|
| 909 |
現在是<package>equivs</package>登台的時候了。用它來安裝套裝軟體,它所做
|
| 910 |
的工作就是建立一個新的空套裝軟體來實作關聯,讓套裝軟體管理系統相信所有的依
|
| 911 |
賴關係都可以滿足。
|
| 912 |
<p>
|
| 913 |
在我們開始以前,我必須提醒你,編譯某個軟體最安全的方法是對該軟體現有
|
| 914 |
的Debian套裝軟體進行修改後重新編譯,如果你並不知道你正在干什麼,勸你不要使
|
| 915 |
用equivs取代關聯包。更多資訊請參考<ref id="sourcehandling">。
|
| 916 |
<p>
|
| 917 |
繼續上面的例子,你安裝好了新編譯的<prgn>postfix</prgn>,接下來打算安裝
|
| 918 |
<package>mutt</package>。突然你發現<package>mutt</package>想安裝另外一
|
| 919 |
個MTA,但實際上你已經有了你的MTA。
|
| 920 |
<p>
|
| 921 |
前往某個目錄(例如<file>/tmp</file>)執行:
|
| 922 |
|
| 923 |
<p>
|
| 924 |
<example>
|
| 925 |
# equivs-control <var>name</var>
|
| 926 |
</example>
|
| 927 |
|
| 928 |
<p>
|
| 929 |
將<var>name</var>取代為你建立的控制檔案,控制檔案按如下格式建立:
|
| 930 |
|
| 931 |
<p>
|
| 932 |
<example>
|
| 933 |
Section: misc
|
| 934 |
Priority: optional
|
| 935 |
Standards-Version: 3.0.1
|
| 936 |
|
| 937 |
Package: <enter package name; defaults to equivs-dummy>
|
| 938 |
Version: <enter version here; defaults to 1.0>
|
| 939 |
Maintainer: <your name and email address; defaults to username>
|
| 940 |
Pre-Depends: <packages>
|
| 941 |
Depends: <packages>
|
| 942 |
Recommends: <packages>
|
| 943 |
Suggests: <package>
|
| 944 |
Provides: <(virtual)package>
|
| 945 |
Architecture: all
|
| 946 |
Copyright: <copyright file; defaults to GPL2>
|
| 947 |
Changelog: <changelog file; defaults to a generic changelog>
|
| 948 |
Readme: <README.Debian file; defaults to a generic one>
|
| 949 |
Extra-Files: <additional files for the doc directory, comma-separated>
|
| 950 |
Description: <short description; defaults to some wise words>
|
| 951 |
long description and info
|
| 952 |
.
|
| 953 |
second paragraph
|
| 954 |
</example>
|
| 955 |
|
| 956 |
<p>
|
| 957 |
我們只需按自己的需要修改相關專案就行了。檔案中每個項目都描述得很清楚,我
|
| 958 |
們不必在此逐行解釋它們。現在開始修改吧:
|
| 959 |
|
| 960 |
<p>
|
| 961 |
<example>
|
| 962 |
Section: misc
|
| 963 |
Priority: optional
|
| 964 |
Standards-Version: 3.0.1
|
| 965 |
|
| 966 |
Package: mta-local
|
| 967 |
Provides: mail-transport-agent
|
| 968 |
</example>
|
| 969 |
|
| 970 |
<p>
|
| 971 |
行了,就是這樣。<package>mutt</package>依賴於<package>mail-transport-agent
|
| 972 |
</package>,這是所有MTA共同提供的一個虛擬包,我可以簡單地將這個套裝軟體命名
|
| 973 |
為<package>mail-transport-agent</package>,不過我更愿意使用系統的虛擬包方
|
| 974 |
案,使用Provides選項。
|
| 975 |
<p>
|
| 976 |
現在你可以開始組建套裝軟體了:
|
| 977 |
|
| 978 |
<p>
|
| 979 |
<example>
|
| 980 |
# equivs-build <var>name</var>
|
| 981 |
dh_testdir
|
| 982 |
touch build-stamp
|
| 983 |
dh_testdir
|
| 984 |
dh_testroot
|
| 985 |
dh_clean -k
|
| 986 |
# Add here commands to install the package into debian/tmp.
|
| 987 |
touch install-stamp
|
| 988 |
dh_testdir
|
| 989 |
dh_testroot
|
| 990 |
dh_installdocs
|
| 991 |
dh_installchangelogs
|
| 992 |
dh_compress
|
| 993 |
dh_fixperms
|
| 994 |
dh_installdeb
|
| 995 |
dh_gencontrol
|
| 996 |
dh_md5sums
|
| 997 |
dh_builddeb
|
| 998 |
dpkg-deb: building package `<var>name</var>' in `../<var>name</var>_1.0_all.deb'.
|
| 999 |
|
| 1000 |
套裝軟體已經被建立了,注意,套裝軟體是建立在目前目錄中的。
|
| 1001 |
</example>
|
| 1002 |
|
| 1003 |
<p>
|
| 1004 |
然後安裝這個<tt>.deb</tt>檔案。
|
| 1005 |
<p>
|
| 1006 |
眾所周知,<prgn>equivs</prgn>的使用方式很多,譬如你可以建立一個<tt>my-favorites
|
| 1007 |
</tt>套裝軟體,它依賴於你通常安裝的套裝軟體。盡情發揮你的想像力吧,當然還是要小心。
|
| 1008 |
<p>
|
| 1009 |
重要提示:在<file>/usr/share/doc/equivs/examples</file>目錄下有控制檔案
|
| 1010 |
的例子,最好看一下。
|
| 1011 |
</sect>
|
| 1012 |
|
| 1013 |
<sect id="localepurge">移除無用的地區組態(locale)檔案:localepurge
|
| 1014 |
<p>
|
| 1015 |
許多Debian使用者只有在固定地區使用Debian。例如,在巴西的Debian使用者,通常使
|
| 1016 |
用<tt>pt_BR</tt>地區組態檔案而不會關心<tt>es</tt>地區組態檔案。
|
| 1017 |
<p>
|
| 1018 |
對於這類使用者而言<package>localepurge</package>是一個非常有用的工具,你可
|
| 1019 |
以只有保留你目前所用的地區組態檔案,刪除其它無用的檔案,從而釋放大量硬碟空
|
| 1020 |
間。執行<tt>apt-get install localepurge</tt>就行了。
|
| 1021 |
<p>
|
| 1022 |
它組態起來非常容易,debconf的提問將引導使用者一步一步完成設定。在回答第一
|
| 1023 |
個問題時請務必謹慎,如果回答錯了,系統可能刪掉所有的地區組態檔案,包括你
|
| 1024 |
正在使用的這個。複原它們的唯一方法就是重裝那些套裝軟體。
|
| 1025 |
</sect>
|
| 1026 |
|
| 1027 |
<sect id="helper-show-versions">如何知曉哪些套裝軟體可以升級
|
| 1028 |
<p>
|
| 1029 |
<prgn>apt-show-versions</prgn>工具可以告訴你系統中哪些包可以更新以及其它
|
| 1030 |
一些有用的資訊。<tt>-u</tt>選項可以顯示可更新套裝軟體列表:
|
| 1031 |
|
| 1032 |
<p>
|
| 1033 |
<example>
|
| 1034 |
$ apt-show-versions -u
|
| 1035 |
libeel0/unstable upgradeable from 1.0.2-5 to 1.0.2-7
|
| 1036 |
libeel-data/unstable upgradeable from 1.0.2-5 to 1.0.2-7
|
| 1037 |
</example>
|
| 1038 |
</sect>
|
| 1039 |
|
| 1040 |
</chapt>
|
| 1041 |
|
| 1042 |
<chapt id="search">獲取套裝軟體資訊
|
| 1043 |
<p>
|
| 1044 |
有些基於APT系統的前端程序,能十分方便地獲得系統套裝軟體列表,列表包括可安
|
| 1045 |
裝或已安裝的套裝軟體,還可以顯示某套裝軟體屬於哪個section,它的優先等級是多少,
|
| 1046 |
它的說明文件等等。
|
| 1047 |
<p>
|
| 1048 |
但是...在此我們想的學習如何使用APT本身來完成。你如何找出你想要安裝的軟體
|
| 1049 |
包的名稱?
|
| 1050 |
<p>
|
| 1051 |
我們完成這個工作的方法有很多。我們從<tt>apt-cache</tt>開始,APT系統使用
|
| 1052 |
這個程序來維護它的資料庫。下面我們通過一些實際操作來對它做個概覽。
|
| 1053 |
|
| 1054 |
<sect id="cache">獲得套裝軟體名稱
|
| 1055 |
<p>
|
| 1056 |
假設你十分懷念玩Atari 2600的好日子,你決定用APT安裝一個Atari emulator,
|
| 1057 |
隨後再下載幾個游戲,你可以這樣:
|
| 1058 |
|
| 1059 |
<p>
|
| 1060 |
<example>
|
| 1061 |
# apt-cache search atari
|
| 1062 |
atari-fdisk-cross - Partition editor for Atari (running on non-Atari)
|
| 1063 |
circuslinux - The clowns are trying to pop balloons to score points!
|
| 1064 |
madbomber - A Kaboom! clone
|
| 1065 |
tcs - Character set translator.
|
| 1066 |
atari800 - Atari emulator for svgalib/X/curses
|
| 1067 |
stella - Atari 2600 Emulator for X windows
|
| 1068 |
xmess-x - X binaries for Multi-Emulator Super System
|
| 1069 |
</example>
|
| 1070 |
|
| 1071 |
<p>
|
| 1072 |
|
| 1073 |
我們找到了幾個相關的套裝軟體,以及有關的簡單描述。想進一步獲得某個套裝軟體的
|
| 1074 |
詳細資訊,你可以執行:
|
| 1075 |
|
| 1076 |
<p>
|
| 1077 |
<example>
|
| 1078 |
# apt-cache show stella
|
| 1079 |
Package: stella
|
| 1080 |
Priority: extra
|
| 1081 |
Section: non-free/otherosfs
|
| 1082 |
Installed-Size: 830
|
| 1083 |
Maintainer: Tom Lear <tom@trap.mtview.ca.us>
|
| 1084 |
Architecture: i386
|
| 1085 |
Version: 1.1-2
|
| 1086 |
Depends: libc6 (>= 2.1), libstdc++2.10, xlib6g (>= 3.3.5-1)
|
| 1087 |
Filename: dists/potato/non-free/binary-i386/otherosfs/stella_1.1-2.deb
|
| 1088 |
Size: 483430
|
| 1089 |
MD5sum: 11b3e86a41a60fa1c4b334dd96c1d4b5
|
| 1090 |
Description: Atari 2600 Emulator for X windows
|
| 1091 |
Stella is a portable emulator of the old Atari 2600 video-game console
|
| 1092 |
written in C++. You can play most Atari 2600 games message it. The latest
|
| 1093 |
news, code and binaries for Stella can be found at:
|
| 1094 |
http://www4.ncsu.edu/~bwmott/2600
|
| 1095 |
</example>
|
| 1096 |
|
| 1097 |
<p>
|
| 1098 |
螢幕上顯示出這個套裝軟體的詳細資訊及其用途的完整描述。如果你的系統中已安裝
|
| 1099 |
了某個套裝軟體而系統又搜索到它的新版本,系統會將它們的詳細資訊一並列出。如
|
| 1100 |
下例:
|
| 1101 |
|
| 1102 |
<p>
|
| 1103 |
<example>
|
| 1104 |
# apt-cache show lilo
|
| 1105 |
Package: lilo
|
| 1106 |
Priority: important
|
| 1107 |
Section: base
|
| 1108 |
Installed-Size: 271
|
| 1109 |
Maintainer: Russell Coker <russell@coker.com.au>
|
| 1110 |
Architecture: i386
|
| 1111 |
Version: 1:21.7-3
|
| 1112 |
Depends: libc6 (>= 2.2.1-2), debconf (>=0.2.26), logrotate
|
| 1113 |
Suggests: lilo-doc
|
| 1114 |
Conflicts: manpages (<<1.29-3)
|
| 1115 |
Filename: pool/main/l/lilo/lilo_21.7-3_i386.deb
|
| 1116 |
Size: 143052
|
| 1117 |
MD5sum: 63fe29b5317fe34ed8ec3ae955f8270e
|
| 1118 |
Description: LInux LOader - The Classic OS loader can load Linux and others
|
| 1119 |
This Package contains lilo (the installer) and boot-record-images to
|
| 1120 |
install Linux, OS/2, DOS and generic Boot Sectors of other OSes.
|
| 1121 |
.
|
| 1122 |
You can use Lilo to manage your Master Boot Record (message a simple text screen)
|
| 1123 |
or call Lilo from other Boot-Loaders to jump-start the Linux kernel.
|
| 1124 |
|
| 1125 |
Package: lilo
|
| 1126 |
Status: install ok installed
|
| 1127 |
Priority: important
|
| 1128 |
Section: base
|
| 1129 |
Installed-Size: 190
|
| 1130 |
Maintainer: Vincent Renardias <vincent@debian.org>
|
| 1131 |
Version: 1:21.4.3-2
|
| 1132 |
Depends: libc6 (>= 2.1.2)
|
| 1133 |
Recommends: mbr
|
| 1134 |
Suggests: lilo-doc
|
| 1135 |
Description: LInux LOader - The Classic OS loader can load Linux and others
|
| 1136 |
This Package contains lilo (the installer) and boot-record-images to
|
| 1137 |
install Linux, OS/2, DOS and generic Boot Sectors of other OSes.
|
| 1138 |
.
|
| 1139 |
You can use Lilo to manage your Master Boot Record (message a simple text screen)
|
| 1140 |
or call Lilo from other Boot-Loaders to jump-start the Linux kernel.
|
| 1141 |
</example>
|
| 1142 |
|
| 1143 |
<p>
|
| 1144 |
注意,首先列出的是可用套裝軟體,接著列出的是已安裝套裝軟體。獲取某個套裝軟體的
|
| 1145 |
一般資訊可執行:
|
| 1146 |
|
| 1147 |
<p>
|
| 1148 |
<example>
|
| 1149 |
# apt-cache showpkg penguin-command
|
| 1150 |
Package: penguin-command
|
| 1151 |
Versions:
|
| 1152 |
1.4.5-1(/var/lib/apt/lists/download.sourceforge.net_debian_dists_unstable_main_binary-i386_Packages)(/var/lib/dpkg/status)
|
| 1153 |
|
| 1154 |
Reverse Depends:
|
| 1155 |
Dependencies:
|
| 1156 |
1.4.5-1 - libc6 (2 2.2.1-2) libpng2 (0 (null)) libsdl-mixer1.1 (2 1.1.0) libsdl1.1 (0 (null)) zlib1g (2 1:1.1.3)
|
| 1157 |
Provides:
|
| 1158 |
1.4.5-1 -
|
| 1159 |
Reverse Provides:
|
| 1160 |
</example>
|
| 1161 |
|
| 1162 |
<p>
|
| 1163 |
如果只有想了解某套裝軟體的與哪些套裝軟體關聯,可執行:
|
| 1164 |
|
| 1165 |
<p>
|
| 1166 |
<example>
|
| 1167 |
# apt-cache depends penguin-command
|
| 1168 |
penguin-command
|
| 1169 |
Depends: libc6
|
| 1170 |
Depends: libpng2
|
| 1171 |
Depends: libsdl-mixer1.1
|
| 1172 |
Depends: libsdl1.1
|
| 1173 |
Depends: zlib1g
|
| 1174 |
</example>
|
| 1175 |
|
| 1176 |
<p>
|
| 1177 |
總之,有一系列工具可幫助我們找到我們想要的套裝軟體。
|
| 1178 |
</sect>
|
| 1179 |
|
| 1180 |
<sect id="dpkg-search">使用dpkg尋找套裝軟體名稱
|
| 1181 |
<p>
|
| 1182 |
另一個定位套裝軟體的方法是知道套裝軟體中某個關鍵檔案的名稱。例如,你編譯時需
|
| 1183 |
要某個“<tt>.h</tt>”頭檔案,尋找提供該檔案的套裝軟體,你可以執行:
|
| 1184 |
|
| 1185 |
<p>
|
| 1186 |
<example>
|
| 1187 |
# dpkg -S stdio.h
|
| 1188 |
libc6-dev: /usr/include/stdio.h
|
| 1189 |
libc6-dev: /usr/include/bits/stdio.h
|
| 1190 |
perl: /usr/lib/perl/5.6.0/CORE/nostdio.h
|
| 1191 |
</example>
|
| 1192 |
|
| 1193 |
<p>
|
| 1194 |
或是:
|
| 1195 |
|
| 1196 |
<p>
|
| 1197 |
<example>
|
| 1198 |
# dpkg -S /usr/include/stdio.h
|
| 1199 |
libc6-dev: /usr/include/stdio.h
|
| 1200 |
</example>
|
| 1201 |
|
| 1202 |
<p>
|
| 1203 |
解系統中已安裝軟體的套裝軟體名稱十分有用,譬如當你想清理硬碟空間時,可以執行:
|
| 1204 |
|
| 1205 |
<p>
|
| 1206 |
<example>
|
| 1207 |
# dpkg -l | grep mozilla
|
| 1208 |
ii mozilla-browse 0.9.6-7 Mozilla Web Browser
|
| 1209 |
</example>
|
| 1210 |
<p>
|
| 1211 |
這個命令的缺點是它會“截斷”套裝軟體的名字。在上例中,套裝軟體的全稱是
|
| 1212 |
<tt>mozilla-browser</tt>,解決這個問題可以使用<tt>COLUMNS</tt>環境變數:
|
| 1213 |
|
| 1214 |
<p>
|
| 1215 |
<example>
|
| 1216 |
[kov]@[couve] $ COLUMNS=132 dpkg -l | grep mozilla
|
| 1217 |
ii mozilla-browser 0.9.6-7 Mozilla Web Browser - core and browser
|
| 1218 |
</example>
|
| 1219 |
|
| 1220 |
<p>
|
| 1221 |
或顯示成這樣:
|
| 1222 |
|
| 1223 |
<p>
|
| 1224 |
<example>
|
| 1225 |
# apt-cache search "Mozilla Web Browser"
|
| 1226 |
mozilla-browser - Mozilla Web Browser
|
| 1227 |
</example>
|
| 1228 |
</sect>
|
| 1229 |
|
| 1230 |
<sect id="auto-apt">如何“按需”安裝套裝軟體
|
| 1231 |
<p>
|
| 1232 |
你正在編譯某段程序,突然,停住了!一條錯誤資訊報告說你沒有它需要的<tt>.h
|
| 1233 |
</tt>頭檔案。讓<prgn>auto-apt</prgn>來救你吧,它問你是否要安裝需要
|
| 1234 |
的套裝軟體,然後挂起編譯進程,安裝好套裝軟體後再恢復編譯進程。
|
| 1235 |
<p>
|
| 1236 |
你所要做的只有只有是:
|
| 1237 |
|
| 1238 |
<p>
|
| 1239 |
<example>
|
| 1240 |
# auto-apt run command
|
| 1241 |
</example>
|
| 1242 |
|
| 1243 |
<p>
|
| 1244 |
這裡“command”指在執行程序中可能出現“需求檔案不存在”問題的命令。例如:
|
| 1245 |
|
| 1246 |
<p>
|
| 1247 |
<example>
|
| 1248 |
# auto-apt run ./configure
|
| 1249 |
</example>
|
| 1250 |
|
| 1251 |
<p>
|
| 1252 |
一會兒,它就會告訴你要安裝所需的套裝軟體並自動前往apt-get處理。如果你正在
|
| 1253 |
執行X,就會一個圖形界面提示視窗。
|
| 1254 |
<p>
|
| 1255 |
為了提高效率auto-apt所用的資料庫需要實時更新。可調用
|
| 1256 |
<tt>auto-apt update</tt>,<tt>auto-apt updatedb</tt>和
|
| 1257 |
<tt>auto-apt update-local</tt>來完成更新。
|
| 1258 |
</sect>
|
| 1259 |
|
| 1260 |
<sect id="apt-file">如何知道檔案屬於哪個套裝軟體
|
| 1261 |
<p>
|
| 1262 |
如果你想安裝某個套裝軟體,但用<prgn>apt-cache</prgn>查不出它的名稱,不過你
|
| 1263 |
知道這個程序的檔案名稱,或這個套裝軟體中某些檔案的檔案名稱,那麼你可以用<prgn>
|
| 1264 |
apt-file</prgn>來尋找套裝軟體名稱。如下所示:
|
| 1265 |
|
| 1266 |
<p>
|
| 1267 |
<example>
|
| 1268 |
$ apt-file search <var>filename</var>
|
| 1269 |
</example>
|
| 1270 |
|
| 1271 |
<p>
|
| 1272 |
它用起來很象<tt>dpkg -S</tt>,不過它還會列出包含該檔案的已刪除套裝軟體。它
|
| 1273 |
也可以用來尋找哪個套裝軟體包含編譯時所缺的檔案,當然,解決這類問題<prgn>
|
| 1274 |
auto-apt</prgn>可能是更好的方案,請參考<ref id="auto-apt">。
|
| 1275 |
<p>
|
| 1276 |
用這個命令,你可以列出套裝軟體的內容:
|
| 1277 |
|
| 1278 |
<p>
|
| 1279 |
<example>
|
| 1280 |
$ apt-file list <var>packagename</var>
|
| 1281 |
</example>
|
| 1282 |
|
| 1283 |
<p>
|
| 1284 |
<prgn>apt-file</prgn>用一個資料庫來存放所有套裝軟體的內容資訊,和auto-apt
|
| 1285 |
一樣,這個資料庫也需要實時更新,完成更新可以執行:
|
| 1286 |
|
| 1287 |
<p>
|
| 1288 |
<example>
|
| 1289 |
# apt-file update
|
| 1290 |
</example>
|
| 1291 |
|
| 1292 |
<p>
|
| 1293 |
預設情況下,<prgn>apt-file</prgn>和<prgn>auto-apt</prgn>使用同一個資料庫,
|
| 1294 |
參考<ref id="auto-apt">。
|
| 1295 |
|
| 1296 |
</sect>
|
| 1297 |
|
| 1298 |
<sect id="apt-listchanges">如何掌握套裝軟體的變化情況
|
| 1299 |
<p>
|
| 1300 |
在每個套裝軟體被安裝以後,都會在文件目錄(<tt>/usr/share/doc/packagename</tt>)
|
| 1301 |
產生一個<tt>changelog.Debian.gz</tt>的檔案,這個檔案記錄了該套裝軟體最後一
|
| 1302 |
次更新對系統做了哪些修改,你可以用<tt>zless</tt>閱讀這些資訊。不過當你對
|
| 1303 |
整個系統進行升級以後,逐個檢視套裝軟體的更新資訊可不是件容易事。
|
| 1304 |
<p>
|
| 1305 |
有一個工具能幫你完成這項工作,它就是<prgn>apt-listchanges</prgn>。首先你
|
| 1306 |
要裝上<prgn>apt-listchanges</prgn>套裝軟體。在安裝的程序中,為了進行配
|
| 1307 |
置,Debconf會問你一些問題,按你的要求回答它們就行了。
|
| 1308 |
<p>
|
| 1309 |
第一個問題是問你希望apt-listchanges如何來顯示修改日誌。你可以讓它把資訊
|
| 1310 |
通過信件的方式發送給你,這對於自動更新是非常有用的。或是你可以讓它在<prgn>
|
| 1311 |
less</prgn>等程序中顯示修改日誌,這樣在繼續升級前你就可以檢視它們了。如果
|
| 1312 |
你不希望<prgn>apt-listchanges</prgn>在升級的時候自動的執行,可以
|
| 1313 |
回答<tt>none</tt>。
|
| 1314 |
<p>
|
| 1315 |
安裝了apt-listchanges後,每當apt下載套裝軟體之後(不論來來源是Internet、光碟
|
| 1316 |
或是硬碟)都會顯示這些套裝軟體的系統更新資訊。
|
| 1317 |
|
| 1318 |
</sect>
|
| 1319 |
</chapt>
|
| 1320 |
|
| 1321 |
<chapt id="sourcehandling">來源碼包操作
|
| 1322 |
<sect id="source">下載來源碼包
|
| 1323 |
<p>
|
| 1324 |
在自由軟體的世界裡,經常需要學習來源碼或為程序除錯,所以你需要下載它們。APT提
|
| 1325 |
供了一套簡便的方法幫你獲得發佈版中眾多程序的來源程式碼以及建立一個.debs所需的
|
| 1326 |
所有檔案。
|
| 1327 |
<p>
|
| 1328 |
Debian來源碼的另一個普遍用途是將unstable發佈版的新版程序進行改寫以供別的發
|
| 1329 |
布版使用。例如,從stable發佈版外引入新的套裝軟體,需要重新產生.debs將它在
|
| 1330 |
原發佈版中的關聯關係遷移到新的發佈版。
|
| 1331 |
<p>
|
| 1332 |
要完成這些工作,<tt>/etc/apt/sources.list</tt>檔案中<tt>deb-src</tt>所指
|
| 1333 |
參照鏡像來源應該是unstable,別忘了將行首的註解符去掉。詳情參考
|
| 1334 |
<ref id="sources.list">。
|
| 1335 |
<p>
|
| 1336 |
用下面的命令下載來源碼包:
|
| 1337 |
|
| 1338 |
<p>
|
| 1339 |
<example>
|
| 1340 |
$ apt-get source packagename
|
| 1341 |
</example>
|
| 1342 |
<p>
|
| 1343 |
通常會下載三個檔案:一個<tt>.orig.tar.gz</tt>、一個<tt>.dsc</tt>和一個<tt>
|
| 1344 |
.diff.gz</tt>。對於Debian專用的套裝軟體,不會下載最後一個檔案,第一個檔案的文
|
| 1345 |
件名中沒有“<tt>orig</tt>”項。
|
| 1346 |
<p>
|
| 1347 |
dpkg-source通過<tt>.dsc</tt>檔案中的資訊,將來源碼包解包到
|
| 1348 |
<var>packagename-version</var>目錄,下載下來的來源碼包中有一個
|
| 1349 |
<tt>debian/</tt>目錄,裡面是建立.deb包所需的檔案。
|
| 1350 |
<p>
|
| 1351 |
想要下載的來源碼包自動編譯成套裝軟體,只需在命令行中加上<tt>-b</tt>,如下:
|
| 1352 |
|
| 1353 |
<p>
|
| 1354 |
<example>
|
| 1355 |
$ apt-get -b source packagename
|
| 1356 |
</example>
|
| 1357 |
|
| 1358 |
<p>
|
| 1359 |
如果你不打算在下載後就立刻建立.deb檔案,你可以在之後用下面的命令建立:
|
| 1360 |
|
| 1361 |
<p>
|
| 1362 |
<example>
|
| 1363 |
$ dpkg-buildpackage -rfakeroot -uc -b
|
| 1364 |
</example>
|
| 1365 |
|
| 1366 |
<p>
|
| 1367 |
上述命令應當在下載後為套裝軟體建立的目錄中執行。要安裝用這種方式組建好的
|
| 1368 |
套裝軟體,只能直接使用套裝軟體管理器,例如:
|
| 1369 |
|
| 1370 |
<p>
|
| 1371 |
<example>
|
| 1372 |
# dpkg -i <var>file.deb</var>
|
| 1373 |
</example>
|
| 1374 |
|
| 1375 |
<p>
|
| 1376 |
<prgn>apt-get</prgn>的<tt>source</tt>命令與它的其它命令有所不同,普通用
|
| 1377 |
戶就可以執行source命令。檔案被下載到使用者調用<tt>apt-source package</tt>
|
| 1378 |
命令時所處的目錄中。
|
| 1379 |
</sect>
|
| 1380 |
|
| 1381 |
<sect id="build-dep">編譯來源碼包所需的套裝軟體
|
| 1382 |
<p>
|
| 1383 |
通常,編譯來源碼包時要用到某些頭檔案和共享庫,所有的來源碼包的控制檔案中都
|
| 1384 |
有一個網域“Build-Depends:”,網域中指出了編譯該來源碼包需要哪些附加包。
|
| 1385 |
<p>
|
| 1386 |
APT提供了一個簡單的方法下載這些附加包,你只需執行<tt>apt-get build-dep
|
| 1387 |
package</tt>,其中“package”就是你打算編譯的來源碼包
|
| 1388 |
名稱。見下例:
|
| 1389 |
|
| 1390 |
<p>
|
| 1391 |
<example>
|
| 1392 |
# apt-get build-dep gmc
|
| 1393 |
Reading Package Lists... Done
|
| 1394 |
Building Dependency Tree... Done
|
| 1395 |
The following NEW packages will be installed:
|
| 1396 |
comerr-dev e2fslibs-dev gdk-imlib-dev imlib-progs libgnome-dev libgnorba-dev
|
| 1397 |
libgpmg1-dev
|
| 1398 |
0 packages upgraded, 7 newly installed, 0 to remove and 1 not upgraded.
|
| 1399 |
Need to get 1069kB of archives. After unpacking 3514kB will be used.
|
| 1400 |
Do you want to continue? [Y/n]
|
| 1401 |
</example>
|
| 1402 |
|
| 1403 |
<p>
|
| 1404 |
這些將要被安裝的包是用於正確編譯<package>gmc</package>的。注意這個命令不
|
| 1405 |
能用來搜索某個軟體的來源碼包,你得另外執行<tt>apt-get source</tt>下載來源碼包。
|
| 1406 |
|
| 1407 |
<p>
|
| 1408 |
如果你想做的是檢查要編譯一個套裝軟體需要哪些其它的套裝軟體,<tt>apt-cache show
|
| 1409 |
</tt>可以顯示它(從那考<ref id="search">,在眾多資訊之中,<tt>Build-Depends
|
| 1410 |
</tt>一行會列出那些需要的套裝軟體。
|
| 1411 |
|
| 1412 |
<p>
|
| 1413 |
<example>
|
| 1414 |
# apt-cache showsrc <var>package</var>
|
| 1415 |
</example>
|
| 1416 |
|
| 1417 |
</sect>
|
| 1418 |
</chapt>
|
| 1419 |
|
| 1420 |
<chapt id="erros">如何處理錯誤
|
| 1421 |
<sect id="erros-comuns">一般錯誤
|
| 1422 |
<p>
|
| 1423 |
錯誤總是發生,大部分是因為使用者的粗心,下面列舉一些常見錯誤及處理方法。
|
| 1424 |
<p>
|
| 1425 |
如果在執行<tt>apt-get install package</tt>時,你的系統報告如下資訊:
|
| 1426 |
|
| 1427 |
<p>
|
| 1428 |
<example>
|
| 1429 |
Reading Package Lists... Done
|
| 1430 |
Building Dependency Tree... Done
|
| 1431 |
W: Couldn't stat source package list 'http://people.debian.org unstable/ Packages' (/var/state/apt/lists/people.debian.org_%7ekov_debian_unstable_Packages) - stat (2 No such file or directory)
|
| 1432 |
W: You may want to run apt-get update to correct these missing files
|
| 1433 |
E: Couldn't find package penguineyes
|
| 1434 |
</example>
|
| 1435 |
|
| 1436 |
<p>
|
| 1437 |
上次你修改<tt>/etc/apt/sources.list</tt>後,忘了執行<tt>apt-get update
|
| 1438 |
</tt>更新。
|
| 1439 |
<p>
|
| 1440 |
如果出現這樣的資訊:
|
| 1441 |
|
| 1442 |
<p>
|
| 1443 |
<example>
|
| 1444 |
E: Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)
|
| 1445 |
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
|
| 1446 |
</example>
|
| 1447 |
|
| 1448 |
<p>
|
| 1449 |
|
| 1450 |
如果你沒有root權限,執行除<tt>source</tt>外的其它<prgn>apt-get</prgn>命
|
| 1451 |
令,如會出現上面的錯誤資訊。這是因為你是普通用戶。
|
| 1452 |
<p>
|
| 1453 |
當你同時執行兩個<prgn>apt-get</prgn>進程,或是當你試圖執行<prgn>apt-get
|
| 1454 |
</prgn>時已有一個的<prgn>dpkg</prgn>進程處於活化狀態,系統也
|
| 1455 |
會報告與上面相似的錯誤資訊。唯一能與其它命令同時執行的只有<tt>source</tt>
|
| 1456 |
命令。
|
| 1457 |
<p>
|
| 1458 |
如果在安裝程序中出現插斷,然後你發現該套裝軟體既不能重裝又不能刪除,試試下
|
| 1459 |
面兩個命令:
|
| 1460 |
|
| 1461 |
<p>
|
| 1462 |
<example>
|
| 1463 |
# apt-get -f install
|
| 1464 |
# dpkg --configure -a
|
| 1465 |
</example>
|
| 1466 |
|
| 1467 |
<p>
|
| 1468 |
重試著安裝那個套裝軟體,如果不行再次執行上述命令後重試。這兩個命令對於那些
|
| 1469 |
使用unstable的玩家非常有用。
|
| 1470 |
|
| 1471 |
<p>
|
| 1472 |
如果你在執行<tt>apt-get update</tt>時看到“E: Dynamic MMap ran out of room”,
|
| 1473 |
那麼在<file>/etc/apt/apt.conf</file>加入如下內容:
|
| 1474 |
|
| 1475 |
<example>
|
| 1476 |
APT::Cache-Limit 10000000;
|
| 1477 |
</example>
|
| 1478 |
|
| 1479 |
</sect>
|
| 1480 |
|
| 1481 |
<sect id="help">在哪兒獲得幫助?
|
| 1482 |
<p>
|
| 1483 |
如果你發現自己有太多疑問,沒關係,有大量的Debian套裝軟體管理系統文件供你參
|
| 1484 |
考。<tt>--help</tt>和幫助文件能為你提供巨大的幫助,這些文件位元於<tt>
|
| 1485 |
/usr/share/doc</tt>目錄中,如<tt>/usr/share/doc/apt</tt>。
|
| 1486 |
<p>
|
| 1487 |
如果本文件沒法幫你排憂解難,可以去Debian信件列表找找答案,在相關欄目內你
|
| 1488 |
會獲得更多資訊。Debian的網址是:<url id="http://www.debian.org"
|
| 1489 |
name="http://www.debian.org">。
|
| 1490 |
<p>
|
| 1491 |
記住只有Debian使用者才能這些信件列表和資源,其它作業系統的使用者請到相關係統
|
| 1492 |
發佈者建立的社區中獲取更多資源。
|
| 1493 |
</sect>
|
| 1494 |
</chapt>
|
| 1495 |
|
| 1496 |
<chapt id="distros">哪些發行版支援APT?
|
| 1497 |
<p>
|
| 1498 |
|
| 1499 |
下面是部分使用APT系統的發行版的名稱:
|
| 1500 |
<p>
|
| 1501 |
Debian GNU/Linux (<url id="http://www.debian.org" name="http://www.debian.org">)
|
| 1502 |
- APT正是為這個發行版開發的
|
| 1503 |
<p>
|
| 1504 |
Conectiva (<url id="http://www.conectiva.com.br" name="http://www.conectiva.com.br">)
|
| 1505 |
- 這是第一個將APT移植到rpm上的發行版
|
| 1506 |
<p>
|
| 1507 |
Libranet (<url id="http://www.libranet.com" name="http://www.libranet.com">)
|
| 1508 |
<p>
|
| 1509 |
Mandrake (<url id="http://www.mandrake.com" name="http://www.mandrake.com">)
|
| 1510 |
<p>
|
| 1511 |
PLD (<url id="http://www.pld.org.pl" name="http://www.pld.org.pl">)
|
| 1512 |
<p>
|
| 1513 |
Vine (<url id="http://www.vinelinux.org" name="http://www.vinelinux.org">)
|
| 1514 |
<p>
|
| 1515 |
APT4RPM (<url id="http://apt4rpm.sf.net" name="http://apt4rpm.sf.net">)
|
| 1516 |
<p>
|
| 1517 |
Alt Linux (<url id="http://www.altlinux.ru/" name="http://www.altlinux.ru/">)
|
| 1518 |
<p>
|
| 1519 |
Red Hat (<url id="http://www.redhat.com/" name="http://www.redhat.com/">)
|
| 1520 |
<p>
|
| 1521 |
Sun Solaris (<url id="http://www.sun.com/" name="http://www.sun.com/">)
|
| 1522 |
<p>
|
| 1523 |
SuSE (<url id="http://www.suse.de/" name="http://www.suse.de/">)
|
| 1524 |
<p>
|
| 1525 |
Yellow Dog Linux (<url id="http://www.yellowdoglinux.com/"
|
| 1526 |
name="http://www.yellowdoglinux.com/">)
|
| 1527 |
</chapt>
|
| 1528 |
|
| 1529 |
<chapt id="agradecimentos">致謝
|
| 1530 |
<p>
|
| 1531 |
非常感謝你們,我Debian-BR項目組的好朋友們!還有你Debian,始終在我身邊幫助
|
| 1532 |
我,給我動力不停工作為全人類做出貢獻,幫助我樹立拯救世界的理想。:)
|
| 1533 |
<p>
|
| 1534 |
我還要感謝CIPSGA,他們給予我們項目組乃至整個自由軟體項目巨大的幫助,是我
|
| 1535 |
們靈感的來源泉。
|
| 1536 |
<p>
|
| 1537 |
|
| 1538 |
特別感謝:
|
| 1539 |
<p>
|
| 1540 |
Yooseong Yang <yooseong@debian.org>
|
| 1541 |
<p>
|
| 1542 |
Michael Bramer <grisu@debian.org>
|
| 1543 |
<p>
|
| 1544 |
Bryan Stillwell <bryan@bokeoa.com>
|
| 1545 |
<p>
|
| 1546 |
Pawel Tecza <pawel.tecza@poczta.fm>
|
| 1547 |
<p>
|
| 1548 |
Hugo Mora <h.mora@melix.com.mx>
|
| 1549 |
<p>
|
| 1550 |
Luca Monducci <luca.mo@tiscali.it>
|
| 1551 |
<p>
|
| 1552 |
Tomohiro KUBOTA <kubota@debian.org>
|
| 1553 |
<p>
|
| 1554 |
Pablo Lorenzzoni <spectra@debian.org>
|
| 1555 |
<p>
|
| 1556 |
Steve Langasek <vorlon@netexpress.net>
|
| 1557 |
<p>
|
| 1558 |
Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
| 1559 |
<p>
|
| 1560 |
Erik Rossen <rossen@freesurf.ch>
|
| 1561 |
<p>
|
| 1562 |
Ross Boylan <RossBoylan@stanfordalumni.org>
|
| 1563 |
<p>
|
| 1564 |
Matt Kraai <kraai@debian.org>
|
| 1565 |
<p>
|
| 1566 |
Aaron M. Ucko <ucko@debian.org>
|
| 1567 |
<p>
|
| 1568 |
Jon Åslund <d98-jas@nada.kth.se>
|
| 1569 |
</chapt>
|
| 1570 |
|
| 1571 |
<chapt id="novas">本使用指南的新版本
|
| 1572 |
<p>
|
| 1573 |
本操作手冊由<url id="http://www.debian-br.org" name="Debian-BR項目組">撰
|
| 1574 |
寫,我們希望它能為Debian使用者提供有效的幫助。
|
| 1575 |
<p>
|
| 1576 |
你可以從Debian文件項目頁面獲得本文件的新版本:<url
|
| 1577 |
id="http://www.debian.org/doc/ddp" name="http://www.debian.org/doc/ddp">。
|
| 1578 |
<p>
|
| 1579 |
對本文件有任何意見或建議可直接發email給我:<email>kov@debian.org</email>。
|
| 1580 |
(華文使用者請發給譯者)
|
| 1581 |
</chapt>
|
| 1582 |
|
| 1583 |
</book>
|
| 1584 |
|
| 1585 |
</debiandoc>
|