⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 packages-using.html

📁 这是很好的学习嵌入式LINUX的文章
💻 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>Using the Packages System</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Installing Applications: Packages and Ports" href="ports.html" /><link rel="PREVIOUS" title="Finding Your Application"href="ports-finding-applications.html" /><link rel="NEXT" title="Using the Ports Collection" href="ports-using.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></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 Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="ports-finding-applications.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 4 Installing Applications:Packages and Ports</td><td width="10%" align="right" valign="bottom"><a href="ports-using.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="PACKAGES-USING" name="PACKAGES-USING">4.4 Using the PackagesSystem</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Contributed by</span> Chern Lee.</i> <div class="SECT2"><h2 class="SECT2"><a id="AEN5425" name="AEN5425">4.4.1 Installing a Package</a></h2><p>You can use the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=pkg_add&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pkg_add</span>(1)</span></a> utility toinstall a FreeBSD software package from a local file or from a server on the network.</p><div class="EXAMPLE"><a id="AEN5437" name="AEN5437"></a><p><b>Example 4-1. Downloading a Package Manually and Installing It Locally</b></p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ftp -a <varclass="REPLACEABLE">ftp2.FreeBSD.org</var></kbd>Connected to ftp2.FreeBSD.org.220 ftp2.FreeBSD.org FTP server (Version 6.00LS) ready.331 Guest login ok, send your email address as password.230-230-     This machine is in Vienna, VA, USA, hosted by Verio.230-         Questions? E-mail freebsd@vienna.verio.net.230-230-230 Guest login ok, access restrictions apply.Remote system type is UNIX.Using binary mode to transfer files.<samp class="PROMPT">ftp&#62;</samp> <kbdclass="USERINPUT">cd /pub/FreeBSD/ports/packages/sysutils/</kbd>250 CWD command successful.<samp class="PROMPT">ftp&#62;</samp> <kbd class="USERINPUT">get lsof-4.56.4.tgz</kbd>local: lsof-4.56.4.tgz remote: lsof-4.56.4.tgz200 PORT command successful.150 Opening BINARY mode data connection for 'lsof-4.56.4.tgz' (92375 bytes).100% |**************************************************| 92375       00:00 ETA226 Transfer complete.92375 bytes received in 5.60 seconds (16.11 KB/s)<samp class="PROMPT">ftp&#62;</samp> <kbd class="USERINPUT">exit</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">pkg_add <varclass="REPLACEABLE">lsof-4.56.4.tgz</var></kbd></pre></div><p>If you do not have a source of local packages (such as a FreeBSD CD-ROM set) then itwill probably be easier to use the <var class="OPTION">-r</var> option to <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=pkg_add&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pkg_add</span>(1)</span></a>. This willcause the utility to automatically determine the correct object format and release andthen fetch and install the package from an FTP site.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">pkg_add -r <varclass="REPLACEABLE">lsof</var></kbd></pre><p>The example above would download the correct package and add it without any furtheruser intervention. If you want to specify an alternative FreeBSD Packages Mirror, insteadof the main distribution site, you have to set <tt class="ENVAR">PACKAGESITE</tt>accordingly, to override the default settings. <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=pkg_add&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pkg_add</span>(1)</span></a> uses <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=fetch&sektion=3"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">fetch</span>(3)</span></a> to downloadthe files, which honors various environment variables, including <ttclass="ENVAR">FTP_PASSIVE_MODE</tt>, <tt class="ENVAR">FTP_PROXY</tt>, and <ttclass="ENVAR">FTP_PASSWORD</tt>. You may need to set one or more of these if you arebehind a firewall, or need to use an FTP/HTTP proxy. See <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=fetch&sektion=3"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">fetch</span>(3)</span></a> for thecomplete list. Note that in the example above <var class="LITERAL">lsof</var> is usedinstead of <var class="LITERAL">lsof-4.56.4</var>. When the remote fetching feature isused, the version number of the package must be removed. <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=pkg_add&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pkg_add</span>(1)</span></a> willautomatically fetch the latest version of the application.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=pkg_add&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pkg_add</span>(1)</span></a> willdownload the latest version of your application if you are using FreeBSD-CURRENT orFreeBSD-STABLE. If you run a -RELEASE version, it will grab the version of the packagethat was built with your release. It is possible to change this behavior by overridingthe <tt class="ENVAR">PACKAGESITE</tt> environment variable.</p></blockquote></div><p>Package files are distributed in <tt class="FILENAME">.tgz</tt> and <ttclass="FILENAME">.tbz</tt> formats. You can find them at <ahref="ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/packages/"target="_top">ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/packages/</a>, or on the FreeBSDCD-ROM distribution. Every CD on the FreeBSD 4-CD set (and the PowerPak, etc.) containspackages in the <tt class="FILENAME">/packages</tt> directory. The layout of the packagesis similar to that of the <tt class="FILENAME">/usr/ports</tt> tree. Each category hasits own directory, and every package can be found within the <ttclass="FILENAME">All</tt> directory.</p><p>The directory structure of the package system matches the ports layout; they work witheach other to form the entire package/port system.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN5497" name="AEN5497">4.4.2 Managing Packages</a></h2><p><a href="http://www.FreeBSD.org/cgi/man.cgi?query=pkg_info&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pkg_info</span>(1)</span></a> is autility that lists and describes the various packages installed.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">pkg_info</kbd>cvsup-16.1          A general network file distribution system optimized for CVdocbook-1.2         Meta-port for the different versions of the DocBook DTD...</pre><p><a href="http://www.FreeBSD.org/cgi/man.cgi?query=pkg_version&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pkg_version</span>(1)</span></a> is autility that summarizes the versions of all installed packages. It compares the packageversion to the current version found in the ports tree.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">pkg_version</kbd>cvsup                       =docbook                     =...</pre><p>The symbols in the second column indicate the relative age of the installed versionand the version available in the local ports tree.</p><div class="INFORMALTABLE"><a id="AEN5523" name="AEN5523"></a><table border="0" frame="void" class="CALSTABLE"><col /><col /><thead><tr><th>Symbol</th><th>Meaning</th></tr></thead><tbody><tr><td>=</td><td>The version of the installed package matches the one found in the local portstree.</td></tr><tr><td>&lt;</td><td>The installed version is older than the one available in the ports tree.</td></tr><tr><td>&gt;</td><td>The installed version is newer than the one found in the local ports tree. (The localports tree is probably out of date.)</td></tr><tr><td>?</td><td>The installed package cannot be found in the ports index. (This can happen, forinstance, if an installed port is removed from the ports collection or renamed.)</td></tr><tr><td>*</td><td>There are multiple versions of the package.</td></tr></tbody></table></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN5545" name="AEN5545">4.4.3 Deleting a Package</a></h2><p>To remove a previously installed software package, use the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=pkg_delete&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pkg_delete</span>(1)</span></a>utility.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">pkg_delete <varclass="REPLACEABLE">xchat-1.7.1</var></kbd></pre></div><div class="SECT2"><h2 class="SECT2"><a id="AEN5561" name="AEN5561">4.4.4 Miscellaneous</a></h2><p>All package information is stored within the <tt class="FILENAME">/var/db/pkg</tt>directory. The installed file list and descriptions of each package can be found withinfiles in this directory.</p></div></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="ports-finding-applications.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="ports-using.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Finding Your Application</td><td width="34%" align="center" valign="top"><a href="ports.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Using the Ports Collection</td></tr></table></div><p align="center"><small>This, and other documents, can be downloaded from <ahref="ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/">ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/</a>.</small></p><p align="center"><small>For questions about FreeBSD, read the <ahref="http://www.FreeBSD.org/docs.html">documentation</a> before contacting &#60;<ahref="mailto:questions@FreeBSD.org">questions@FreeBSD.org</a>&#62;.<br />For questions about this documentation, e-mail &#60;<ahref="mailto:doc@FreeBSD.org">doc@FreeBSD.org</a>&#62;.</small></p></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -