?? 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="使用package系統" 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">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 4. 安裝應用程序: Packages 和Ports</td><td width="10%" align="right" valign="bottom"><a href="ports-nextsteps.html"accesskey="N">Next</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>The alternative method to obtain and keep your ports collection up to date is by using<b class="APPLICATION">CVSup</b>. Look at the ports <b class="APPLICATION">CVSup</b>file, <tt class="FILENAME">/usr/share/examples/cvsup/ports-supfile</tt>. See <ahref="cvsup.html">Using CVSup</a> (<a href="cvsup.html">Section A.5</a>) for moreinformation on using <b class="APPLICATION">CVSup</b> and this file.</p><div class="PROCEDURE"><p><b>CVSup Method</b></p><p>This is a quick method for getting the ports collection using <bclass="APPLICATION">CVSup</b>. If you want to keep your ports tree up to date, or learnmore about <b class="APPLICATION">CVSup</b>, read the previously mentioned sections.</p><ol type="1"><li><p>Install the <a href="http://www.FreeBSD.org/cgi/url.cgi?ports/net/cvsup/pkg-descr"><ttclass="FILENAME">net/cvsup</tt></a> port. See <a href="cvsup.html#CVSUP-INSTALL">CVSupInstallation</a> (<a href="cvsup.html#CVSUP-INSTALL">Section A.5.2</a>) for moredetails.</p></li><li><p>As <tt class="USERNAME">root</tt>, copy <ttclass="FILENAME">/usr/share/examples/cvsup/ports-supfile</tt> to a new location, such as<tt class="FILENAME">/root</tt> or your home directory.</p></li><li><p>Edit <tt class="FILENAME">ports-supfile</tt>.</p></li><li><p>Change <var class="REPLACEABLE">CHANGE_THIS.FreeBSD.org</var> to a <bclass="APPLICATION">CVSup</b> server near you. See <ahref="cvsup.html#CVSUP-MIRRORS">CVSup Mirrors</a> (<ahref="cvsup.html#CVSUP-MIRRORS">Section A.5.7</a>) for a complete listing of mirrorsites.</p></li><li><p>Run <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>Running this command later will download and apply all the recent changes to yourports collection, except actually rebuilding the ports for your own system.</p></li></ol></div></div><div class="SECT2"><h2 class="SECT2"><a id="PORTS-SKELETON" name="PORTS-SKELETON">4.5.2. InstallingPorts</a></h2><p>The first thing that should be explained when it comes to the ports collection is whatis actually meant by a ``skeleton''. In a nutshell, a port skeleton is a minimal set offiles that tell your FreeBSD system how to cleanly compile and install a program. Eachport skeleton includes:</p><ul><li><p>A <tt class="FILENAME">Makefile</tt>. The <tt class="FILENAME">Makefile</tt> containsvarious statements that specify how the application should be compiled and where itshould be installed on your system.</p></li><li><p>A <tt class="FILENAME">distinfo</tt> file. This file contains information about thefiles that must be downloaded to build the port and their checksums, to verify that fileshave not been corrupted during the download using <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">md5</span>(1)</span>.</p></li><li><p>A <tt class="FILENAME">files</tt> directory. This directory contains patches to makethe program compile and install on your FreeBSD system. Patches are basically small filesthat specify changes to particular files. They are in plain text format, and basicallysay ``Remove line 10'' or ``Change line 26 to this ...''. Patches are also known as``diffs'' because they are generated by the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">diff</span>(1)</span> program.</p><p>This directory may also contain other files used to build the port.</p></li><li><p>A <tt class="FILENAME">pkg-descr</tt> file. This is a more detailed, oftenmultiple-line, description of the program.</p></li><li><p>A <tt class="FILENAME">pkg-plist</tt> file. This is a list of all the files that willbe installed by the port. It also tells the ports system what files to remove upondeinstallation.</p></li></ul><p>Some ports have other files, such as <tt class="FILENAME">pkg-message</tt>. The portssystem uses these files to handle special situations. If you want more details on thesefiles, and on ports in general, check out the <a href="../porters-handbook/index.html"target="_top">FreeBSD Porter's Handbook</a>.</p><p>Now that you have enough background information to know what the ports collection isused for, you are ready to install your first port. There are two ways this can be done,and each is explained below.</p><p>Before we get into that, however, you will need to choose a port to install. There area few ways to do this, with the easiest method being the <ahref="../../../../ports/index.html" target="_top">ports listing on the FreeBSD website</a>. You can browse through the ports listed there or use the search function on thesite. Each port also includes a description so you can read a bit about each port beforedeciding to install it.</p><p>Another method is to use the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">whereis</span>(1)</span> command. Simply type <ttclass="COMMAND">whereis <var class="REPLACEABLE">file</var></tt>, where <varclass="REPLACEABLE">file</var> is the program you want to install. If it is found on yoursystem, you will be told where it is, as follows:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">whereis lsof</kbd>lsof: /usr/ports/sysutils/lsof</pre><p>This tells us that <tt class="COMMAND">lsof</tt> (a system utility) can be found inthe <tt class="FILENAME">/usr/ports/sysutils/lsof</tt> directory.</p><p>Yet another way to find a particular port is by using the ports collection's built-insearch mechanism. To use the search feature, you will need to be in the <ttclass="FILENAME">/usr/ports</tt> directory. Once in that directory, run <ttclass="COMMAND">make search name=<var class="REPLACEABLE">program-name</var></tt> where<var class="REPLACEABLE">program-name</var> is the name of the program you want to find.For example, if you were looking for <tt class="COMMAND">lsof</tt>:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cd /usr/ports</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make search name=lsof</kbd>Port: lsof-4.56.4Path: /usr/ports/sysutils/lsofInfo: Lists information about open files (similar to fstat(1))Maint: obrien@FreeBSD.orgIndex: sysutilsB-deps: R-deps:</pre><p>The part of the output you want to pay particular attention to is the ``Path:'' line,since that tells you where to find the port. The other information provided is not neededin order to install the port, so it will not be covered here.</p><p>For more in-depth searching you can also use <tt class="COMMAND">make search key=<varclass="REPLACEABLE">string</var></tt> where <var class="REPLACEABLE">string</var> is sometext to search for. This searches port names, comments, descriptions and dependencies andcan be used to find ports which relate to a particular subject if you don't know the nameof the program you are looking for.</p><p>In both of these cases, the search string is case-insensitive. Searching for ``LSOF''will yield the same results as searching for ``lsof''.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> You must be logged in as <tt class="USERNAME">root</tt> to installports.</p></blockquote></div><p>Now that you have found a port you would like to install, you are ready to do theactual installation. The port includes instructions on how to build source code, but doesnot include the actual source code. You can get the source code from a CD-ROM or from theInternet. Source code is distributed in whatever manner the software author desires.Frequently this is a tarred and gzipped file, but it might be compressed with some othertool or even uncompressed. The program source code, whatever form it comes in, is calleda ``distfile''. You can get the distfile from a CD-ROM or from the Internet.</p><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]...
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -