Tuesday, February 06, 2007

Use darwinports

Using DarwinPorts
The port command

Using the DarwinPorts port command is very straight-forward. Most of the time all you need to do is execute a single command to install a port. For example, if you want to install the text editor vile, you would simply type:

sudo port install vile

That will fetch, build and install vile and anything else it needs to work. All of the examples below use the vile for as an example. You should use whatever port you actually want to install.

The port command provides several other 'actions' that can be performed:


If you aren't sure the exact name of the port you want, you can use the search option. For example, if you wanted to find out if there was anything called vile in in the ports, you could do:

port search 'vile'

The search facility uses standard regular expression syntax, so you can also do much more complex searches.
Additional Steps: fetch, configure, build, destroot, install

You may want to break up the installation of a port into a number of steps. fetch, configure, build, destroot and finally install are all available and perform part of the build or install process. Using the steps individually is not normally needeed unless you are developing a new port or trying to diagnose a problem.
Cleaning a Port

Once the port has been installed, you may want to delete all the intermediate files that DarwinPorts has created while building the port. To do this, simply use the clean option:

port clean vile

It is possible to make the clean option remove the distfile, the archive and the work directory.

To remove the ports distfile

port clean --dist vile

To remove a archive created by a port

port clean --archive vile

To remove the working directory

port clean --work vile or port clean vile

If you want to do all of the above (remove the distfile and archive, and clean the workdirectory), you can:

port clean --all vile
Getting Information about a Port

You may want to get information about a port, such as a description, its maintainer, and more. You can do this by using the info option:

port info vim
Listing available Ports

You may want a list of all the ports that are available. You can do this two ways, first by using the search option:

port search '.+'

Or, by using the list option:

port list
Discovering which ports are installed

To determine which ports have been installed, and what their versions are, use:

port installed

To determine the installed version of a particular port, use:

port installed
Discovering which ports are out-of-date

To determine which ports are out-of-date (the current Portfile provides a newer version than the installed version of the port) use:

port outdated
Contents of a Port

Once the port has been installed, you might want to check what files are associated with that port. The contents option will list all of the files that were installed by the port:

port contents vile
Variants and Dependencies

Before you install a port, you may want to check what variations of that port are available to use. Variants provide additional configuration options for a port. To see what variations a port has, use the variants option:

port variants vile

You also may want to see what dependencies a port has. You can use the deps option to check:

port deps vile

If you want to find out which ports depends on a port you have installed, use:

port dependents gettext

For more information you should look at the port manpage by entering: man port.
The portindex command

Most of the time you won't need to use this command as it is used to build the index of all the available ports, but sometimes the index you have is out of date or innacurate for some reason. When this occurs you will get an error message like 'port search failed: expected integer but got "PortIndex"'. You can fix problem by moving to the dports directory (/Users/mike/darwinports/dports in our examples) and executing: portindex. This will go through all the available ports in the dport directory and build an index file called PortIndex.
Removing ports

Ports are removed using the port command described above, simply execute the command: sudo port uninstall vile
Upgrading ports

You can check if a port is outdated with the following command:
port outdated gnome

To check if you have any outdated ports:
port outdated

To upgrade a port execute:
sudo port upgrade gnome

This will deactivate the old version and install the new, and also install the newer versions of the dependencies of the port.

If you would like to upgrade the port, but not the dependencies of the port, you can:
sudo port -n upgrade gnome

To upgrade all installed ports simply do:
sudo port upgrade installed

If you dont like that upgrade just deactivates the old version of the port, you can get it to uninstall the old version by using the -u option:
sudo port -u upgrade gnome

Using force
While upgrading you can run into cases when you have to use force (-f). This is especially true if you are upgrading a port that wants to install a file that another port allready has installed, or if you use the -u option to upgrade (and uninstall) a port that could be installed as a dependency. Allways remember to use the -f option with caution.

No comments :