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

📄 ports-using.html

📁 FreeBSD安装说明概述 FreeBSD 提供了一个以文字为主
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<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>===&gt;  Installing for lsof-4.57...[installation output snipped]...===&gt;   Generating temporary packing list===&gt;   Compressing manual pages for lsof-4.57===&gt;   Registering installation for lsof-4.57===&gt;  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>Note:</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>Note:</b> Some shells keep a cache of the commands that are available in thedirectories listed in the <tt class="ENVAR">PATH</tt> environment variable, to speed uplookup operations for the executable file of these commands. If you are using one ofthese shells, you might have to use the <tt class="COMMAND">rehash</tt> command afterinstalling a port, before the newly installed commands can be used. This is true for bothshells that are part of the base-system (such as <tt class="COMMAND">tcsh</tt>) andshells that are available as ports (for instance, <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/shells/zsh/pkg-descr"><ttclass="FILENAME">shells/zsh</tt></a>).</p></blockquote></div><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> Please be aware that the licenses of a few ports do not allow forinclusion on the CD-ROM. This could be because a registration form needs to be filled outbefore downloading or redistribution is not allowed, or for another reason. If you wishto install a port not included on the CD-ROM, you will need to be online in order to doso (see the <a href="ports-using.html#PORTS-INET">next section</a>).</p></blockquote></div></div><div class="SECT3"><h3 class="SECT3"><a id="PORTS-INET" name="PORTS-INET">4.5.2.2. Installing Ports from theInternet</a></h3><p>As with the last section, this section makes an assumption that you have a workingInternet connection. If you do not, you will need to perform the <ahref="ports-using.html#PORTS-CD">CD-ROM installation</a>, or put a copy of the distfileinto <tt class="FILENAME">/usr/ports/distfiles</tt> manually.</p><p>Installing a port from the Internet is done exactly the same way as it would be if youwere installing from a CD-ROM. The only difference between the two is that the distfileis downloaded from the Internet instead of read from the CD-ROM.</p><p>The steps involved are identical:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make install</kbd>&gt;&gt; lsof_4.57D.freebsd.tar.gz doesn't seem to exist in /usr/ports/distfiles/.&gt;&gt; Attempting to fetch from ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/.Receiving lsof_4.57D.freebsd.tar.gz (439860 bytes): 100%439860 bytes transferred in 18.0 seconds (23.90 kBps)===&gt;  Extracting for lsof-4.57...[extraction output snipped]...&gt;&gt; Checksum OK for lsof_4.57D.freebsd.tar.gz.===&gt;  Patching for lsof-4.57===&gt;  Applying FreeBSD patches for lsof-4.57===&gt;  Configuring for lsof-4.57...[configure output snipped]...===&gt;  Building for lsof-4.57...[compilation output snipped]...===&gt;  Installing for lsof-4.57...[installation output snipped]...===&gt;   Generating temporary packing list===&gt;   Compressing manual pages for lsof-4.57===&gt;   Registering installation for lsof-4.57===&gt;  SECURITY NOTE:       This port has installed the following binaries which execute with      increased privileges.<samp class="PROMPT">#</samp></pre><p>As you can see, the only difference is the line that tells you where the system isfetching the port distfile from.</p><p>The ports system uses <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">fetch</span>(1)</span> to download the files, which honors variousenvironment variables, including <tt class="ENVAR">FTP_PASSIVE_MODE</tt>, <ttclass="ENVAR">FTP_PROXY</tt>, and <tt class="ENVAR">FTP_PASSWORD</tt>. You may need toset one or more of these if you are behind a firewall, or need to use an FTP/HTTP proxy.See <span class="CITEREFENTRY"><span class="REFENTRYTITLE">fetch</span>(3)</span> for thecomplete list.</p><p>For users which cannot be connected all the time, the <tt class="COMMAND">make <ttclass="MAKETARGET">fetch</tt></tt> option is provided. Just run this command at the toplevel directory (<tt class="FILENAME">/usr/ports</tt>) and the required files will bedownloaded for you. This command will also work in the lower level categories, forexample: <tt class="FILENAME">/usr/ports/net</tt>. Note that if a port depends onlibraries or other ports this will <span class="emphasis"><iclass="EMPHASIS">not</i></span> fetch the distfiles of those ports too. Replace <ttclass="MAKETARGET">fetch</tt> with <tt class="MAKETARGET">fetch-recursive</tt> if youwant to fetch all the dependencies of a port too.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> You can build all the ports in a category or as a whole by running <ttclass="COMMAND">make</tt> in the top level directory, just like the aforementioned <ttclass="COMMAND">make <tt class="MAKEVAR">fetch</tt></tt> method. This is dangerous,however, as some ports cannot co-exist. In other cases, some ports can install twodifferent files with the same filename.</p></blockquote></div><p>In some rare cases, users may need to acquire the tarballs from a site other than the<tt class="MAKEVAR">MASTER_SITES</tt> (the location where files are downloaded from). Youcan override the <tt class="MAKEVAR">MASTER_SITES</tt> option with the followingcommand:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cd /usr/ports/<varclass="REPLACEABLE">directory</var></kbd></pre><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make MASTER_SITE_OVERRIDE= \    ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/ fetch</kbd></pre><p>In this example we change the <tt class="MAKEVAR">MASTER_SITES</tt> option to <ttclass="HOSTID">ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/</tt>.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> Some ports allow (or even require) you to provide build options which canenable/disable parts of the application which are unneeded, certain security options, andother customizations. A few which come to mind are <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/www/mozilla/pkg-descr"><ttclass="FILENAME">www/mozilla</tt></a>, <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/security/gpgme/pkg-descr"><ttclass="FILENAME">security/gpgme</tt></a>, and <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/mail/sylpheed-claws/pkg-descr"><ttclass="FILENAME">mail/sylpheed-claws</tt></a>. A message will be displayed when optionssuch as these are available.</p></blockquote></div></div><div class="SECT3"><h3 class="SECT3"><a id="AEN5670" name="AEN5670">4.5.2.3. Overriding the Default PortsDirectories</a></h3><p>Sometimes it is useful (or mandatory) to use a different distfiles and portsdirectory. The <tt class="MAKEVAR">PORTSDIR</tt> and <tt class="MAKEVAR">PREFIX</tt>variables can override the default directories. For example:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">make PORTSDIR=/usr/home/example/ports install</kbd></pre><p>will compile the port in <tt class="FILENAME">/usr/home/example/ports</tt> and installeverything under <tt class="FILENAME">/usr/local</tt>.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">make PREFIX=/usr/home/example/local install</kbd></pre><p>will compile it in <tt class="FILENAME">/usr/ports</tt> and install it in <ttclass="FILENAME">/usr/home/example/local</tt>.</p><p>And of course,</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">make PORTSDIR=../ports PREFIX=../local install</kbd></pre><p>will combine the two (it is too long to completely write on this page, but it shouldgive you the general idea).</p><p>Alternatively, these variables can also be set as part of your environment. Read themanual page for your shell for instructions on doing so.</p></div><div class="SECT3"><h3 class="SECT3"><a id="AEN5693" name="AEN5693">4.5.2.4. Dealing with <ttclass="COMMAND">imake</tt></a></h3><p>Some ports that use <tt class="COMMAND">imake</tt> (a part of the X Windows System) donot work well with <tt class="MAKEVAR">PREFIX</tt>, and will insist on installing under<tt class="FILENAME">/usr/X11R6</tt>. Similarly, some Perl ports ignore <ttclass="MAKEVAR">PREFIX</tt> and install in the Perl tree. Making these ports respect <ttclass="MAKEVAR">PREFIX</tt> is a difficult or impossible job.</p></div></div><div class="SECT2"><h2 class="SECT2"><a id="PORTS-REMOVING" name="PORTS-REMOVING">4.5.3. Removing InstalledPorts</a></h2><p>Now that you know how to install ports, you are probably wondering how to remove them,just in case you install one and later on decide that you installed the wrong port. Wewill remove our previous example (which was <tt class="COMMAND">lsof</tt> for those ofyou not paying attention). As with installing ports, the first thing you must do ischange to the port directory, <tt class="FILENAME">/usr/ports/sysutils/lsof</tt>. Afteryou change directories, you are ready to uninstall <tt class="COMMAND">lsof</tt>. This isdone with the <tt class="COMMAND">make deinstall</tt> command:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cd /usr/ports/sysutils/lsof</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make deinstall</kbd>===&gt;  Deinstalling for lsof-4.57</pre><p>That was easy enough. You have removed <tt class="COMMAND">lsof</tt> from your system.If you would like to reinstall it, you can do so by running <tt class="COMMAND">makereinstall</tt> from the <tt class="FILENAME">/usr/ports/sysutils/lsof</tt> directory.</p><p>The <tt class="COMMAND">make deinstall</tt> and <tt class="COMMAND">makereinstall</tt> sequence does not work once you have run <tt class="COMMAND">makeclean</tt>. If you want to deinstall a port after cleaning, use <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pkg_delete</span>(1)</span> as discussedin the <a href="packages-using.html">Packages section of the Handbook</a>.</p></div><div class="SECT2"><h2 class="SECT2"><a id="PORTS-DISK-SPACE" name="PORTS-DISK-SPACE">4.5.4. Ports and DiskSpace</a></h2><p>Using the ports collection can defiantly eat up your disk space. For this reason youshould always remember to clean up the work directories using the <ttclass="COMMAND">make <tt class="MAKEVAR">clean</tt></tt> option. This will remove the <ttclass="FILENAME">work</tt> directory after a port has been built, and installed. You canalso remove the tar files from the <tt class="FILENAME">distfiles</tt> directory, andremove the installed ports when their use has delimited.</p><p>Some users choose to limit the port categories by placing an entry in the <ttclass="FILENAME">refuse</tt> file. This way when they run the <bclass="APPLICATION">CVSup</b> application, it will not download the files in thatcategory.</p></div><div class="SECT2"><h2 class="SECT2"><a id="PORTS-UPGRADING" name="PORTS-UPGRADING">4.5.5. UpgradingPorts</a></h2><p>Keeping your ports up to date can be a tedious job. For instance, to upgrade a portyou would go to the ports directory, build the port, deinstall the old port, install thenew port, and then clean up after the build. Imagine doing that for five ports, tediousright? This was a large problem for system administrators to deal with, and now we haveutilities which do this for us. For instance the <ttclass="FILENAME">sysutils/portupgrade</tt> utility will do everything for you! Justinstall it like you would any other port, using the <tt class="COMMAND">make <ttclass="MAKEVAR">install clean</tt></tt> command.</p><p>Now create a database with the <tt class="COMMAND">pkgdb -F</tt> command. This willread the list of installed ports and create a database file in the <ttclass="FILENAME">/var/db/pkg</tt> directory. Now when you run <ttclass="COMMAND">portupgrade -a</tt>, it will read this and the ports <ttclass="FILENAME">INDEX</tt> file. Finally, <tt class="COMMAND">portupgrade</tt> willbegin to download, build, backup, install, and clean the ports which have been updated.Other utilities exist which will do this, check out the <ttclass="FILENAME">ports/sysutils</tt> directory and see what you come up with.</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="packages-using.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-nextsteps.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">使用package系统</td><td width="34%" align="center" valign="top"><a href="ports.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Post-installation Activities</td></tr></table></div></body></html>

⌨️ 快捷键说明

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