1. Introduction
2. Installing MacPorts
2.1. Install Xcode
2.2. Install MacPorts
2.3. MacPorts Upgrade
2.4. Uninstall
2.5. MacPorts and the Shell
3. Using MacPorts
3.1. The port Command
3.2. Port Variants
3.3. Common Tasks
3.4. Port Binaries
4. Portfile Development
4.1. Portfile Introduction
4.2. Creating a Portfile
4.3. Example Portfiles
4.4. Port Variants
4.5. Patch Files
4.6. Local Portfile Repositories
4.7. Portfile Best Practices
4.8. MacPorts' buildbot
5. Portfile Reference
5.1. Global Keywords
5.2. Global Variables
5.3. Port Phases
5.4. Dependencies
5.5. Variants
5.6. Tcl Extensions & Useful Tcl Commands
5.7. StartupItems
5.8. Livecheck / Distcheck
5.9. PortGroups
6. MacPorts Internals
6.1. File Hierarchy
6.2. Configuration Files
6.3. Port Images
6.4. APIs and Libs
6.5. The MacPorts Registry
7. MacPorts Project
7.1. Using Trac for Tickets
7.2. Contributing to MacPorts
7.3. Port Update Policies
7.4. Updating Documentation
7.5. MacPorts Membership
7.6. The PortMgr Team
8. MacPorts Guide Glossary
9. Macros

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 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, they archives are uploaded to packages.macports.org 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 ./+DESC
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 portarchivetype key. The default format is tbz2; other options are: tar, tbz, tbz2, tgz, tlz, txz, xar, zip, cpgz, and cpio.

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 .pkg (macOS Installer packages). MacPorts can also convert a .pkg package into a macOS .dmg 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 Section 2.2.4, “Install Multiple MacPorts Copies” and choose a prefix specific to the software you are trying to package, e.g., /opt/logrotate for logrotate. Then use this custom MacPorts installation to build your package.

Create a macOS .pkg installer for the pstree port:

$ sudo port pkg pstree

You may also create a macOS .dmg 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 .dmg.

$ sudo port mdmg gimp2

All packages are placed in a port's work directory, which you can locate using:

$ port work portname