< Day Day Up > |
14.2. Using DarwinPortsOnce DarwinPorts has been installed, you can see what packages are available with the port list command. Since the list is quite long, you may want to pipe this command through the more command. You can also use the port command to search for specific packages. For example, the command port search pine returns a listing for the pine package; the command port search kde lists several packages, namely all available packages that contain the string kde. You can install a package from source with the command sudo port install package. This command actually performs several steps prior to installing the package on your system. These steps include checking dependencies, downloading the necessary source code including source of dependencies, verifying checksums, configuring packages, building and installing any other required packages, and building the requested package in an intermediate directory called a destroot. After these steps have been performed the requested package is installed into an "image repository" directory and "activated." Activation of a port creates hard links to the files in the image repository directory. The port command must be used with sudo whenever the directory /opt/local or /Applications/DarwinPorts is modified. For example if you installed pine-4.58 using the sudo port install pine command, pine and all its related files are installed into the image repository /opt/local/var/db/dports/software/pine/4.58_1/opt/local/bin, and then activated through the creation of hard links in the ${prefix} directory /opt/local/bin. The image repository can be revealed via the port location pine command. You can subsequently deactivate pine by issuing the command sudo port deactivate pine, which deletes the hard links in /opt/local/bin while leaving the pine installation in the image repository intact. You can later reactivate pine with the sudo port activate pine command. The chief advantage of this approach, called Port Images , is that it allows you to install multiple versions of a package. With Port Images, you won't need to uninstall one version of a package to make room for another. Instead, you can deactivate one version and activate another version.
As mentioned earlier, DarwinPorts automatically checks package dependencies and installs any other required packages. Similarly, if you deactivate a package, you are warned if the package you are deactivating is needed by another installed package. To uninstall a particular port, use the port uninstall command. For example, to uninstall pine, enter the command: sudo port uninstall pine To update a particular port, you can enter the following command: sudo port upgrade foo If a new version of foo is available, this command will deactivate the currently installed foo port, and install and activate the newer version. This command will also update all of foo's dependencies. If you want to remove the older version of foo at the same time, you should enter the following command: sudo port -u upgrade foo You can update all installed ports with the following command: sudo port -a upgrade 14.2.1. Creating and Installing Packages in pkg FormatUsing DarwinPorts, you can create a .pkg package installer using the port command with the package option, For example, to create a .pkg installer for bvi, enter the command: port package bvi This downloads the source for bvi, builds the application, and creates a double-clickable package installer, named bvi-1.3.1.pkg. This package is saved in ~/darwinports/dports/editors/bvi/work. It's worth noting that this command only creates the package; it does not install the package. To install it (in /opt/local/), double-click bvi-1.3.1.pkg in the Finder, authenticate yourself as an administrative user, and install the package on your system as you would with any other package. When you install a package in this manner, the DarwinPorts database won't list it among its installed packages. For example, if you issue the port installed command, this package won't show up in the list. If you enter the command port clean bvi, the installer bvi-1.3.1.pkg is deleted. 14.2.2. Creating and Installing Packages in RPM FormatIf you are planning to create packages in RPM format, the first thing you should do is to install rpm (via the sudo port install rpm command). Once you have installed rpm, you can create RPM packages using the port command with the rpmpackage option. For example, to create an RPM for pine, enter the following command: sudo port rpmpackage pine This command creates the RPM file in ${prefix}/src/apple/RPMS/${arch}, which in most cases is /opt/local/src/apple/RPMS/ppc. You can safely use the sudo port clean pine command after the RPM is created, since the port clean command won't remove the .rpm installer. Before installing RPM packages, however, you need to create /etc/mnttab, which is the file that keeps track of which RPM packages have been installed. This can be done with: touch /etc/mnttab A summary of the use of the port command is provided in Table 14-1.
|
< Day Day Up > |