FreeBSD 6 Unleashed
If you've updated your ports tree (as described in the previous section) and the version of a port has changed, you can simply use make install to install it over the old version. This can be a bad idea, however, because most of the installed files will be the same from one version to another, so if you try to delete (using pkg_delete) an older version of the same port or package while a newer one is installed over it, you will end up deleting most of the newer version as well. If you have pkg_version output like the following, you're stuck with the earlier versions in your package database, unless you're willing to deinstall all versions of the package and then reinstall the current version: apache-1.3.12 < needs updating (port has 1.3.34) apache-1.3.14 < needs updating (port has 1.3.34) apache-1.3.17 < needs updating (port has 1.3.34) apache-1.3.19 = up-to-date with port To avoid this situation, always check for a previous version of a port before installing a new one. Use pkg_info, pkg_version, or the /var/db/pkg structure to see what's there already. If there's an earlier version, remove it, like so: # pkg_delete apache-1.3.12 You shouldn't have to worry about customized config files for the port. In the apache port, for example, the pkg-plist file contains @unexec commands, which compare the configuration files with the default ones installed by the port and delete them only if they match (they correspond to the UNEXEC commands you saw earlier in the chapter when we looked at package information with pkg_info). Even so, it's a good idea to back up important config files before removing a package or port, just in case. It's not the end of the world to leave your old versions installed, though. This provides an audit trail so you can view your system's upgrade history, and it doesn't hurt anything to have the old versions around (except that if a port's component files are reorganized, the outdated files on your system will continue to hang around uselessly taking up space, and potentially confusing any other hapless administrator with whom you might be sharing duties). Upgrading Ports with Portupgrade
To make your ports even easier to maintain and upgrade, you might want to install Portupgrade, a utility written by members of the FreeBSD team to further support the ports system. Using Portupgrade (which can be installed from the sysutils category), you can upgrade an installed port to a newer version with a single commandno need to research the current version, deinstall the old version, or any such trivial tasks. However, Portupgrade should be used with cautionits ease of use comes at the expense of some of the safeguards and consistency checks that make building from the ports the safest way to install software. For example, Portupgrade doesn't automatically upgrade all dependency packages or packages that depend on the one you're upgrading; you have to provide special command-line switches to make it do that (see man portupgrade for details). Portupgrade is intended as an expert's tool, letting you update large groups of related ports (or all your ports at once, using the -a option) with a single command, but only if you're fully aware of the dangerous implications of such a momentous action. First update your ports, using CVSup. This ensures that the makefiles in the ports tree all have the most recent versions of all the ports, so you can determine which ports need to be upgraded and to what versions. Use pkg_version to do this: # pkg_version -v pine-4.58 < needs updating (port has 4.64)
Here we see that Pine needs to be upgraded. Rather than going into /usr/ports/mail/pine4 and typing make, make install, and make clean (and deinstalling the old version to replace it with the new one), you can simply issue the following command to perform all these steps at once: [View full width] # portupgrade pine [Updating the pkgdb <format:bdb1_btree> in /var/db/pkg ... - 194 packages found (-0 +0) done] ---> Upgrading 'pine-4.58' to 'pine-4.64' (mail/pine4) ---> Building '/usr/ports/mail/pine4' ===> Cleaning for pico-4.64 ===> Cleaning for ispell-3.2.06_13 ===> Cleaning for pine-4.64 ===> Vulnerability check disabled, database not found /bin/sh pkg-install . . . ===> Compressing manual pages for pine-4.64 ===> Registering installation for pine-4.64 ===> Cleaning for pico-4.64 ===> Cleaning for ispell-3.2.06_13 ===> Cleaning for pine-4.64 ---> Cleaning out obsolete shared libraries [Updating the pkgdb <format:bdb1_btree> in /var/db/pkg ... - 195 packages found (-0 +2) ..Tip Notice at the beginning and end of the process that Portupgrade maintains its own database of installed packages, which it uses to compare against the available ports. This database provides the ability for you to look up any given file and find out what package it came from: # pkgdb /usr/local/bin/pdfopt [Updating the pkgdb <format:bdb1_btree> in /var/db/pkg ... - 195 packages found (-0 +0) done] ghostscript-gnu-7.07_11
After the process is done, use pkg_version again to verify that the port has been upgraded successfully: # pkg_version -v pine-4.64 = up-to-date with port
Tip You can use the portinstall command to install a new port without manually building it with the make command. portinstall is really just an alias for an install-only mode of portupgrade.
|
Категории