Files

719 lines
25 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<chapter id="user_info">
<chapterinfo>
<keywordset>
<keyword>
usage
</keyword>
<keyword>
introduction
</keyword>
<keyword>
user
</keyword>
<keyword>
manual
</keyword>
</keywordset>
</chapterinfo>
<title>Using MacPorts</title>
<sect1>
<title>About this chapter</title>
<para>This document provides a short guide to the basics of the
MacPorts system. The first section provides a short description
of the goals of the project and a brief comparison with other systems.
Subsequent sections describe how to get, install, and use MacPorts
on your own machines. </para>
</sect1>
<sect1 id='about_mports'>
<title>About MacPorts</title>
<para>The aim of the MacPorts project is to develop a second-
generation system for the building, installation and management of
third party software. MacPorts is mainly developed on Mac OS X,
however by design it is quite portable and is intended to work on
other UNIX-like systems, especially *BSD and hopefully Linux-based
systems. </para>
<para>MacPorts is probably best described by comparison: It's sort
of like the <ulink url='http://www.freebsd.org/ports/'>FreeBSD ports
collection</ulink> or <ulink url='http://www.finkproject.org/'>Fink</ulink>
in that it automates the process of building third party software for
Mac OS X and other operating systems. MacPorts also tracks all
dependency information for a given piece of software. In other words,
it knows what it needs to build and install and in what order for the
piece of software you want to work properly. MacPorts knows how to
make, build and install the software to a specific location, meaning
that software installed via MacPorts doesn't simply scatter itself
all over the system or require user knowledge of dependencies in what
order. </para>
<para>The FreeBSD Ports Collection is a large set of software packages
ported to FreeBSD. The ports collection is also used on the other "free"
BSDs. The FreeBSD Ports Collection is based on a large tree of ports
where each software has a directory within a category (like mail or
graphics). That directory contains the information needed to build the
piece of software. MacPorts also uses a directory structure like this,
although unlike FreeBSD ports the intention is to avoid requiring a
complete copy of the 'Ports Tree' on every user's machine. The FreeBSD
Ports Collection is essentially implemented as some very impressive but
hairy BSD make(1)'s macros and can be opaque and non-extensible from
the perspective of someone looking to extend or refactor parts of the
system. Given that makefiles aren't the easiest thing to parse or for
non-developers to understand, it is also harder to "mine" the FreeBSD
ports collection for data to use for other purposes such as
generating documentation indexes or arbitrary front-ends for
creating or managing ports. </para>
<para>A ports collection can be considered an 'expert system' that
knows the sources, dependencies, and other information necessary to
*build* a given Open Source project. A package management system relies
on similar dependency information, but is focused on safely installing
(and de-installing) software. Before MacPorts, most systems did
both at once; MacPorts, however, is explicitly designed as a pure
ports collection which can use various package management systems.
</para>
<para>Even discounting some of the limitations of The FreeBSD Ports
Collection described above, creating automated build systems is rather
more complex than it looks at first glance and there's always room for
fresh approaches to the problem. Which is what we have set out to do
with MacPorts. There are certainly other systems, some of which have
already been mentioned, which have made their own attempts at solving
this problem. There will likely be many more such systems in the future
since trying to find a single solution which pleases everyone is rather
like trying to find a single programming language which pleases everyone
- it's more or less impossible. </para>
<para>MacPorts is mostly written in Tcl, with some components written
in C. Tcl was chosen to allow MacPorts to be readily embedded in other
applications (e.g. a Cocoa GUI) and to allow flexible, but easy to read
Portfiles. </para>
<para>Even though MacPorts is written in Tcl, users do not need to know
Tcl in order to use the system or even to add new ports. Port description
files, though they are actually full Tcl programs in their own right, are
designed to look like a simple list of key/value pairs. </para>
</sect1>
<sect1 id='setup'>
<title>Installing MacPorts</title>
<sect2 id='prerequisites'>
<title>What you need</title>
<para>MacPorts primary target platforms are Mac OS X 10.4
"Tiger" and Mac OS X 10.3 "Panther" (i. e. Darwin 8.x and 7.x).
However,
MacPorts should still work on Mac OS X 10.2 "Jaguar", although
most ports are no longer tested on Jaguar. MacPorts was previously
known to work on various other operating systems such as FreeBSD,
NetBSD, OpenBSD, and various Linux distributions, but the MacPorts
project is no longer supports them.</para>
<para>To install and use MacPorts you must install the Developer
tools (gcc, autoconf etc on other platforms, also known as the
"Xcode tools" on Mac OS X 10.3 and 10.4.).
All the other prerequisites are
pre-installed on Mac OS X 10.2 and later. On other platforms you
will need to ensure you have installed Tcl (8.3 or later). </para>
</sect2>
<sect2 id='getting_mports'>
<title>Obtaining MacPorts</title>
<para>Currently there are basically two ways to obtain MacPorts.
Either download the sources as a tarball or get the binary
installer via the downloadable disk image (both available in the
<ulink url='http://trac.macports.org/projects/macports/browser/downloads/'>
download section</ulink>). If you choose the binary installer, you can skip
the next sections.</para>
<para>If you want greater control and want to e. g. specify one of
the various install-time options, you need to get the sources.
</para>
<para>If you want to very closely track the latest ports and use
the latest experimental features of the port tool, you may want to
use svn to check out the sources from our svn repository.</para>
</sect2>
<sect2 id='install_mports'>
<title>Installing MacPorts from sources</title>
<para>To install MacPorts execute the following commands from the
macports/base directory. These commands assume that you checked
out the macports tree from Subversion or downloaded and extracted the
tarball in your home directory. Modify
the <userinput>cd</userinput> command appropriately if you did
otherwise.
<programlisting><![CDATA[% cd ~/macports/base
% ./configure
% make
% sudo make install]]></programlisting>
This will compile and install all the necessary software. In order
to install MacPorts on *BSD the default group-ownership must be
passed to each make command: <userinput>make DSTGRP=wheel
</userinput>.</para>
</sect2>
<sect2 id='configure_mports'>
<title>Configuring for MacPorts</title>
<para>It is no longer necessary to edit
<filename>${prefix}/etc/macports/sources.conf</filename> after installing
MacPorts. If you change the location of the
<filename>mports</filename> directory, which was in
<filename>~/macports/mports</filename> based on the above
examples, then you will still need to edit
<filename>${prefix}/etc/macports/sources.conf</filename> and modify the
<userinput>file:///Users/mike/macports/mports</userinput> line
to reflect the new location. To edit the file you must use a
command line text editor like pico or vi. </para>
<note><para>Please note, if you are using Mac OS X 10.2 "Jaguar", then
you will need to edit <filename>${prefix}/etc/macports/macports.conf</filename> and
change: <computeroutput>portinstalltype image</computeroutput>
to: <userinput>portinstalltype direct</userinput></para></note>
<para>You should add /opt/local/bin (or wherever you chose to
install MacPorts) to your shell's path.</para>
<para>If you are using Mac OS X 10.3 "Panther", Mac OS X 10.4 "Tiger"
or a Bourne shell (bash, zsh), add the following line to your
<filename>~/.profile</filename>:</para>
<para><userinput>export PATH=$PATH:/opt/local/bin</userinput></para>
<para>If you are using Mac OS X 10.2 "Jaguar" or a C shell (tcsh),
add the following line to your
<filename>~/.cshrc</filename>:</para>
<para><userinput>set path=($path /opt/local/bin)</userinput></para>
<para>These changes will not take effect until you have opened a
new shell. If you upgraded your Mac OS X installation from 10.2,
you might still have a C shell as login shell.</para>
<para>Once you have got this far, you should have a working
installation of MacPorts, you have installed the 'port'
command (by default this installed as
<filename>/opt/local/bin/port</filename>)
and the libraries it needs (in
<filename>/opt/local/share/macports</filename>
and <filename>/Library/Tcl/macports1.0</filename> by
default.)
</para>
</sect2>
<sect2 id='updating_mports'>
<title>Updating MacPorts</title>
<para>New ports are always being added to the MacPorts mports
tree, you should regularly update your tree to get access to new
ports, and (hopefully) improved versions of current ports.
Currently the simplest way you can update the mports tree is to use
the selfupdate feature of port.
To start a (rsync based) selfupdate, just issue
<command>port sync</command>.
</para>
<para>Updating your port tool is equally easy to accomplish. If
you are using at least version 1.0 of port,
<command>port selfupdate</command>
will update the sources of port, recompile and install them for you
with the same options you installed your current version of port.
</para>
<variablelist>
<varlistentry>
<term>Updating your MacPorts ports</term>
<listitem>
<para>To get the latest Portfiles (the instructions for
building ports), you need to update your
<filename>mports</filename> tree via
<programlisting><![CDATA[%port sync]]></programlisting>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Updating your MacPorts infrastructure</term>
<listitem>
<para>To get the latest MacPorts infrastructure (or
"base") for building ports, you need to update your
<filename>base</filename> via
<programlisting><![CDATA[% port selfupdate]]></programlisting>
</para>
<!--
More comments here about what to expect of port
selfupdate
-->
</listitem>
</varlistentry>
</variablelist>
</sect2>
</sect1>
<sect1>
<title>Using MacPorts</title>
<sect2 id='port'>
<title>The port command</title>
<!--
<para>Using MacPorts is very straightforward, 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'd
simply execute the command <userinput>sudo port install vile
</userinput>. That will fetch, build and install vim and anything
else vim needs to work. All of the examples below use the vile
port as an example, you should use whatever port you actually
want to install.</para>
<para>If you aren't sure of the exact name of your port you can
use the search feature. For example, if you wanted to find out
if there was anything called vile in the ports you could do:
<userinput>port search 'vile'</userinput>. The search facility
uses standard regular expression syntax, so you can list all
the ports by doing: <userinput>port search '.+'</userinput>.</para>
<para>You can see more detail of what is happening when you
install a port by using the verbose (-v), or debug (-d) flags
when using the port install command, to see all the possible
output use them both together: <userinput>port -v -d install
vile</userinput>. </para>
<para>You may break up the installation of a port into a number of
steps, fetch, checksum, configure, build, and finally install. Each
of these steps performs a part of the process to install a port,
using the steps individually is however not normally needed unless
you are developing a new port or are trying to diagnose a
problem. </para>
<para>Once the port has been installed, you may want to delete
all the intermediate files that MacPorts has created while
building the port, to do this you should enter:
<userinput>port clean vile</userinput>.</para>
-->
<para>Using the MacPorts <userinput>port</userinput> 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:</para>
<para><userinput>sudo port install vile</userinput></para>
<para>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.</para>
<para>The <userinput>port</userinput> command provides several
other 'actions' that can be performed:</para>
<variablelist>
<varlistentry>
<term>Searching</term>
<listitem>
<para>If you aren't sure the exact name of the port you
want, you can use the <userinput>search</userinput> option.
For example, if you wanted to find out if there was anything
called vile in in the ports, you could do:</para>
<para><userinput>port search 'vile'</userinput></para>
<para>The search facility uses standard regular expression
syntax, so you can also do much more complex
searches.</para>
<!--
Examples of such regexs, and where to go to learn
more about them.
-->
</listitem>
</varlistentry>
<varlistentry>
<term>Additional Steps: fetch, configure, build, destroot,
install</term>
<listitem>
<para>You may want to break up the installation of a port
into a number of steps. <userinput>fetch</userinput>,
<userinput>configure</userinput>,
<userinput>build</userinput>,
<userinput>destroot</userinput> and finally
<userinput>install</userinput> are all available and perform
part of the build or install process. Using the steps
individually is not normally needed unless you are
developing a new port or trying to diagnose a
problem.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>Cleaning a Port</term>
<listitem>
<para>Once the port has been installed, you may want to
delete all the intermediate files that MacPorts has
created while building the port. To do this, simply use the
<userinput>clean</userinput> option:</para>
<para><userinput>port clean vile</userinput></para>
<para>It is possible to make the <userinput>clean</userinput> option
remove the distfile, the archive and the work directory.</para>
<para>To remove the ports distfile</para>
<para><userinput>port clean --dist vile</userinput></para>
<para>To remove a archive created by a port</para>
<para><userinput>port clean --archive vile</userinput></para>
<para>To remove the working directory</para>
<para><userinput>port clean --work vile </userinput> or
<userinput>port clean vile</userinput></para>
<para>If you want to do all of the above (remove the distfile and
archive, and clean the workdirectory), you can:</para>
<para><userinput>port clean --all vile</userinput></para>
</listitem>
</varlistentry>
<varlistentry>
<term>Getting Information about a Port</term>
<listitem>
<para>You may want to get information about a port, such as
a description, its maintainer, and more. You can do this by
using the <userinput>info</userinput> option:</para>
<para><userinput>port info vim</userinput></para>
</listitem>
</varlistentry>
<varlistentry>
<term>Listing available Ports</term>
<listitem>
<para>You may want a list of all the ports that are
available. You can do this two ways, first by using the
<userinput>search</userinput> option:</para>
<para><userinput>port search '.+'</userinput></para>
<para>Or, by using the <userinput>list</userinput>
option:</para>
<para><userinput>port list</userinput></para>
</listitem>
</varlistentry>
<varlistentry>
<term>Discovering which ports are installed</term>
<listitem>
<para>To determine which ports have been installed, and
what their versions are, use:</para>
<para><userinput>port installed</userinput></para>
<para>To determine the installed version of a particular port,
use:</para>
<para><userinput>port installed &lt;portname&gt;</userinput></para>
</listitem>
</varlistentry>
<varlistentry>
<term>Discovering which ports are out-of-date</term>
<listitem>
<para>To determine which ports are out-of-date (the current
Portfile provides a newer version than the installed version
of the port) use:</para>
<para><userinput>port outdated</userinput></para>
</listitem>
</varlistentry>
<varlistentry>
<term>Contents of a Port</term>
<listitem>
<para>Once the port has been installed, you might want to
check what files are associated with that port. The
<userinput>contents</userinput> option will list all of the
files that were installed by the port:</para>
<para><userinput>port contents vile</userinput></para>
</listitem>
</varlistentry>
<varlistentry>
<term>Variants and Dependencies</term>
<listitem>
<para>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
<userinput>variants</userinput> option:</para>
<para><userinput>port variants vile</userinput></para>
<para>You also may want to see what dependencies a port has.
You can use the <userinput>deps</userinput> option to
check:</para>
<para><userinput>port deps vile</userinput></para>
<para>If you want to find out which ports depends on a
port you have installed, use:</para>
<para><userinput>port dependents gettext</userinput></para>
<!--
Clarification that it is only the _installed_ ports
that depend on gettext, not all the ones that can?
-->
</listitem>
</varlistentry>
</variablelist>
<para>For more information you should look at the port manpage
by entering: <userinput>man port</userinput>.</para>
</sect2>
<sect2 id='portindex'>
<title>The portindex command</title>
<para>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 mports directory
(/Users/mike/macports/mports in our examples) and
executing: <userinput>portindex</userinput>. This will go
through all the available ports in the mport directory and
build an index file called PortIndex.</para>
</sect2>
<sect2 id='uninstall_mports'>
<title>Removing ports</title>
<para>Ports are removed using the port command described above,
simply execute the command:
<userinput>sudo port uninstall vile</userinput></para>
</sect2>
<sect2 id='upgrade_mports'>
<title>Upgrading ports</title>
<para>You can check if a port is outdated with the following command:
</para>
<userinput>port outdated gnome</userinput>
<para>To check if you have any outdated ports:</para>
<userinput>port outdated</userinput>
<para>To upgrade a port execute:</para>
<userinput>sudo port upgrade gnome</userinput>
<para>This will deactivate the old version and install the new, and
also install the newer versions of the dependencies of the port.</para>
<para>If you would like to upgrade the port, but not the dependencies
of the port, you can:</para>
<userinput>sudo port -n upgrade gnome</userinput>
<para>To upgrade all installed ports simply do:</para>
<userinput>sudo port upgrade installed</userinput>
<para>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:</para>
<userinput>sudo port -u upgrade gnome</userinput>
<para>Using force</para>
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.
</sect2>
</sect1>
<sect1 id='troubleshooting_use'>
<title>Troubleshooting</title>
<para>There are a number of common problems so before you report a
problem (details on how to <link linkend='user_bugs'>report problems</link>
follow) check that the problem is described here, or in the
<ulink url='http://trac.macports.org/projects/macports/wiki/FAQ'>
FAQ</ulink> first.</para>
<sect2>
<title>Common errors and problems</title>
<sect3 id='E_port_search'>
<title>port search failed: expected integer but got
"PortIndex"</title>
<para>This means your PortIndex file is incorrect or
potentially corrupted, run the <link linkend='portindex'>
portindex</link> command</para>
</sect3>
<sect3 id='E_port_activation'>
<title>port activate failed: Image error: "filename" is being
used by the active "portname" port. Please deactivate
this port first.</title>
<para>This means that the port your are trying to install wants to
overwrite a file that is installed already. You can :</para>
<para>Force activation by using -f like: <userinput>sudo port -f
activate vile</userinput> remember to take caution when using force.</para>
<para>Try to figure out why the conflict occurs and email the
port maintainer a fix, or even better submit the fix to Trac.</para>
</sect3>
</sect2>
<sect2 id='user_bugs'>
<title>Bug reports</title>
<para>If the you have updated your ports tree, searched the
macports-dev@lists.macosforge.org mailling list archives and read the
common problems and the FAQ and you still can't find the answer
to the problem, you should submit a bug report via Trac.</para>
<para>The following section describes in some more detail how
to use Trac to submit your port.</para>
<sect3>
<!--
More details are needed for this in general
-->
<title>Submission parameters</title>
<variablelist>
<varlistentry id='Project'>
<term>
Project:
</term>
<listitem>
<para>Make sure you select the MacPorts
project.</para>
</listitem>
</varlistentry>
<varlistentry id='Component'>
<term>
Component:
</term>
<listitem>
<para>Select "mports" as the component. </para>
</listitem>
</varlistentry>
<varlistentry id='Assigned_to'>
<term>
Assigned to:
</term>
<listitem>
<para>Please assign updates, bug reports and
comments on existing ports to the maintainer.
Otherwise, if this is a new port or an RFC,
please leave blank</para>
<!--
Is this still the procedure we wish to recommend?
-->
</listitem>
</varlistentry>
<varlistentry id='URL'>
<term>
URL:
</term>
<listitem>
<para>You may use this field to point to the
port output if it is available online.</para>
</listitem>
</varlistentry>
<varlistentry id='Summary'>
<term>
Summary:
</term>
<listitem>
<para>Please use this format
<userinput>BUG: portname-1.2.3</userinput> for
the submission of port installation failures. </para>
</listitem>
</varlistentry>
<varlistentry id='Description'>
<term>
Description:
</term>
<listitem>
<para>The description field should contain the
following information as per the example given
here here. </para>
<programlisting>
<![CDATA[Portname-1.2.3
the error log can be found here: URL or ATTACHED or INLINE
Description: What the problem was in a nutshell,
Comments: Any comments you have about the port, bug diagnosis steps,
concerns, lookouts, dependencies that you may want to mention.
================INLINE CONTENT================
--
your sig if you'd like]]> </programlisting>
</listitem>
</varlistentry>
</variablelist>
</sect3>
</sect2>
</sect1>
</chapter>