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, the 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 ./+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
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