diff --git a/zh_TW.Big5/books/handbook/ports/chapter.sgml b/zh_TW.Big5/books/handbook/ports/chapter.sgml index 9144a10407..5cdb59656b 100644 --- a/zh_TW.Big5/books/handbook/ports/chapter.sgml +++ b/zh_TW.Big5/books/handbook/ports/chapter.sgml @@ -1,1334 +1,1321 @@ 軟體套件管理篇:Packages 及 Ports 機制 概述 ports packages 儘管 FreeBSD 在 base system 已加了很多系統工具。 然而,在實務運用上,您可能仍需要安裝額外的軟體。 FreeBSD 提供了 2 種安裝應用程式的套件管理系統︰Ports Collection(以 soucre 來編譯、安裝) 和 package(預先編譯好的 binary 檔)。上述的方式,無論要用哪一種,都可以由像是 CDROM 等或網路上來安裝想裝的最新版軟體。 讀完這章,您將了解: 如何以 packages 來安裝軟體。 如何以 ports 來安裝軟體。 已安裝的 packages 或 ports 要如何移除。 如何更改(override) ports collection 所使用的預設值。 如何在套件管理系統中,找出想裝的軟體。 如何升級已安裝的軟體。 安裝軟體的各種方式介紹 通常要在 &unix; 系統上安裝軟體時,有幾個步驟要作: 先下載該軟體壓縮檔(tarball),有可能是原始碼或是 binary 執行檔。 解開該壓縮檔。(通常是以 &man.compress.1; , &man.gzip.1; 或 &man.bzip2.1; 壓縮的) 閱讀相關文件檔,以了解如何安裝。(通常檔名是 INSTALLREADME, 或在 doc/ 目錄下的一些文件) 如果所下載的是原始碼,可能要先修改 Makefile 或是執行 ./configure 之類的 script ,接著再編譯該軟體。 最後測試再測試與安裝。 如果一切順利的話,就這麼簡單。如果在安裝非專門設計(移植)給 FreeBSD 的軟體時出問題, 那可能需要修改一下它的程式碼,才能正常使用。 當然,我們可以在 FreeBSD 上使用上述的傳統方式來安裝軟體,但是,我們還有更簡單的選擇。 FreeBSD 提供了兩種省事的軟體管理機制: packages 和 ports。就在寫這篇文章的時候, 已經有超過 &os.numports; 個 port 軟體可以使用。 所謂的 FreeBSD package 就是別人把該應用程式編譯、打包完畢。 該 package 會包括該應用程式的所有執行檔、設定檔、文件等。 而下載到硬碟上的 package 都可透過 FreeBSD 套件管理指令來進行管理,比如: &man.pkg.add.1;、&man.pkg.delete.1;、&man.pkg.info.1;等指令。 所以,只需簡單打個指令就可輕鬆安裝新的應用程式了。 而 FreeBSD port 則是用一些檔案,來自動處理應用程式的安裝流程。 - Remember that there are a number of steps you would normally - carry out if you compiled a program yourself (downloading, - unpacking, patching, compiling, installing). The files that - make up a port contain all the necessary information to allow - the system to do this for you. You run a handful of simple - commands and the source code for the application is - automatically downloaded, extracted, patched, compiled, and - installed for you. + 請記住:如果打算自己來編譯的話,需要執行很多操作步驟(下載、解壓、patch、編譯、安裝)。 + 而 port 呢,則是涵蓋所有需要完成這些工作的必備步驟, + 所以只需打一些簡單的指令,那些原始程式碼就會自動下載、解壓、patch、編譯,直至安裝完畢。 事實上,ports 機制還可以用來產生 packages,以便他人可以用 pkg_add 來安裝,或是稍後會介紹到的其他套件管理指令。 - Both packages and ports understand - dependencies. Suppose you want to install - an application that depends on a specific library being - installed. Both the application and the library have been made - available as FreeBSD ports and packages. If you use the - pkg_add command or the ports system to add - the application, both will notice that the library has not been - installed, and automatically install the library first. + 而 packages 以及 ports 它們都是一樣,都會認 dependencies(軟體相依關係)。 + 假設:您想安裝某程式,但它有相依另一個已裝的函式庫(library), + 而在 FreeBSD 的 port 以及 package 都有這程式以及該函式庫了。 + 所以無論是用 pkg_add 指令或者 port 方式來裝該程式, + 這兩者(package、port)都會先檢查有沒有裝該函式庫,若沒有就會自動先裝該函式庫了。 - Given that the two technologies are quite similar, you might - be wondering why FreeBSD bothers with both. Packages and ports - both have their own strengths, and which one you use will depend - on your own preference. + 這兩種技術都很相似,您可能會好奇為什麼 FreeBSD 會弄出這兩種技術來呢。 + 其實,packages 和 ports 都有它們各自的長處,使用哪一種完全取決於您自己的喜好。 Package 好處在於: A compressed package tarball is typically smaller than the compressed tarball containing the source code for the application. Packages do not require any additional compilation. For large applications, such as Mozilla, KDE, or GNOME this can be important, particularly if you are on a slow system. Packages do not require any understanding of the process involved in compiling software on FreeBSD. Ports 好處在於: Packages are normally compiled with conservative options, because they have to run on the maximum number of systems. By installing from the port, you can tweak the compilation options to (for example) generate code that is specific to a Pentium IV or Athlon processor. Some applications have compile time options relating to what they can and cannot do. For example, Apache can be configured with a wide variety of different built-in options. By building from the port you do not have to accept the default options, and can set them yourself. In some cases, multiple packages will exist for the same application to specify certain settings. For example, Ghostscript is available as a ghostscript package and a ghostscript-nox11 package, depending on whether or not you have installed an X11 server. This sort of rough tweaking is possible with packages, but rapidly becomes impossible if an application has more than one or two different compile time options. The licensing conditions of some software distributions forbid binary distribution. They must be distributed as source code. Some people do not trust binary distributions. At least with source code, you can (in theory) read through it and look for potential problems yourself. If you have local patches, you will need the source in order to apply them. Some people like having code around, so they can read it if they get bored, hack it, borrow from it (license permitting, of course), and so on. To keep track of updated ports, subscribe to the &a.ports; and the &a.ports-bugs;. 在安裝軟體前,最好先看 內是否有該軟體的安全漏洞通報。 此外,也可以裝 security/portaudit,它會自動檢查所有已裝的 的軟體是否有已知的安全漏洞,另外,它還會在裝軟體的編譯過程前先行檢查。 也可以在裝了某些軟體之後,用 portaudit -F -a 來作全面強制安檢。 The remainder of this chapter will explain how to use packages and ports to install and manage third party software on FreeBSD. 尋找想裝的軟體 在安裝任何軟體之前,你必須先了解你想要什麼的軟體,以及該軟體叫做什麼名稱。 FreeBSD 上可裝的軟體清單不斷在增加中, 不過,我們很慶幸有幾種方式可以來找你想裝的軟體: FreeBSD 網站上有更新頻繁的軟體清單,在 http://www.FreeBSD.org/ports/。 - 各 ports 皆依其性質而分門別類,and you may either - search for an application by name (if you know it), or see - all the applications available in a category. + 各 ports 皆依其性質而分門別類,既可以透過軟體名稱來搜尋(如果知道名字的話), + 也可以在分類中列出所有可用的軟體。 FreshPorts - Dan Langille 維護 FreshPorts 網站,網址在 。 FreshPorts - tracks changes to the applications in the ports tree as they - happen, allows you to watch one or more - ports, and can send you email when they are updated. + 由 Dan Langille 所維護 FreshPorts 網站,網址在 。 + FreshPorts 會不斷追蹤 port tree 中的各種變化, + 也可以針對某些 port 以列入 追蹤名單(watch) 內, + 當有任何軟體升級時,就會發 email 提醒。 FreshMeat - If you do not know the name of the application you want, - try using a site like FreshMeat () to find an - application, then check back at the FreeBSD site to see if - the application has been ported yet. + 如果不知道想裝的軟體名稱,那麼可透過像是 FreshMeat () 這類的網站來找, + 如果找到了,可以回 FreeBSD 網站去看一下這個應用程式是否已經被 port 進去了。 If you know the exact name of the port, but just need to find out which category it is in, you can use the &man.whereis.1; command. Simply type whereis file, where file is the program you want to install. If it is found on your system, you will be told where it is, as follows: &prompt.root; whereis lsof lsof: /usr/ports/sysutils/lsof This tells us that lsof (a system utility) can be found in the /usr/ports/sysutils/lsof directory. Yet another way to find a particular port is by using the Ports Collection's built-in search mechanism. To use the search feature, you will need to be in the /usr/ports directory. Once in that directory, run make search name=program-name where program-name is the name of the program you want to find. For example, if you were looking for lsof: &prompt.root; cd /usr/ports &prompt.root; make search name=lsof Port: lsof-4.56.4 Path: /usr/ports/sysutils/lsof Info: Lists information about open files (similar to fstat(1)) Maint: obrien@FreeBSD.org Index: sysutils B-deps: R-deps: 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 needed in order to install the port, so it will not be covered here. For more in-depth searching you can also use make search key=string where string is some text to search for. This searches port names, comments, descriptions and dependencies and can be used to find ports which relate to a particular subject if you do not know the name of the program you are looking for. In both of these cases, the search string is case-insensitive. Searching for LSOF will yield the same results as searching for lsof. Chern Lee Contributed by 使用 Packages 管理機制 Package 的安裝方式 packages installing pkg_add 可以用 &man.pkg.add.1; 從本機上或者透過網路來安裝任一 FreeBSD package。 手動下載、安裝 Package (譯者chinsan: 這方法比較不便,建議改用 pkg_add -r ) &prompt.root; ftp -a ftp2.FreeBSD.org 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. ftp> cd /pub/FreeBSD/ports/packages/sysutils/ 250 CWD command successful. ftp> get lsof-4.56.4.tgz local: lsof-4.56.4.tgz remote: lsof-4.56.4.tgz 200 PORT command successful. 150 Opening BINARY mode data connection for 'lsof-4.56.4.tgz' (92375 bytes). 100% |**************************************************| 92375 00:00 ETA 226 Transfer complete. 92375 bytes received in 5.60 seconds (16.11 KB/s) ftp> exit &prompt.root; pkg_add lsof-4.56.4.tgz If you do not have a source of local packages (such as a FreeBSD CD-ROM set) then it will probably be easier to use the option to &man.pkg.add.1;. This will cause the utility to automatically determine the correct object format and release and then fetch and install the package from an FTP site. pkg_add &prompt.root; pkg_add -r lsof The example above would download the correct package and add it without any further user intervention. If you want to specify an alternative &os; Packages Mirror, instead of the main distribution site, you have to set PACKAGESITE accordingly, to override the default settings. &man.pkg.add.1; uses &man.fetch.3; to download the files, which honors various environment variables, including FTP_PASSIVE_MODE, FTP_PROXY, and FTP_PASSWORD. You may need to set one or more of these if you are behind a firewall, or need to use an FTP/HTTP proxy. See &man.fetch.3; for the complete list. Note that in the example above lsof is used instead of lsof-4.56.4. When the remote fetching feature is used, the version number of the package must be removed. &man.pkg.add.1; will automatically fetch the latest version of the application. &man.pkg.add.1; will download the latest version of your application if you are using &os.current; or &os.stable;. If you run a -RELEASE version, it will grab the version of the package that was built with your release. It is possible to change this behavior by overriding the PACKAGESITE environment variable. For example, if you run a &os; 5.4-RELEASE system, by default &man.pkg.add.1; will try to fetch packages from ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-5.4-release/Latest/. If you want to force &man.pkg.add.1; to download &os; 5-STABLE packages, set PACKAGESITE to ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-5-stable/Latest/. Package files are distributed in .tgz and .tbz formats. You can find them at , or on the FreeBSD CD-ROM distribution. Every CD on the FreeBSD 4-CD set (and the PowerPak, etc.) contains packages in the /packages directory. The layout of the packages is similar to that of the /usr/ports tree. Each category has its own directory, and every package can be found within the All directory. The directory structure of the package system matches the ports layout; they work with each other to form the entire package/port system. 管理 Packages packages managing &man.pkg.info.1; is a utility that lists and describes the various packages installed. pkg_info &prompt.root; pkg_info cvsup-16.1 A general network file distribution system optimized for CV docbook-1.2 Meta-port for the different versions of the DocBook DTD ... &man.pkg.version.1; is a utility that summarizes the versions of all installed packages. It compares the package version to the current version found in the ports tree. pkg_version &prompt.root; pkg_version cvsup = docbook = ... The symbols in the second column indicate the relative age of the installed version and the version available in the local ports tree. 符號 代表意義 = The version of the installed package matches the one found in the local ports tree. < The installed version is older than the one available in the ports tree. >The installed version is newer than the one found in the local ports tree. (The local ports tree is probably out of date.) ?The installed package cannot be found in the ports index. (This can happen, for instance, if an installed port is removed from the Ports Collection or renamed.) *There are multiple versions of the package. 移除已安裝的 Package pkg_delete packages deleting 若要移除已裝的軟體,那麼請多利用 &man.pkg.delete.1; 工具,比如: &prompt.root; pkg_delete xchat-1.7.1 其他細節部份 所有已裝的 package 資訊都會存到 /var/db/pkg 目錄內, 在該目錄下可以找到記載已裝的軟體檔案清單及該軟體簡介的檔案。 使用 Ports 管理機制 下面我們會介紹如何使用 Ports Collection 來安裝、移除軟體的基本用法。 至於其他可用的 make 詳細用法與環境設定,可參閱 &man.ports.7;。 記得安裝 Ports Collection 在安裝任一 ports 之前,必須先裝上 Ports Collection —— 它主要是由 /usr/ports 內一堆 Makefiles, patches 以及一些軟體簡介檔所組成的。 在裝 FreeBSD 時,若忘了在 sysinstall 內勾選要裝 Ports Collection 的話, 沒關係,可以照下列方式來安裝 ports collection: CVSup 方式 使用 CVSup 是安裝、更新 Ports Collection 的快速方法之一。 若想更瞭解 CVSup 用法的話,請參閱 使用 CVSup。 - 第一次跑 CVSup 之前,請先確認 /usr/ports - 是空的! 若你已經裝了 Ports Collection ,但又自行加上其他 patch 檔,那麼 CVSup + 第一次跑 CVSup 之前,請先確認 /usr/ports + 是空的! 若你已經裝了 Ports Collection ,但又自行加上其他 patch 檔,那麼 CVSup 並不會刪除你自行加上的 patch 檔,這樣可能會導致要安裝某些軟體時,發生 patch 失敗或編譯失敗。 安裝 net/cvsup-without-gui package: &prompt.root; pkg_add -r cvsup-without-gui 細節用法請參閱 安裝 CVSup()。 執行 cvsup &prompt.root; cvsup -L 2 -h cvsup.tw.FreeBSD.org /usr/share/examples/cvsup/ports-supfile 請把 cvsup.tw.FreeBSD.org 請改成離你比較近(快)的 CVSup Server。 這部分可以參閱完整的 CVSup mirror 站列表()。 One may want to use his own ports-supfile, for example to avoid the need of passing the CVSup server on the command line. In this case, as root, copy /usr/share/examples/cvsup/ports-supfile to a new location, such as /root or your home directory. Edit ports-supfile. Change CHANGE_THIS.FreeBSD.org to a CVSup server near you. See CVSup Mirrors () for a complete listing of mirror sites. And now to run cvsup, use the following: &prompt.root; cvsup -L 2 /root/ports-supfile Running the &man.cvsup.1; command later will download and apply all the recent changes to your Ports Collection, except actually rebuilding the ports for your own system. Portsnap 方式 &man.portsnap.8; is an alternative system for distributing the Ports Collection. It was first included in &os; 6.0. On older systems, you can install it from sysutils/portsnap port: &prompt.root; pkg_add -r portsnap Please refer to Using Portsnap for a detailed description of all Portsnap features. Create an empty directory /usr/ports if it does not exists. &prompt.root; mkdir /usr/ports Download a compressed snapshot of the Ports Collection into /var/db/portsnap. You can disconnect from the Internet after this step, if you wish. &prompt.root; portsnap fetch If you are running Portsnap for the first time, extract the snapshot into /usr/ports: &prompt.root; portsnap extract If you already have a populated /usr/ports and you are just updating, run the following command instead: &prompt.root; portsnap update Sysinstall 方式 This method involves using sysinstall to install the Ports Collection from the installation media. Note that the old copy of Ports Collection from the date of the release will be installed. If you have Internet access, you should always use one of the methods mentioned above. As root, run sysinstall (/stand/sysinstall in &os; versions older than 5.2) as shown below: &prompt.root; sysinstall Scroll down and select Configure, press Enter. Scroll down and select Distributions, press Enter. Scroll down to ports, press Space. Scroll up to Exit, press Enter. Select your desired installation media, such as CDROM, FTP, and so on. Scroll up to Exit and press Enter. Press X to exit sysinstall. Ports 的安裝方式 ports installing The first thing that should be explained when it comes to the Ports Collection is what is actually meant by a skeleton. In a nutshell, a port skeleton is a minimal set of files that tell your FreeBSD system how to cleanly compile and install a program. Each port skeleton includes: A Makefile. The Makefile contains various statements that specify how the application should be compiled and where it should be installed on your system. A distinfo file. This file contains information about the files that must be downloaded to build the port and their checksums, to verify that files have not been corrupted during the download using &man.md5.1;. A files directory. This directory contains patches to make the program compile and install on your FreeBSD system. Patches are basically small files that specify changes to particular files. They are in plain text format, and basically say Remove line 10 or Change line 26 to this .... Patches are also known as diffs because they are generated by the &man.diff.1; program. This directory may also contain other files used to build the port. A pkg-descr file. This is a more detailed, often multiple-line, description of the program. A pkg-plist file. This is a list of all the files that will be installed by the port. It also tells the ports system what files to remove upon deinstallation. Some ports have other files, such as pkg-message. The ports system uses these files to handle special situations. If you want more details on these files, and on ports in general, check out the FreeBSD Porter's Handbook. The port includes instructions on how to build source code, but does not include the actual source code. You can get the source code from a CD-ROM or from the Internet. 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 other tool or even uncompressed. The program source code, whatever form it comes in, is called a distfile. The two methods for installing a &os; port are described below. You must be logged in as root to install ports. Before installing any port, you should be sure to have an up-to-date Ports Collection and you should check for security issues related to your port. A security vulnerabilities check can be automatically done by portaudit before any new application installation. This tool can be found in the Ports Collection (security/portaudit). Consider running portaudit -F before installing a new port, to fetch the current vulnerabilities database. A security audit and an update of the database will be performed during the daily security system check. For more information read the &man.portaudit.1; and &man.periodic.8; manual pages. The Ports Collection makes an assumption that you have a working Internet connection. If you do not, you will need to put a copy of the distfile into /usr/ports/distfiles manually. To begin, change to the directory for the port you want to install: &prompt.root; cd /usr/ports/sysutils/lsof Once inside the lsof directory, you will see the port skeleton. The next step is to compile, or build, the port. This is done by simply typing make at the prompt. Once you have done so, you should see something like this: &prompt.root; make >> lsof_4.57D.freebsd.tar.gz doesn't seem to exist in /usr/ports/distfiles/. >> Attempting to fetch from ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/. ===> 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] ... &prompt.root; Notice that once the compile is complete you are returned to your prompt. The next step is to install the port. In order to install it, you simply need to tack one word onto the make command, and that word is install: &prompt.root; make install ===> 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. &prompt.root; Once you are returned to your prompt, you should be able to run the application you just installed. Since lsof is a program that runs with increased privileges, a security warning is shown. During the building and installation of ports, you should take heed of any other warnings that may appear. It is a good idea to delete the working subdirectory, which contains all the temporary files used during compilation. Not only it consumes a valuable disk space, it would also cause problems later when upgrading to the newer version of the port. &prompt.root; make clean ===> Cleaning for lsof-4.57 &prompt.root; You can save an extra step by just running make install clean instead of make, make install and make clean as three separate steps. Some shells keep a cache of the commands that are available in the directories listed in the PATH environment variable, to speed up lookup operations for the executable file of these commands. If you are using one of these shells, you might have to use the rehash command after installing a port, before the newly installed commands can be used. This command will work for shells like tcsh. Use the hash -r command for shells like sh. Look at the documentation for your shell for more information. Some third party DVD-ROM products such as the FreeBSD Toolkit from the FreeBSD Mall contain distfiles. They can be used with the Ports Collection. Mount the DVD-ROM on /cdrom. If you use a different mount point, set CD_MOUNTPTS make variable. The needed distfiles will be automatically used if they are present on the disk. Please be aware that the licenses of a few ports do not allow for inclusion on the CD-ROM. This could be because a registration form needs to be filled out before downloading or redistribution is not allowed, or for another reason. If you wish to install a port not included on the CD-ROM, you will need to be online in order to do so. The ports system uses &man.fetch.1; to download the files, which honors various environment variables, including FTP_PASSIVE_MODE, FTP_PROXY, and FTP_PASSWORD. You may need to set one or more of these if you are behind a firewall, or need to use an FTP/HTTP proxy. See &man.fetch.3; for the complete list. For users which cannot be connected all the time, the make fetch option is provided. Just run this command at the top level directory (/usr/ports) and the required files will be downloaded for you. This command will also work in the lower level categories, for example: /usr/ports/net. Note that if a port depends on libraries or other ports this will not fetch the distfiles of those ports too. Replace fetch with fetch-recursive if you want to fetch all the dependencies of a port too. You can build all the ports in a category or as a whole by running make in the top level directory, just like the aforementioned make fetch method. This is dangerous, however, as some ports cannot co-exist. In other cases, some ports can install two different files with the same filename. In some rare cases, users may need to acquire the tarballs from a site other than the MASTER_SITES (the location where files are downloaded from). You can override the MASTER_SITES option with the following command: &prompt.root; cd /usr/ports/directory &prompt.root; make MASTER_SITE_OVERRIDE= \ ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/ fetch In this example we change the MASTER_SITES option to ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/. Some ports allow (or even require) you to provide build options which can enable/disable parts of the application which are unneeded, certain security options, and other customizations. A few which come to mind are www/mozilla, security/gpgme, and mail/sylpheed-claws. A message will be displayed when options such as these are available. 更改(Override)預設的 Ports 目錄 Sometimes it is useful (or mandatory) to use a different distfiles and ports directory. The PORTSDIR and PREFIX variables can override the default directories. For example: &prompt.root; make PORTSDIR=/usr/home/example/ports install will compile the port in /usr/home/example/ports and install everything under /usr/local. &prompt.root; make PREFIX=/usr/home/example/local install will compile it in /usr/ports and install it in /usr/home/example/local. And of course, &prompt.root; make PORTSDIR=../ports PREFIX=../local install will combine the two (it is too long to completely write on this page, but it should give you the general idea). Alternatively, these variables can also be set as part of your environment. Read the manual page for your shell for instructions on doing so. Dealing with <command>imake</command> Some ports that use imake (a part of the X Window System) do not work well with PREFIX, and will insist on installing under /usr/X11R6. Similarly, some Perl ports ignore PREFIX and install in the Perl tree. Making these ports respect PREFIX is a difficult or impossible job. 移除已安裝的 Ports ports removing 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. We will remove our previous example (which was lsof for those of you not paying attention). Ports are being removed exactly the same as the packages (discussed in the Packages section), using the &man.pkg.delete.1; command: &prompt.root; pkg_delete lsof-4.57 升級已安裝的 Ports ports upgrading 首先,用 &man.pkg.version.1; 指令來列出目前 Ports Collection 中提供了那些可升級的 port 版本: &prompt.root; pkg_version -v - - <filename>/usr/ports/UPDATING</filename> - - 每次更新完 Ports Collection 之後,請務必記得在升級 port 前, + + <filename>/usr/ports/UPDATING</filename> + + 每次更新完 Ports Collection 之後,請務必記得在升級 port 前, 先看看 /usr/ports/UPDATING, 這裡會寫升級方面的各式問題,比如:檔案格式改變、變更設定檔位置、與舊版不相容的問題等, - 以及怎麼解決的完整步驟。 - - UPDATING 內容與你看到的其他文件有些不同、相衝的話, - 那麼以 UPDATING 為主。 + 以及怎麼解決的完整步驟。 + + UPDATING 內容與你看到的其他文件有些不同、相衝的話, + 那麼以 UPDATING 為主。 以 Portupgrade 來升級已安裝的 Ports portupgrade portupgrade 可以輕鬆升級已裝的軟體。 該工具可從 sysutils/portupgrade port 安裝, 安裝方式就如同其他 port 一樣,用 make install clean 指令就可以了: &prompt.root; cd /usr/ports/sysutils/portupgrade &prompt.root; make install clean 首先最好先以 pkgdb -F 來掃瞄已裝的 ports 資料庫是否有誤,並修正有問題的地方。 在每次做升級之前,最好定期做一下 pkgdb -F 動作會較為妥當。 When you run portupgrade -a, portupgrade will begin to upgrade all the outdated ports installed on your system. Use the flag if you want to be asked for confirmation of every individual upgrade. &prompt.root; portupgrade -ai If you want to upgrade only a certain application, not all available ports, use portupgrade pkgname. Include the flag if portupgrade should first upgrade all the ports required by the given application. &prompt.root; portupgrade -R firefox To use packages instead of ports for installation, provide flag. With this option portupgrade searches the local directories listed in PKG_PATH, or fetches packages from remote site if it is not found locally. If packages can not be found locally or fetched remotely, portupgrade will use ports. To avoid using ports, specify . &prompt.root; portupgrade -PR gnome2 To just fetch distfiles (or packages, if is specified) without building or installing anything, use . For further information see &man.portupgrade.1;. 以 Portmanager 來升級已安裝的 Ports portmanager Portmanager 也可以用來輕鬆升級已裝的軟體。 該工具可從 sysutils/portmanager port 安裝: &prompt.root; cd /usr/ports/sysutils/portmanager &prompt.root; make install clean 所有已裝的軟體,都可以輕鬆用類似下列指令來升級: &prompt.root; portmanager -u 此外,使用參數可以改為 ,如此一來 Portmanager 在升級一些有特殊選項的軟體時,就會詢問該如何升級。 Portmanager 也可以用來裝新 port。與以往常用的 make install clean 指令不同之處在於:它會先升級你要裝的 port 所相依的所有 ports, 然後才開始編譯、安裝要裝的 port。 &prompt.root; portmanager x11/gnome2 若要裝的 port 之軟體相依關係有問題時,也可以用 Portmanager 使它們重歸正軌。而 Portmanager 解決相依問題完畢之後,該 port 也會重新編譯,以因應正確的相依關係。 &prompt.root; portmanager graphics/gimp -f 其他運用方式,請參閱 Portmanager 的線上手冊。 Ports 與硬碟空間 ports disk-space 因為使用 Ports Collection 遲早可能會用光硬碟空間, 所以在裝完軟體後,記得要以 make clean 指令來清除臨時的 work 目錄。 此外,可以用下列指令來清除整個 Ports Collection 內的臨時目錄: &prompt.root; portsclean -C You will accumulate a lot of old source distribution files in the distfiles directory over time. You can remove them by hand, or you can use the following command to delete all the distfiles that are no longer referenced by any ports: &prompt.root; portsclean -D The portsclean utility is part of the portupgrade suite. Do not forget to remove the installed ports once you no longer need them. A nice tool to help automate this task is available from the sysutils/pkg_cutleaves port. 安裝之後,有什麼後續注意事項嗎? 通常,安裝完軟體後,我們可以閱讀所附的一些文件,或需要編輯設定檔, 來確保這個軟體能順利運作,或在機器開機的時候啟動(如果是 daemon 的話)等等。 不同的軟體會有不同的設定步驟。不管怎樣,如果裝好了軟體, 但是不知道下一步怎麼辦的時候, 可以試試看這些小技巧: 善用 &man.pkg.info.1; ,這指令可以顯示:透過套件管理系統(Packages/Ports)裝了哪些軟體、檔案裝在哪邊。舉例來說,若剛裝了 FooPackage (版本 1.0.0),那麼下面這指令: &prompt.root; pkg_info -L foopackage-1.0.0 | less 就會顯示這軟體所安裝的檔案清單。 Pay special attention to files in man/ directories, which will be manual pages, etc/ directories, which will be configuration files, and doc/, which will be more comprehensive documentation. If you are not sure which version of the application was just installed, a command like this &prompt.root; pkg_info | grep -i foopackage will find all the installed packages that have foopackage in the package name. Replace foopackage in your command line as necessary. Once you have identified where the application's manual pages have been installed, review them using &man.man.1;. Similarly, look over the sample configuration files, and any additional documentation that may have been provided. If the application has a web site, check it for additional documentation, frequently asked questions, and so forth. If you are not sure of the web site address it may be listed in the output from &prompt.root; pkg_info foopackage-1.0.0 A WWW: line, if present, should provide a URL for the application's web site. Ports that should start at boot (such as Internet servers) will usually install a sample script in /usr/local/etc/rc.d. You should review this script for correctness and edit or rename it if needed. See Starting Services for more information. 如何處理爛掉(Broken)的 Ports? 如果發現某個 port 無法順利安裝、運作, 有幾種方法可以試試看: Problem Report 資料庫 中挖寶看看,說不定已經有人送可用的 patch 上去囉, 那麼或許就可以順利解決問題哩。 向該 port 的 maintainer 尋求協助:請打 make maintainer 或翻閱 Makefile 以查詢 maintainer 的 email address。記得寄信給 maintainer 時,要附註該 port 的名稱、版本(或是把 Makefile 內的 $FreeBSD: 那一整行附上) 以及相關錯誤訊息。 有些 port 不是由專門的單一 maintainer 負責,而是透過 mailing list 的專題討論。許多(但非全部)的聯絡 email 格式通常是 freebsd-list名稱@FreeBSD.org。發問時,請記得把『freebsd-list名稱』改為相關討論的 mailing list 名稱。 尤其當 port 的 maintainer 欄位是 freebsd-ports@FreeBSD.org 時,事實上已經沒人當該 port maintainer 了。 因此若該 port 仍有修正或其他技術支援的話,相關討論都會在 freebsd-ports 郵遞論壇上出現。 喔,對了,如果有熟悉該軟體者,志願當該 port maintainer 的話,我們也都很歡迎您的加入喔。 若 port maintainer 沒有回覆您的信件, 則可以用 &man.send-pr.1; 來提交問題報告 PR。(請參閱 Writing FreeBSD Problem Reports)。 試試看修正它吧! Porter's Handbook 包括了 Ports 架構的細節部份,這些書中內容有助您修好有問題的 port 甚至提交自己的 port﹗ 從較近的 FTP 站點下載編譯好的 package。 package collection 的最上游站是在 ftp.FreeBSD.org 上的 packages 目錄內,但請記得先檢查是否已有 local mirror 站! 通常情況下這些 package 都可以直接使用,而且應該比自行編譯快一些。 用 &man.pkg.add.1; 即可順利安裝 package 。