?? ports-using.html
字號:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>使用Ports Collection</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD 使用手冊" href="index.html" /><link rel="UP" title="安裝應用程序: Packages 和 Ports" href="ports.html" /><link rel="PREVIOUS" title="使用Packages系統" href="packages-using.html" /><link rel="NEXT" title="Post-installation Activities" href="ports-nextsteps.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /><meta http-equiv="Content-Type" content="text/html; charset=GB2312" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD 使用手冊</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="packages-using.html"accesskey="P">后退</a></td><td width="80%" align="center" valign="bottom">章 4. 安裝應用程序: Packages 和 Ports</td><td width="10%" align="right" valign="bottom"><a href="ports-nextsteps.html"accesskey="N">前進</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="PORTS-USING" name="PORTS-USING">4.5. 使用PortsCollection</a></h1><p>下面的章節提供了使用ports collection來安裝或卸載程序的基本用法。</p><div class="SECT2"><h2 class="SECT2"><a id="PORTS-TREE" name="PORTS-TREE">4.5.1. 獲得PortsCollection</a></h2><p>在您能使用ports之前, 您必須先獲得ports collection--本質上是<ttclass="FILENAME">/usr/ports</tt>目錄下的一堆 <tt class="FILENAME">Makefiles</tt>,補丁,和描述文件。</p><p>在您安裝FreeBSD系統的時候,<bclass="APPLICATION">sysinstall</b>會詢問您是否需要安裝ports collection.如果您選擇no,那您可以根據下面的指令來安裝ports collection:</p><div class="PROCEDURE"><p><b>Sysinstall 方式</b></p><p>這種方式使用<b class="APPLICATION">sysinstall</b>再次手動安裝ports collection。</p><ol type="1"><li><p>用<tt class="USERNAME">root</tt>用戶, 運行 <ttclass="COMMAND">/stand/sysinstall</tt>命令,像下面顯示的:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">/stand/sysinstall</kbd></pre></li><li><p>選擇<span class="GUIMENUITEM">Configure</span>, 按<b class="KEYCAP">Enter</b>。</p></li><li><p>選擇<span class="GUIMENUITEM">Distributions</span>, 按 <bclass="KEYCAP">Enter</b>。</p></li><li><p>選擇<span class="GUIMENUITEM">ports</span>, 按<b class="KEYCAP">Space</b>。</p></li><li><p>選擇<span class="GUIMENUITEM">Exit</span>, 按<b class="KEYCAP">Enter</b>。</p></li><li><p>選擇您的安裝介質,就像CDROM,FTP,等等</p></li><li><p>選擇<span class="GUIMENUITEM">Exit</span>并按<b class="KEYCAP">Enter</b>。</p></li><li><p>按<b class="KEYCAP">X</b>鍵退出<b class="APPLICATION">sysinstall</b>。</p></li></ol></div><p>您可以使用<b class="APPLICATION">CVSup</b>,這個程序讓您獲得和更新 ports collection。<b class="APPLICATION">CVSup</b>需要使用 <ttclass="FILENAME">/usr/share/examples/cvsup/ports-supfile</tt>這個配置文件。如果您想獲得關于<b class="APPLICATION">CVSup</b>這個應用程序的更多信息,請看<ahref="cvsup.html">使用 CVSup</a> (<a href="cvsup.html">µÚ A.5節</a>)和本文件。</p><div class="PROCEDURE"><p><b>CVSup 方法</b></p><p>使用<b class="APPLICATION">CVSup</b>獲得 ports collection ,是一個非常快捷的方法。如果您想保持您的 ports 樹的最新狀態,或學習更多關于<bclass="APPLICATION">CVSup</b>的內容您可以閱讀剛才提及的內容。</p><ol type="1"><li><p>安裝<a href="http://www.FreeBSD.org/cgi/url.cgi?ports/net/cvsup/pkg-descr"><ttclass="FILENAME">net/cvsup</tt></a> port。詳情請參閱<ahref="cvsup.html#CVSUP-INSTALL">CVSup 安裝</a> (<ahref="cvsup.html#CVSUP-INSTALL">µÚ A.5.2 節</a>)。</p></li><li><p>用<tt class="USERNAME">root</tt> 用戶,復制 <ttclass="FILENAME">/usr/share/examples/cvsup/ports-supfile</tt> 到一個新的地方,比如 <ttclass="FILENAME">/root</tt> 和您的家目錄。</p></li><li><p>編輯 <tt class="FILENAME">ports-supfile</tt>。</p></li><li><p>修改 <var class="REPLACEABLE">CHANGE_THIS.FreeBSD.org</var> 到離您比較近的<bclass="APPLICATION">CVSup</b> 服務器。請看 <a href="cvsup.html#CVSUP-MIRRORS">CVSup鏡像</a> (<a href="cvsup.html#CVSUP-MIRRORS">µÚ A.5.7 節</a>)服務器的完整列表。</p></li><li><p>運行 <tt class="COMMAND">cvsup</tt>:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cvsup -g -L 2 <varclass="REPLACEABLE">/root/ports-supfile</var></kbd></pre></li><li><p>運行這個命令之后將下載和應用所有變化的ports系統,除了在您的系統中重建ports系統。</p></li></ol></div></div><div class="SECT2"><h2 class="SECT2"><a id="PORTS-SKELETON" name="PORTS-SKELETON">4.5.2. 安裝 Ports</a></h2><p>當提到Ports collection時,第一個要說明的就是何謂“``skeleton''”。簡單地說,一個portskeleton讓一個程序在FreeBSD上簡潔地編譯并安裝的所需文件的最小組合。每個portskeleton包含:</p><ul><li><p>一個 <tt class="FILENAME">Makefile</tt>。<ttclass="FILENAME">Makefile</tt>包括好幾個部分,指出應用程序是如何編譯和它將被安裝在系統的哪個地方。</p></li><li><p>一個 <tt class="FILENAME">distinfo</tt>文件。這個文件包括這些信息:這些文件用來對下載后的文件checksums,使用 <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">md5</span>(1)</span>來確保在下載過程中文件不會被破壞。</p></li><li><p>一個<ttclass="FILENAME">files</tt>目錄。這個目錄包括在您的FreeBSD系統上編譯和安裝程序需要用到的補丁。這些補丁基本上都是些小文件,指出特定文件作了哪些修正。他們都是純文本的的格式,基本上是這樣的``Removeline 10'' 或``Change line 26 to this ...'',補丁文件使用了``diffs'',他們由 <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">diff</span>(1)</span> 程序產生。</p><p>這個目錄也包含了在建立port時要用到的其它文件T。</p></li><li><p>一個<ttclass="FILENAME">pkg-descr</tt>文件。這是一個提供更多細節,有軟件的多行描述。</p></li><li><p>一個 <tt class="FILENAME">pkg-plist</tt>文件。這是即將被安裝的所有文件的列表。它告訴ports系統在重新安裝時什么文件需要被刪除。</p></li></ul><p>一些ports還有些其它的文件,就像 <ttclass="FILENAME">pkg-message</tt>。ports系統會在特殊的情況下使用這些文件。如果您想知道這些文件更多的細節以及ports的概要,請參閱<a href="../../../../doc/en_US.ISO8859-1/books/porters-handbook/index.html"target="_top">FreeBSD Porter's Handbook</a>.</p><p>port里面包含著如何編譯源代碼的指令,但不包含真實的源代碼。您可以在網上或CD-ROM上獲得源代碼。Source code is distributed in whatever manner the software author desires. Frequentlythis is a tarred and gzipped file, but it might be compressed with some other tool oreven uncompressed. The program source code, whatever form it comes in, is called a``distfile''. The two methods for installing a FreeBSD port are described below.</p><div class="NOTE"><blockquote class="NOTE"><p><b>注:</b> 您必須使用 <tt class="USERNAME">root</tt> 用戶登錄后安裝ports.</p></blockquote></div><div class="WARNING"><blockquote class="WARNING"><p><b>警告</b>在安裝任何 port 之前, 應該首先確保已經更新到了最新的 ports collection,并檢查 <a href="http://vuxml.freebsd.org/" target="_top">http://vuxml.freebsd.org/</a>中是否有與那個 port 有關的安全問題。</p><p>在安裝應用程序之前, 可以使用 <b class="APPLICATION">portaudit</b>來自動地檢查是否存在已知的安全問題。 這個工具同樣可以在 ports collection (<ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/security/portaudit/pkg-descr"><ttclass="FILENAME">security/portaudit</tt></a>) 中找到。 在安裝新的 port 之前,可以考慮先運行一下 <tt class="COMMAND">portaudit -F</tt> 來抓取最新的漏洞數據庫。在每天的周期性系統安全檢察時, 數據庫會被自動更新, 并且會在這之后實施安全審計。欲了解進一步的情況,請參閱 <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">portaudit</span>(1)</span> 和 <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">periodic</span>(8)</span>。</p></blockquote></div><div class="SECT3"><h3 class="SECT3"><a id="PORTS-CD" name="PORTS-CD">4.5.2.1. Installing Ports from aCD-ROM</a></h3><p>The FreeBSD Project's official CD-ROM images no longer include distfiles. They take upa lot of room that is better used for precompiled packages. CD-ROM products such as theFreeBSD PowerPak do include distfiles, and you can order these sets from a vendor such asthe <a href="http://www.freebsdmall.com/" target="_top">FreeBSD Mall</a>. This sectionassumes you have such a FreeBSD CD-ROM set.</p><p>Place your FreeBSD CD-ROM in the drive. Mount it on <tt class="FILENAME">/cdrom</tt>.(If you use a different mount point, the install will not work.) To begin, change to thedirectory for the port you want to install:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cd /usr/ports/sysutils/lsof</kbd></pre><p>Once inside the <tt class="FILENAME">lsof</tt> directory, you will see the portskeleton. The next step is to compile, or ``build'', the port. This is done by simplytyping <tt class="COMMAND">make</tt> at the prompt. Once you have done so, you should seesomething like this:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make</kbd>>> lsof_4.57D.freebsd.tar.gz doesn't seem to exist in /usr/ports/distfiles/.>> Attempting to fetch from file:/cdrom/ports/distfiles/.===> Extracting for lsof-4.57...[extraction output snipped]...>> Checksum OK for lsof_4.57D.freebsd.tar.gz.===> Patching for lsof-4.57===> Applying FreeBSD patches for lsof-4.57===> Configuring for lsof-4.57...[configure output snipped]...===> Building for lsof-4.57...[compilation output snipped]...<samp class="PROMPT">#</samp></pre><p>Notice that once the compile is complete you are returned to your prompt. The nextstep is to install the port. In order to install it, you simply need to tack one wordonto the <tt class="COMMAND">make</tt> command, and that word is <ttclass="COMMAND">install</tt>:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make install</kbd>===> Installing for lsof-4.57...[installation output snipped]...===> Generating temporary packing list===> Compressing manual pages for lsof-4.57===> Registering installation for lsof-4.57===> SECURITY NOTE: This port has installed the following binaries which execute with increased privileges.<samp class="PROMPT">#</samp></pre><p>Once you are returned to your prompt, you should be able to run the application youjust installed. Since <tt class="COMMAND">lsof</tt> is a program that runs with increasedprivileges, a security warning is shown. During the building and installation of ports,you should take heed of any other warnings that may appear.</p><div class="NOTE"><blockquote class="NOTE"><p><b>注:</b> You can save an extra step by just running <tt class="COMMAND">makeinstall</tt> instead of <tt class="COMMAND">make</tt> and <tt class="COMMAND">makeinstall</tt> as two separate steps.</p></blockquote></div><div class="NOTE"><blockquote class="NOTE"><p><b>注:</b> Some shells keep a cache of the commands that are available in the
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -