]> Using MacPorts This chapter describes using port, port variants, common tasks and port binaries.
The port Command port is the main utility used to interact with MacPorts. It is used to update Portfiles and the MacPorts infrastructure, and install and manage ports. Note that not all actions are listed here; see port(1) for the full list.
port help The action shows some brief information about the specified action, or if no action is specified, shows basic usage information for port in general. $ port help selfupdate Usage: selfupdate --no-sync Upgrade MacPorts itself and run the sync target --no-sync Do not run the sync target, i.e., do not update the ports tree. Only checks for (and installs, if available) new versions of MacPorts.
port selfupdate The action should be used regularly to update the local ports tree with the global MacPorts ports repository so you will have the latest versions of software packages available. It also checks for new releases of MacPorts itself, and upgrades it when necessary. $ sudo port selfupdate ---> Updating MacPorts base sources using rsync MacPorts base version &macports-version; installed, MacPorts base version &macports-version; downloaded. ---> Updating the ports tree ---> MacPorts base is already the latest version If detects that a newer version of MacPorts is available, it automatically updates the installed copy of MacPorts base to the latest released version. In that case, you will see this message: ---> Updating MacPorts base sources using rsync MacPorts base version &macports-prev-version; installed, MacPorts base version &macports-version; downloaded. ---> Updating the ports tree ---> MacPorts base is outdated, installing new version &macports-version; Installing new MacPorts release in /opt/local as root:admin; permissions 755 If the procedure fails you'll see a message like this: Error installing new MacPorts base: command execution failed As always, you can use the debug flag to enable verbose output. If your failed, re-run it with debug output enabled to see all output generated by the build system. $ sudo port -d selfupdate The output may give you an idea why the build failed. Look for the first occurrences of error. If you cannot figure out what's wrong yourself, feel free to ask on the macports-users@lists.macports.org mailing list and attach the output generated by sudo port -d selfupdate. accepts a single switch: Only update MacPorts itself, do not update the tree of Portfiles.
port sync The action performs a subset of . It synchronizes the ports tree, as does , but it does not check for MacPorts upgrades. On macOS, unless there is a special reason not to do so, run selfupdate instead. does not accept any switches.
port diagnose The action checks for common issues in the user's environment and reports all issues it finds to the user, along with possible fixes for said problem. accepts a single switch: Only displays warnings and errors, rather than the status of all tests run.
port reclaim The action attempts to reclaim space by uninstalling inactive ports, and removing unnecessary files that were downloaded during the installation process. accepts switches to configure automatic reminders. If passed, the reclaim process will not be run. Enable regular reminders to run port reclaim. Disable regular reminders to run port reclaim.
port list The action lists the currently available version of the specified ports, or if no ports are specified, displays a list of all available ports. The list of available ports is very long, so use search if you are looking for a specific port. $ port list port list always lists the most recent version available in MacPorts, which is not necessarily the version you have installed. For this reason, port list installed likely produces unexpected output. In most cases where you would , using or is the better choice instead. Both port installed and port echo installed would produce the output you might expect from the command, port list installed will not (and, to make matters worse, will be slow). You will hardly need port list at all to work with MacPorts. When searching, port search is the better choice and when trying to list ports, port installed and port echo are much more useful.
port search The action allows finding ports by partial matches of the name or description. Other fields can be matched against, and matched in different ways, by using options. port search is the tool of choice if you are looking for a specific software in MacPorts. We recommend you read up on some of its flags to improve your efficiency when searching for ports. Run port help search for an exhaustive list of possible switches. Suppose you are looking for PHP in MacPorts. You might start with port search php and notice your query produces a lot of output. In fact, at the time of writing this, this search produces 661 matches. By default, port search searches both name and description of a port. While we're looking for PHP, we can reduce the number of hits by using the flag. Furthermore, we only want ports whose name starts with php, so we add the flag (actually, we could leave it out because it is the default) and modify the search term to php*: $ port search --name --glob 'php*' Furthermore, we can enable compact output by using the switch. This causes only a single line to be printed for each match: $ port search --name --line --glob 'php*' Among a large number of PHP modules you will find the main PHP ports, which are named php<version>. Choose one to install. If you know regex and know about the format of the PHP versions, you can further reduce the output of port search: $ port search --name --line --regex '^php\d*$' php 5.5 lang www PHP: Hypertext Preprocessor php4 4.4.9 lang www PHP: Hypertext Preprocessor php5 5.3.28 lang www PHP: Hypertext Preprocessor php52 5.2.17 lang www PHP: Hypertext Preprocessor php53 5.3.28 lang www PHP: Hypertext Preprocessor php54 5.4.31 lang www PHP: Hypertext Preprocessor php55 5.5.15 lang www PHP: Hypertext Preprocessor php56 5.6.0RC2 lang www PHP: Hypertext Preprocessor Let us look at another example that is less complicated. Assuming you are looking for rrdtool, a popular system to store and graph time-series data, the simple search approach works well: $ port search rrd cacti @0.8.8b (net) Cacti is a complete RRDtool network graphing solution. jrrd @1.0.4 (java) Java interface to RRDTool netmrg @0.20 (net) An RRDtool frontend for network monitoring, reporting, and graphing that generates day/week/month MRTG style graphs. network-weathermap @0.97c (net) Weathermap is a network visualisation tool, to take graphs you already have and display an overview of your network as a map. It supports RRD, MRTG (RRD and old log-format), and tab-delimited text files. Other sources are via plugins or external scripts. php-rrd @1.1.3 (php, net, devel) PHP rrdtool extension php5-rrd @1.1.3 (php, net, devel) PHP rrdtool extension php5-rrdtool @1.0.5 (php, net, devel) this port is only a stub and has been made obsolete by php5-rrd php53-rrd @1.1.3 (php, net, devel) PHP rrdtool extension php54-rrd @1.1.3 (php, net, devel) PHP rrdtool extension php55-rrd @1.1.3 (php, net, devel) PHP rrdtool extension rrdtool @1.4.7_5 (net) Round Robin Database Found 11 ports. The possible switches to and their meaning are: Match the search string in a case-sensitive manner. Match the literal search string exactly. Treat the given search string as glob search string (i.e., expand wildcards , , and ). This is the default behavior. Treat the given search string as regular expression. Test the search string against <field>. Can be specified multiple times to test against multiple fields. The default is . Possible values for <field> are , Search for ports in a given category. , , , , , Search for ports that depend on the port given as search string. The is an alias for all other options combined. Note that only dependencies specified in default variants will be found. , Test the search string against ports' descriptions. Test the search string against the homepage field of all ports. , Search for ports maintained by a specific maintainer. Search only ports' names. Test the search string against the path of the directory that contains the port. , Search for variant names.
port info The action is used to get information about a port: name, version, description, variants, homepage, dependencies, license, and maintainers. $ port info yubico-pam yubico-pam @2.16 (security) Variants: universal Description: The Yubico PAM module provides an easy way to integrate the YubiKey into your existing user authentication infrastructure. The module can be configured to validate YubiKeys against Yubico's YubiCloud infrastructure, a custom YubiKey validation server or it can be used for offline authentication with newer YubiKeys supporting a challenge-response protocol. Homepage: https://github.com/Yubico/yubico-pam Build Dependencies: pkgconfig, autoconf, automake, libtool Library Dependencies: ykpers, yubico-c-client Platforms: darwin License: BSD Maintainers: cal@macports.org
port deps The action lists the dependencies of a port. Dependencies are the packages required by a port at runtime (library and runtime dependencies) or required to build it (build, fetch, extract, and patch dependencies), or required to run its test suite (test dependencies). $ port deps apache2 Full Name: apache2 @2.2.27_0+preforkmpm Library Dependencies: apr, apr-util, expat, openssl, pcre, perl5, zlib Note that the list of dependencies might depend on the variants you chose. For example, choosing the variant of adds a dependency on : $ port deps apache2 +openldap Full Name: apache2 @2.2.27_0+openldap+preforkmpm Library Dependencies: apr, apr-util, expat, openssl, pcre, perl5, zlib, openldap accepts three switches: Do not read the Portfile to determine dependencies. Instead, rely on the information cached in the port index. Note that (despite specifying them), this option will ignore any effects of variants. It is, however, much faster. Exclude dependencies only required at build time, i.e., fetch, extract, patch, and build dependencies. Exclude test dependencies.
port rdeps The action is like , but operates recursively. That is, each of the ports that the given port depends on is listed, and then for each of those ports, its dependencies are listed, and so on. Unlike , the output is also not split into sections for each dependency type, each port is simply listed on its own line with a level of indentation indicating how many levels deep the dependency occurs. $ port rdeps gettext The following ports are dependencies of gettext @0.22.5_0: ncurses gettext-tools-libs libiconv gperf libtextstyle gettext-runtime accepts four switches: Normally, each distinct port is only shown in the output once. This option instead prints a line for every dependency encountered in a full traversal of the dependency graph. Beware, this can produce extremely large amounts of output for some ports. Do not read the Portfile to determine dependencies. Instead, rely on the information cached in the port index. Note that (despite specifying them), this option will ignore any effects of variants. It is, however, much faster. Exclude dependencies only required at build time, i.e., fetch, extract, patch, and build dependencies. Exclude test dependencies.
port variants The action allows you to check what variations of a port are available before you install it. Variants are a way for port authors to provide options you can use to customize your build at install time. See Invoking Port Variants below to install ports that have variants. $ port variants apache2 +universal apache2 has the variants: eventmpm: Use event MPM (experimental) * conflicts with preforkmpm workermpm openldap: Enable LDAP support through OpenLDAP [+]preforkmpm: Use prefork MPM * conflicts with eventmpm workermpm +universal: Build for multiple architectures workermpm: Use worker MPM * conflicts with eventmpm preforkmpm This output lists all variants followed by their description. If a variant depends on or conflicts with other variants, a line detailing that follows. A variant name prefixed by indicates that it has been enabled (on the command line), while a prefix indicates that it has been disabled. When bracketed, a prefix means that the variant is enabled by default. Any are derived from the Portfile. While are derived from the variants.conf. See for more information on variants.conf.
port install The action is used to install a port. Once you determined the name of a port you want (possibly using port search), you can install it using this command. See on how to choose variants when installing a new port. For example, $ sudo port install apache2 -preforkmpm +workermpm installs the port without the , but with the variant. If the installation of a port fails, you can enable verbose or debug output by giving the or flag to port: $ sudo port -v install apache2 All debug information is also kept in main.log for the port you installed. Its path will be printed automatically if the installation fails. You can manually get the path using port logfile portname. Note that logfiles will automatically be deleted on successful installation. If the installation of a port fails, you should always clean and try again, i.e., run $ sudo port clean portname and re-execute the command you ran before. You might also want to try enabling trace mode, which can prevent conflicts caused by files installed by other ports or in common system locations, such as /usr/local. To do that, re-run the installation with the flag, i.e., $ sudo port -t install portname If the port still fails to install after you have followed these steps, please file a ticket and attach the main.log of a clean attempt. The installation of a single port consists of multiple phases. These phases are fetch, extract, patch, configure, build, destroot, archive, and finally install. You may break up a port's installation into smaller steps for troubleshooting by using the name of one of these phases as action rather than . For example $ sudo port destroot apache2 will run the installation of until the destroot phase. See for a complete list of phases and a detailed description. takes the following switches: By default, a binary sanity check called is run automatically after each successful installation. Pass this flag, if you want to avoid running this step, for example if you want to run it explicitly later after a number of installations using sudo port rev-upgrade, or if you know it will detect problems but want to defer dealing with them. By default, each port you install using the explicitly (contrary to ports installed as a dependency of a different port) is marked as requested. If you want MacPorts to treat a port you installed manually as if it was automatically installed as a dependency (e.g., if a dependency failed to build and you re-tried installing the dependency only), pass this flag.
port notes The action is used to display any notes that a port's author included. These can contain anything, but by convention are brief, and typically contain quick start steps for configuring and using the port, pitfalls to watch out for, or other information that users should be aware of. These same notes are also displayed after installing a port. Many ports have no notes. More extensive documentation can often be found at a port's homepage, or in its installed files. $ port notes xinit ---> xinit has the following notes: To use MacPorts' X11 as the default server, install xorg-server, log out, and log back in.
port clean The action deletes intermediate files created by MacPorts while installing a port. A port clean is often necessary when builds fail and should be the first thing to try after a failed installation attempt. $ sudo port clean portname port clean can also be used to remove corrupted downloads after a failed phase, by specifying the flag: $ sudo port clean --dist portname deletes all files that have been downloaded for the given port. accepts the following options: Remove temporary archives. Remove downloaded files. Remove log files. Remove the work directory, i.e., the directory used by MacPorts to build a software. This removes all traces of an attempted build and is the default operation. All of the above combined.
port uninstall The action will remove an installed port. It is one of the actions you will use fairly often in MacPorts. $ sudo port uninstall portname MacPorts will refuse to uninstall ports that are still needed by other ports. For example: $ sudo port uninstall libcomerr ---> Unable to uninstall libcomerr @1.42.9_0, the following ports depend on it: ---> kerberos5 @1.11.3_0 ---> subversion @1.8.9_0 ---> subversion-perlbindings-5.16 @1.8.9_0 Error: port uninstall failed: Please uninstall the ports that depend on libcomerr first. You can recursively uninstall all ports that depend on the given port before uninstalling the port itself to work around this. To do that, use the flag. $ sudo port uninstall --follow-dependents libcomerr You can also override this safety check using the (force) flag. Since this will obviously break the dependents you shouldn't do this unless you know what you are doing. $ sudo port -f uninstall libcomerr Uninstalling a port will not uninstall ports that have been automatically installed as dependencies of the uninstalled port and are otherwise unused. You can trigger this behavior by passing the flag. Ports that were manually installed (i.e., are marked as requested) or have other dependents will not be removed. You can manually uninstall the unneeded ports later using the pseudo-port, e.g., using sudo port uninstall leaves. supports the following switches: Recursively uninstall ports that depend on the specified port before uninstalling the port itself. See also the textual description above. Also uninstall ports that were automatically installed as dependencies of the removed port and are no longer needed. Avoid running any uninstall hooks, such as commands that update cache files.
port contents The action displays a list of all files that have been installed by a given port. You can only use for ports you installed. $ port contents xorg-renderproto Port xorg-renderproto contains: /opt/local/include/X11/extensions/render.h /opt/local/include/X11/extensions/renderproto.h /opt/local/lib/pkgconfig/renderproto.pc /opt/local/share/doc/renderproto/renderproto.txt Common uses for are finding the location of a port's executable after installing it. The following line is usually helpful in this case: $ port -q contents portname | grep -E '/s?bin/' The (quiet) flag suppresses the header line in this case, but is not strictly necessary. accepts: Prints a human-readable representation of the files' sizes. Used in conjunction with to choose the unit of the file size. Valid parameters for are List sizes in bytes. , , or List sizes in , i.e., 1024 bytes. , or List sizes in , i.e., 1024 * 1024 bytes. , or List sizes in , i.e., 1024 * 1024 * 1024 bytes. , or List sizes in , i.e., 1000 bytes. , or List sizes in , i.e., 1000 * 1000 bytes. , or List sizes in , i.e., 1000 * 1000 * 1000 bytes.
port installed The action displays the installed versions and variants of the specified ports, or if no ports are specified, all installed ports. It also displays whether a port is active, i.e., whether the files belonging to this port are currently present on disk or inactive, i.e., stashed away in a compressed tarball. $ port installed The following ports are currently installed: a52dec @0.7.4_0 (active) adns @1.4_0 (active) apache2 @2.2.27_0+preforkmpm (active) apr @1.5.1_0 (active) apr-util @1.5.3_0 (active) aquaterm @1.1.1_0 (active) asciidoc @8.6.9_1+python27 (active) … XviD @1.3.3_0 (active) xz @5.0.5_0 (active) yasm @1.2.0_0 (active) ykpers @1.12.0_0 (active) youtube-dl @2014.07.25.1_0+python27 (active) yubico-c-client @2.12_0 (active) yubico-pam @2.16_0 (active) zlib @1.2.8_0 (active) Use to also display the platform and CPU architecture(s) for which the ports were built, and any variants which were explicitly negated. $ port -v installed libsdl The following ports are currently installed: libsdl @1.2.15_3-x11 (active) platform='darwin 13' archs='x86_64'
port outdated The action checks your installed ports against the current ports tree to see they have been updated since you installed them. Note that you will only get new versions by updating your ports tree using (or ). $ port outdated The following installed ports are outdated: gnupg 1.4.16_0 < 1.4.18_0 gnupg2 2.0.22_2 < 2.0.25_0 gpg-agent 2.0.22_1 < 2.0.25_0 gpgme 1.5.0_0 < 1.5.1_0 HexFiend 2.1.2_1 < 2.3.0_0 libksba 1.0.8_0 < 1.3.0_0 p5.16-class-methodmaker 2.180.0_1 < 2.210.0_0 p5.16-gnupg-interface 0.330.0_3 < 0.500.0_1 p5.16-ipc-run 0.910.0_1 < 0.920.0_0 port outdated lists the ports for which an upgrade is available and on the second column, why MacPorts thinks the port needs an upgrade. In most cases, this will be an increase in the version number. If it isn't, more details will be given.
port upgrade The action upgrades installed ports and their dependencies to the latest version available in MacPorts. In most cases, you will run $ sudo port upgrade outdated to update all ports that have an upgrade available. You can, however, selectively upgrade ports if you want to delay other upgrades until later. This is not recommended unless you know what you are doing, since you might experience software errors for the ports that have not yet been upgraded. To upgrade individual ports, specify the name(s) of the port(s) to upgrade: $ sudo port upgrade gnupg2 Note that MacPorts may decide to upgrade other dependent ports before upgrading the port you requested to be updated. Do not attempt to prevent this, since it will very likely lead to problems later. does not uninstall the old version of a port. Instead, it deactivates it, i.e., it stashes the files belonging to the older version away in a tarball. This allows you to go back to the older version if there happens to be a problem with the updated one. To do that, run $ port installed portname to determine the version number of the old version you want to re-activate, and run $ sudo port activate portname @old-version to go back to the old version. If you do not want to keep the old versions around while upgrading, you can pass when upgrading: $ sudo port -u upgrade outdated However, we instead recommend keeping the older versions around for a while and running $ sudo port uninstall inactive once in a while. accepts a number of switches: Always consider the given ports outdated, regardless of whether they actually are. If the installed variants do not match those requested, upgrade (and change variants) even if the port is not outdated. You can use this to switch the variant selection on an installed port, e.g., using $ sudo port upgrade --enforce-variants apache2 -preforkmpm +workermpm Note that will also enforce your variant selection in all dependencies. If you know this is not necessary, you can avoid processing dependencies using the global flag: $ sudo port -n upgrade --enforce-variants apache2 -preforkmpm +workermpm Do not automatically install replacement ports for a port that you have installed, but was replaced with a different one.
port dependents The action reports what ports depend upon a given (installed) port, if any. $ port dependents openssl apache2 depends on openssl curl depends on openssl cyrus-sasl2 depends on openssl git depends on openssl kerberos5 depends on openssl lftp depends on openssl libssh depends on openssl mosh depends on openssl openldap depends on openssl p5.16-net-ssleay depends on openssl python27 depends on openssl python32 depends on openssl qt4-mac depends on openssl ruby19 depends on openssl serf1 depends on openssl textmate2 depends on openssl wireshark depends on openssl Note that does not work for ports that are not installed on your system. If you want to find out, which ports depend on a port that you have not installed, you can use $ port echo depends:portname This command will, however, not cover dependencies that are only present in non-default variants.
port livecheck The action checks to see if the application corresponding to a given port has been updated at the developer's download site. This action is mostly useful for port maintainers to determine whether their port needs to be updated, but other may also wish to see if a port packages the latest available version. See for more information on livecheck. $ port livecheck rb19-sass rb19-sass seems to have been updated (port version: 3.3.10, new version: 3.3.14) If finds no higher version at the port's download site, it prints nothing. The option (debug) may be used for detailed livecheck processing information.
port lint The lint action checks if the Portfile conforms to the MacPorts standards specified in Portfile Development. You should use this if you modified a Portfile before submitting patches back to MacPorts. If a Portfile validates fine the following message is shown. $ port lint rb19-sass ---> Verifying Portfile for rb19-sass ---> 0 errors and 0 warnings found. Otherwise the warnings and errors are listed. $ port lint abiword ---> Verifying Portfile for abiword Warning: Variant use_binary does not have a description Warning: Variant use_source does not have a description Warning: no license set ---> 0 errors and 3 warnings found. has the following flag: Enables additional checks that are mostly whitespace-related and best practices.
port load Some ports install software that is meant to run as a daemon. Or in other words, a long-running background process. Examples of this are database servers like MySQL or PostgreSQL. On macOS, launchd is primarily responsible for starting, stopping, and managing long-running services. Ports that want to run daemon processes can install their own .plist file(s) into launchd. These files will allow launchd to start and manage the port's daemon processes. So once a port is installed, the action can be used to do the above and activate the port's launchd service(s): $ sudo port load prometheus ---> Loading startupitem 'prometheus' for prometheus Now the port's service(s) should be running in launchd. This can be verified with the launchctl command: $ sudo launchctl list | grep macports 49119 0 org.macports.prometheus To stop the daemon service and mark it as disabled for launchd, use the port unload command.
port unload As discussed in the port load section, the port load command can be used to install and activate a port's daemon service(s) in launchd. The action reverses this. port unload will stop the port's daemon processes, and mark the port's service .plist as disabled: $ sudo port unload prometheus ---> Unloading startupitem 'prometheus' for prometheus The port's service(s) should no longer be present in launchctl list.
Port Variants Variants are a way for port authors to provide options for a port that may be chosen at installation. Typically, variants are optional features that can be enabled, but are not necessarily useful for all users and are thus not enabled by default. To display the available variants for a port, if any, use this command: $ port variants portname For example: $ port variants apache2 apache2 has the variants: eventmpm: Use event MPM (experimental) * conflicts with preforkmpm workermpm openldap: Enable LDAP support through OpenLDAP [+]preforkmpm: Use prefork MPM * conflicts with eventmpm workermpm universal: Build for multiple architectures workermpm: Use worker MPM * conflicts with eventmpm preforkmpm This output lists all variants followed by their description. If a variant depends on or conflicts with other variants, a line with the details on that follows. Variant lines that have a are enabled and those with are disabled. Any are derived from the Portfile. While are derived from the variants.conf. See for more information on variants.conf.
Invoking Variants A variant can only be selected when a port is installed. After you have determined what variants a given port has, if any, you may install a port using a variant by specifying its name preceded by a plus sign on the command line, for example $ sudo port install apache2 +openldap Multiple variants can be selected by simply listing them one after another separated by a space. $ sudo port install apache2 +openldap +universal Use a minus sign to deselect a variant that is on by default. $ sudo port install apache2 -preforkmpm +workermpm Note that you will not see any confirmation of successful variant selection and MacPorts will not warn you if you misspelled a variant's name. If your installation is successful, but the chosen feature still seems to be missing, check for possible typos. You can use port installed to verify that the port has been installed with the chosen variant. This happens because MacPorts will also use the specified variants for any dependencies. For example, $ sudo port install apache2 +mariadb is accepted even though does not have a variant. However, it depends on the port which does have the variant and will be installed with it. MacPorts will remember the variants that were used when installing a port. If you upgrade a port later, the same variants will be used, unless you manually specify different variants.
Negating Default Variants A Portfile can specify a default set of variants that will be used when you do not manually override it. Not all ports specify default variants – if there are no default variants, no variants are chosen by default. If you wish to disable a variant that has been enabled by default, either by the Portfile, or by your configuration in variants.conf, you can negate the variant in question by prefixing the variant name with a minus on the command line: $ sudo port install apache2 -preformmpm +workermpm
Common Tasks This section lists common operations you may want to perform when managing a MacPorts installation. These are the workflows you will need most while using MacPorts. We recommend you read at least this section as a primer into how to use MacPorts. More details about the usage can be found in and the manpage available by running man 1 port in a Terminal. Mind the sudo for some of the subsequent examples, which is necessary if you have a default MacPorts installation.
Updating Your Ports Tree The local ports tree is a collection of files that contain information on which packages are available through MacPorts and how they can be installed. You should regularly update your ports tree to get access to updated versions of software and bug fixes. To do that, use : $ sudo port selfupdate Password: ---> Updating MacPorts base sources using rsync MacPorts base version &macports-version; installed, MacPorts base version &macports-version; downloaded. ---> Updating the ports tree ---> MacPorts base is already the latest version The ports tree has been updated. To upgrade your installed ports, you should run port upgrade outdated
Show Ports Which Need Updating To see what's new after running , you can use port outdated to generate a list of ports that have newer versions available. This can help in estimating the time required for sudo port upgrade outdated, even though this depends on further factors such as binary package availability and a port's build time. $ port outdated The following installed ports are outdated: gnupg 1.4.16_0 < 1.4.18_0 gnupg2 2.0.22_2 < 2.0.25_0 gpg-agent 2.0.22_1 < 2.0.25_0 gpgme 1.5.0_0 < 1.5.1_0 HexFiend 2.1.2_1 < 2.3.0_0 libksba 1.0.8_0 < 1.3.0_0 p5.16-class-methodmaker 2.180.0_1 < 2.210.0_0 p5.16-gnupg-interface 0.330.0_3 < 0.500.0_1 p5.16-ipc-run 0.910.0_1 < 0.920.0_0
Upgrading Outdated Ports To upgrade all your installed and outdated ports, run $ sudo port upgrade outdated In case you want to upgrade only a specific port (not recommended unless you know what you are doing), replace outdated in the command given above with the port's name: $ sudo port upgrade makedepend Password: ---> Computing dependencies for makedepend ---> Fetching makedepend ---> Attempting to fetch makedepend-1.0.3.tar.bz2 from http://lil.fr.distfiles.macports.org/makedepend ---> Verifying checksum(s) for makedepend ---> Extracting makedepend ---> Configuring makedepend ---> Building makedepend ---> Staging makedepend into destroot ---> Computing dependencies for makedepend ---> Installing makedepend @1.0.3_0 ---> Deactivating makedepend @1.0.2_0 ---> Activating makedepend @1.0.3_0 ---> Cleaning makedepend Note that MacPorts will upgrade any dependencies of a port first before updating the port itself. So even if you request the update of a single port only, other ports may be upgraded first because they are in the dependency tree. Do not try to avoid this, as it will very likely lead to problems later on – the new version of the port you want to upgrade might require the newer dependency, or it might only have been upgraded at all to be rebuilt against the updated dependency, in which case avoiding the update of the dependency defeats the purpose of the reinstallation.
Removing Inactive Version(s) of Upgraded Port(s) By default, upgrading ports in MacPorts does not remove the older versions. This is a safety measure to ensure you can go back to a working and tested version in case an update goes wrong. To save disk space, you should periodically uninstall any old versions you no longer need. Use $ port installed inactive to get a list of inactive ports you likely no longer need. The following ports are currently installed: gnupg @1.4.16_0 gnupg2 @2.0.22_2 gpg-agent @2.0.22_1 gpgme @1.5.0_0 HexFiend @2.1.2_1 libksba @1.0.8_0 p5.16-class-methodmaker @2.180.0_1 p5.16-gnupg-interface @0.330.0_3 p5.16-ipc-run @0.910.0_1 Check the list for any ports you might still want to keep. To remove all of them at once, run $ sudo port uninstall inactive Password: ---> Uninstalling p5.16-gnupg-interface @0.330.0_3 ---> Cleaning p5.16-gnupg-interface ---> Uninstalling gnupg @1.4.16_0 ---> Cleaning gnupg ---> Uninstalling gpgme @1.5.0_0 ---> Cleaning gpgme ---> Uninstalling gnupg2 @2.0.22_2 ---> Cleaning gnupg2 ---> Uninstalling gpg-agent @2.0.22_1 ---> Cleaning gpg-agent ---> Uninstalling HexFiend @2.1.2_1 ---> Cleaning HexFiend ---> Uninstalling libksba @1.0.8_0 ---> Cleaning libksba ---> Uninstalling p5.16-class-methodmaker @2.180.0_1 ---> Cleaning p5.16-class-methodmaker ---> Uninstalling p5.16-ipc-run @0.910.0_1 ---> Cleaning p5.16-ipc-run Of course you could also select only a specific inactive port, but that requires to specify the exact version: $ sudo port uninstall HexFiend @2.1.2_1 Password: ---> Uninstalling HexFiend @2.1.2_1 ---> Cleaning HexFiend To uninstall all inactive ports but a single one, you can use the following shortcut: $ sudo port uninstall inactive and not portname
Finding Ports Depending on a Certain Port If you want to find all ports that depend on a given other port, you can use $ port echo depends:portname If you are only interested in the dependent ports that you actually have installed, you can use the quicker and more accurate : $ port dependents portname gnupg2 depends on libksba gpg-agent depends on libksba MacPorts also has a recursive version of the action called : $ port rdependents libksba The following ports are dependent on libksba: gnupg2 gpgme gpg-agent Finally, to find out which port you manually installed caused the automatic installation of a dependency, use the following expression: $ port installed requested and rdependentof:portname $ port installed requested and rdependentof:libksba The following ports are currently installed: gnupg2 @2.0.25_0 (active)
Finding Leaves After a while of using MacPorts, installing and uninstalling ports, packages that have been automatically installed as dependencies for other ports are left behind, even though they are no longer necessary. Ports that have not been manually installed (requested) and do not have any dependents are called leaves and can be identified using the pseudo-port, for example in conjunction with the or action. $ port echo leaves git-flow @0.4.1_2 gmake @4.0_0 gpgme @1.5.1_0 hs-download-curl @0.1.4_0 pkgconfig @0.28_0 py27-docutils @0.12_0 python32 @3.2.5_0 texi2html @5.0_1 yasm @1.2.0_0 These leaves may be wanted, but are in most cases unneeded. See to find out how to mark some of the leaves as requested. You can uninstall all leaves using $ sudo port uninstall leaves Note that the uninstallation can cause new ports to become leaves. To uninstall all leaves, you can use the pseudo-port instead. To go through this process interactively so you can make sure you're not uninstalling anything you want to keep, you can install the port. After installation, run it with $ sudo port_cutleaves
Keep Your Installation Lean by Defining Leaves as Requested Ports Well, before we come to the procedure of defining your requested ports, let's have a look at a typical scenario where you want to understand what is actually installed and what is on the other hand truly necessary for your system. Say checking leaves of your MacPorts installation gives this output: $ port echo leaves git-flow @0.4.1_2 gmake @4.0_0 gpgme @1.5.1_0 hs-download-curl @0.1.4_0 pkgconfig @0.28_0 py27-docutils @0.12_0 python32 @3.2.5_0 texi2html @5.0_1 yasm @1.2.0_0 Now it is up to the user to decide what's needed and what is not. We've noticed is needed to build many ports, and while it is strictly not needed after installation, we'd like to keep it around to avoid installing it over and over again. , , and are only needed to update , and since that software is rarely updated, we will re-install those ports again when they are needed. Since they are all distributable, MacPorts will use pre-built binaries for their installation anyway, so re-installing them wouldn't take long anyway. We don't really know why the rest of the leaves were installed, so we're just going to remove them for now. Since we decided to keep , we are going to mark it as manually installed (requested in MacPorts lingo) using: $ sudo port setrequested pkgconfig When you've step-by-step figured out which ports you want to keep on your system and have set them as requested, you'll have a list of unnecessary ports, which you can get rid of using $ sudo port uninstall leaves Note that uninstalling leaves may mark new ports as leaves, so you will have to repeat the process. You can install the port, which is a special script for the job. It allows you to interactively decide whether to keep or uninstall a port. Run it as $ sudo port_cutleaves [Leaf 1 of 8] hs-download-curl @0.1.4_0 (active): [keep] / (u)ninstall / (f)lush / (a)bort: ** hs-download-curl @0.1.4_0 will be kept. [Leaf 2 of 8] gmake @4.0_0 (active): [keep] / (u)ninstall / (f)lush / (a)bort: u ** gmake @4.0_0 will be uninstalled. [Leaf 3 of 8] texi2html @5.0_1 (active): [keep] / (u)ninstall / (f)lush / (a)bort: u ** texi2html @5.0_1 will be uninstalled. [Leaf 4 of 8] yasm @1.2.0_0 (active): [keep] / (u)ninstall / (f)lush / (a)bort: u ** yasm @1.2.0_0 will be uninstalled. [Leaf 5 of 8] python32 @3.2.5_0 (active): [keep] / (u)ninstall / (f)lush / (a)bort: u ** python32 @3.2.5_0 will be uninstalled. [Leaf 6 of 8] py27-docutils @0.12_0 (active): [keep] / (u)ninstall / (f)lush / (a)bort: u ** py27-docutils @0.12_0 will be uninstalled. [Leaf 7 of 8] git-flow @0.4.1_2 (active): [keep] / (u)ninstall / (f)lush / (a)bort: u ** git-flow @0.4.1_2 will be uninstalled. [Leaf 8 of 8] gpgme @1.5.1_0 (active): [keep] / (u)ninstall / (f)lush / (a)bort: u ** gpgme @1.5.1_0 will be uninstalled. ---> Deactivating gmake @4.0_0 ---> Cleaning gmake ---> Uninstalling gmake @4.0_0 ---> Cleaning gmake ---> Deactivating texi2html @5.0_1 ---> Cleaning texi2html ---> Uninstalling texi2html @5.0_1 ---> Cleaning texi2html ---> Deactivating yasm @1.2.0_0 ---> Cleaning yasm ---> Uninstalling yasm @1.2.0_0 ---> Cleaning yasm ---> Deactivating python32 @3.2.5_0 ---> Cleaning python32 ---> Uninstalling python32 @3.2.5_0 ---> Cleaning python32 ---> Deactivating py27-docutils @0.12_0 ---> Cleaning py27-docutils ---> Uninstalling py27-docutils @0.12_0 ---> Cleaning py27-docutils ---> Deactivating git-flow @0.4.1_2 ---> Cleaning git-flow ---> Uninstalling git-flow @0.4.1_2 ---> Cleaning git-flow ---> Deactivating gpgme @1.5.1_0 ---> Cleaning gpgme ---> Uninstalling gpgme @1.5.1_0 ---> Cleaning gpgme The following ports were uninstalled: gmake @4.0_0 texi2html @5.0_1 yasm @1.2.0_0 python32 @3.2.5_0 py27-docutils @0.12_0 git-flow @0.4.1_2 gpgme @1.5.1_0 Search for new leaves? [no] / (y)es: y [Leaf 1 of 1] py27-roman @2.0.0_0 (active): [keep] / (u)ninstall / (f)lush / (a)bort: u ** py27-roman @2.0.0_0 will be uninstalled. ---> Deactivating py27-roman @2.0.0_0 ---> Cleaning py27-roman ---> Uninstalling py27-roman @2.0.0_0 ---> Cleaning py27-roman The following ports were uninstalled: py27-roman @2.0.0_0 Search for new leaves? [no] / (y)es: y There are no new leaves to process. You can get a list of all ports you previously set as requested (or installed manually) using: $ port installed requested We recommend you check the list of leaves from time to time to keep your system free of too much garbage. You should also periodically check the list of your requested ports and mark any ports you no longer need as unrequested using $ sudo port unsetrequested portname Then check for new leaves to cut down the number of installed ports and the size of your MacPorts installation.
Port Binaries MacPorts can pre-compile ports into binaries so applications need not be compiled when installing on a target system. MacPorts supports two types of binaries: archives and packages.
Binary Archives Binary archives can only be used on a target system running MacPorts. They allow MacPorts utilities to skip the build (which is usually the phase that takes longest) and begin installation after the destroot phase. Binary archives are automatically created whenever a port is installed, and can also be downloaded from a server. MacPorts runs a buildbot infrastructure that creates prebuilt binary packages for all ports in MacPorts for the default installation prefix. Buildbots exist for systems later or equal to Snow Leopard. If a port builds successfully and its license and those of its dependencies allow binary redistribution, the archives are uploaded to and will be automatically used by MacPorts during installation. You can manually create an archive (and see debug output for its creation) using $ sudo port -d archive logrotate ---> Installing logrotate @3.8.6_2+gzip […] DEBUG: Creating logrotate-3.8.6_2+gzip.darwin_13.x86_64.tbz2 […] a . a ./+COMMENT a ./+CONTENTS a ./+DESC a ./+PORTFILE a ./+STATE a ./opt a ./opt/local a ./opt/local/etc a ./opt/local/sbin a ./opt/local/share a ./opt/local/var a ./opt/local/var/run a ./opt/local/var/run/logrotate a ./opt/local/var/run/logrotate/.turd_logrotate a ./opt/local/share/logrotate a ./opt/local/share/man a ./opt/local/share/man/man5 a ./opt/local/share/man/man8 a ./opt/local/share/man/man8/logrotate.8.gz a ./opt/local/share/man/man5/logrotate.conf.5.gz a ./opt/local/share/logrotate/CHANGES a ./opt/local/share/logrotate/COPYING a ./opt/local/share/logrotate/logrotate.conf.example a ./opt/local/share/logrotate/org.macports.logrotate.plist.example a ./opt/local/sbin/logrotate a ./opt/local/etc/logrotate.d a ./opt/local/etc/logrotate.d/.turd_logrotate DEBUG: Archive logrotate-3.8.6_2+gzip.darwin_13.x86_64.tbz2 packaged Binary archive files are placed in ${prefix}/var/macports/software/. The archive file type is set in macports.conf using the key. The default format is ; other options are: , , , , , , , , , and .
Binary Packages Binary packages are standalone binary installers that are precompiled; they do not require MacPorts on the target system. As such, they are helpful in generating disk images or installers to be redistributed to users without relying on MacPorts for installation. Binary installers created with MacPorts are usually (macOS Installer packages). MacPorts can also convert a package into a macOS disk image. You can create binary packages using port as shown in the following examples. If you want to create installer packages using MacPorts for redistribution, make sure you do not use a standard installation of MacPorts in /opt/local. If you do that, your installer package conflicts with MacPorts on systems that do have MacPorts installed. Instead, follow and choose a prefix specific to the software you are trying to package, e.g., /opt/logrotate for . Then use this custom MacPorts installation to build your package. Create a macOS installer for the port: $ sudo port pkg pstree You may also create a macOS disk image file instead: $ sudo port dmg pstree In most cases you probably want to package a port and all its library and runtime dependencies in a single package. You can use a metapackage to do this. Create one using: $ sudo port mpkg gimp2 Just as with a single package, a metapackage can also be wrapped in a . $ sudo port mdmg gimp2 All packages are placed in a port's work directory, which you can locate using: $ port work portname