From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
MacPorts Logo.svg
MacPorts 2.7.1 in iTerm2 on macOS.png
Screenshot of the port command running in iTerm2
Initial release2002 (2002)[1]
Stable release
2.7.2[2] Edit this on Wikidata / 9 March 2022; 6 months ago (9 March 2022)
Written inTcl[3] and C
Operating systemmacOS, Darwin
PlatformIA-32, x86-64, PowerPC, ARM
Available inEnglish
TypePackage management system
LicenseBSD Edit this on Wikidata

MacPorts, formerly called DarwinPorts,[4] is a package management system that simplifies the installation of software on the macOS and Darwin operating systems. It is an open-source software project that aims to simplify the installation of other open source software.[5] It's similar in function to Fink and the BSD ports collections.

MacPorts allows the installation of a number of packages by entering the command sudo port install packagename in the Terminal, which will then download, compile if necessary, and install the requested software, while also installing any required dependencies automatically. Installed packages can be updated with the command sudo port upgrade outdated.[6]

MacPorts supports universal binaries for PowerPC, Intel-based,[7] and Apple silicon versions of macOS,[8][9] but migrating from a PowerPC installation of MacPorts to a version on an Intel Mac requires reinstalling all installed ports.[10]


Updating Software[edit]

There are three main usage modes of port that assist in updating installed software:

  • sync updates the local ports tree. It doesn't upgrade any installed packages, but instead retrieves information about new and updated software. It's similar in function to brew update or apt update.[11]
  • selfupdate has the same functionality as sync but also updates the MacPorts system.[12] In most cases, this should be used in preference to just running sync by itself,[11] and it's recommended to run this each time before using MacPorts.[13]
  • upgrade upgrades any installed ports and its dependencies to the latest version found in the local ports tree. It's similar in function to apt upgrade.[14]

As an example, one common task is to update outdated ports. This can be done by running the following:[15]

sudo port selfupdate
sudo port upgrade outdated

MacPorts supports logical operators such as and, or and not,[16] as well as glob patterns (enabled by default) and regex (enabled via --regex).[17] For instance, to update outdated ports excluding all PHP versions, change the above command to the following:[16]

sudo port selfupdate
sudo port upgrade outdated and not php*

Installing Software[edit]

Users can indicate one or more packages that they wish to install via the install mode, and MacPorts will aim to install them and its dependencies.[18] For example, both LibreOffice and Texmaker can be installed by running the following:[13][19]

sudo port install libreoffice texmaker

Note that this will install the latest version as indicated by the local ports tree. Running selfupdate beforehand will make sure that the downloaded package is the newest version in MacPorts.[12]


Variants provide different options that may be invoked when installing a port. Common actions include adding or removing dependencies and changing build arguments.[20] They provide additional functionality that might not necessarily be useful for all users, but can be useful for others.

For instance, the youtube-dl port provides an ffmpeg variant that is enabled by default. In return for adding two extra dependencies, this then allows for audio to be extracted.[21][22] Variants can be included or removed using the + or - symbols, so the ffmpeg variant can be disabled by running the following:

sudo port install youtube-dl -ffmpeg

Multiple variants can be listed one after another by separating them with a space. As an example, it's possible to disable the default prefork MPM in the apache2 port in favour of worker MPM:[23]

sudo port install apache2 -preforkmpm +workermpm

The variants of a port can be determined by running port variants packagename, or by searching for the port on the MacPorts website.[23][24]


Homepage of the MacPorts Ports Website.[24]


The MacPorts Ports website was implemented during Google Summer of Code 2019,[25] with major UI improvements made within the same program in 2020.[26][27] It displays information about individual ports, such as installation statistics and build-history.[25] These statistics are also available via an API.[28] Users can optionally login to be notified when a port has been updated.[26]

There is also a separate MacPorts homepage, that provides information on the project as well as instructions on how to install it.[29]


Jordan Hubbard, one of the main creators of MacPorts whilst heading Apple's UNIX team.[30][31]

MacPorts was started in 2002 with the involvement of a number of Apple Inc. employees, including Landon Fuller, Kevin Van Vechten, and Jordan Hubbard.[30] It was originally known as DarwinPorts, with the name coming from Darwin and FreeBSD Ports. It began as part of the OpenDarwin project, with its aim to help users on macOS and Darwin to install Unix software.[32][33]

OpenDarwin was shut down in 2006. DarwinPorts was then hosted on Mac OS Forge, an open source hosting service created and maintained by Apple Inc. for third-party projects not supported by Apple.[34] So as to indicate the project's emphasis on macOS, its name was changed to MacPorts.[32]

When Apple closed Mac OS Forge in 2016, the project moved to GitHub.[35] As part of this change, git was used as the new version control system, although Trac was still preferred for ticket management over GitHub issues.[36]

Version 1.0 was released on April 28, 2005.[37] In December 2005 the project reached a milestone, surpassing 3000 ports.[38] At that time, package installation involved the source code being downloaded and compiled on the end user's machine. Version 2.0, released in 2011, introduced support for prebuilt binary archives; by default ports are installed using the prebuilt binary archive if available, and are built from source otherwise.[39][40] as of August 2022, MacPorts has over 29,700 ports[41] and best-effort support can be sourced from the community.[42]


MacPorts installs software on top of the operating system, providing newer versions of pre-installed packages or software that isn't included in macOS. This is in contrast to other package management systems, such as APT and DNF, that are part of the operating system. For this reason, MacPorts is sometimes known as an overlay distribution. Other examples include Fink and Homebrew.[43]

In contrast to the FreeBSD Ports Collection, which installs its software in /usr/local,[44] MacPorts stores its data in /opt/local by default,[45] although this can be modified when compiling MacPorts from source.[46] The reason given for this change is that other packaging systems could overwrite what MacPorts has installed, or vice versa. A dedicated directory helps to overcome this problem.[47] Fink follows a similar approach, installing its data into /sw by default.[48]

Binary Archives[edit]

Buildbots are used to build ports in advance so that users do not have to compile the package locally. The result of this is known as a binary archive, and it helps to reduce the time required for installation.[49] Similar to Homebrew, MacPorts takes the approach of having different builders for different operating system versions and architectures.[50][51] However, sometimes it might be necessary to build from source locally if the binaries fail to build or the port's license does not allow binary distribution.[52] If a binary could not be built, this would be noted on the MacPorts website for that individual port and the maintainer would be alerted.[53][54] It's also possible to view recent buildbot events on a dedicated activity page.[55]

Binary archives are created locally whenever a user builds a port from source. They can also be manually created by running sudo port archive packagename.[52]


MacPorts stores the instructions required to build a port in a port description file, otherwise known as a portfile.[56] This is similar to how the AUR use shell scripts known as a PKGBUILD,[57] or how Homebrew use ruby scripts as a formula.[58] The portfiles are complete TCL programs with access to the TCL interpreter. They make use of simple key value pair options to define attributes.

MacPorts uses an actual scripting language, namely TCL, in creating port descriptions. This gives the port writer a lot more flexibility in dealing with some of the more complex bits of software out there and the whole notion of action hooks (pre/post fetch, build, install, etc) is much cleaner in MacPorts [compared with FreeBSD]

For example, this is the portfile for Hashcat:[22]

# -*- coding: utf-8; mode: _tcl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- vim:fenc=utf-8:ft=tcl:et:sw=2:ts=2:sts=2

PortSystem              1.0
PortGroup               github 1.0
PortGroup               makefile 1.0

github.setup            hashcat hashcat 6.2.3 v
github.tarball_from     archive

categories              security
license                 MIT
platforms               darwin
maintainers             @gaming-hacker openmaintainer

description             World's fastest and most advanced password recovery utility.

long_description        hashcat is the world's fastest and most advanced \
                        password recovery utility, supporting five unique modes \
                        of attack for over 200 highly-optimized hashing algorithms. \
                        hashcat currently supports CPUs, GPUs, and other hardware \
                        accelerators on Linux, Windows, and macOS, and has \
                        facilities to help enable distributed password cracking

homepage                  {}

checksums               rmd160  8bb501834a320aaac3de149c5ab39c2eb89ee968 \
                        sha256  c0be1c6693ee1f35c7bef1f79bf9e30a954f717ef42d00e37787aaeff3271e51 \
                        size    6222424

Each portfile has pre-defined stages that can be manually configured via the portfile.[59] These include the following:

Output of port info hashcat. This provides information about a port from its portfile.[60][61]


First, MacPorts retrieves and downloads all the relevant files for the port from upstream. These are known as distfiles. In the case of hashcat, these files are retrieved from GitHub.[62] They are removed, along with temporary build files, when the installation is complete.


Checksums are always defined within the portfile, since they're different for different files. The checksums of the downloaded files are compared to those in the portfile to see whether they match.[59]

Only one compressed file is downloaded for Hashcat, so only one checksum is required in the portfile.


Sometimes, the code might need to be modified to make it installable via MacPorts. This could be for a variety of reasons, such as it installing in the wrong location by default. Patch files can be used to modify the source code in a readable format.[63]

In the above portfile, Hashcat does not require any changes to the code for the installation to work. Hence, there are no patch files required. When patches are required, the patch file would be stored with the portfile, and it would be referenced like the following (from wget):[64]

patchfiles              prefix.patch


The project's configure script is run to prepare for the build process. Part of this involves determining whether the required libraries are present. For ports that do not have a configure script, this stage (as well as others when required) can be disabled.

Since the configure stage is not referenced in the Portfile, hashcat is using the default configure setup as defined by MacPorts. This involves running the configure script via ./configure.[65]

Information on the hashcat port from the MacPorts Ports website. With the exception of statistics, this information is retrieved from the portfile.


The instructions in the portfile are then used to build the port. The commands that are executed can vary for different languages.

The portfile for hashcat shows that it should be treated as a Makefile project. It will therefore be built by running make.


Some ports define a test to verify that the build has succeeded. This is an optional phase that is only run if the user executes port test packagename. It's therefore not executed when installing a port.[59]

This hashcat port has not defined a test stage. When defined, it might look like the following (from ImageMagick):[66]                    yes                 check
test.env                    DYLD_LIBRARY_PATH=${worksrcpath}/magick/.libs


The destroot stage is the first step in moving the built files into the correct location. MacPorts takes the approach of first staging the installation into an intermediate location (destroot) before placing the files in their correct positions (install). One advantage of this is that it makes it easy to record what files were created, allowing them to be cleanly uninstalled.[59]

As an example, a file that would normally be installed to /opt/local/lib/libfoo.a might first be installed to /tmp/stage/opt/local/lib/libfoo.a during the destroot stage, maintaining the relative directory structure.[67]

For hashcat, this is done by running make install, where one of the arguments (DESTDIR) specifies where to temporarily store the files.

Note that in the majority of scenarios, only the stages below occur on the user's machine. This is because binaries for the ports are pre-built so that they do not need to be built from source locally.[68][69]


The destrooted files are archived safely. Since these files have not been activated yet, this allows for multiple different versions of the same port to be archived without interfering with each other.[70]


When activating a port, the files in the destroot directory are moved to their correct location. This makes them accessible to the user, completing the installation process.[59]

If they wish to try a different version of the port, they can deactivate their current version and activate the new one. This does not uninstall the old port since it can easily be activated again from the archived files.[70][13]

When upgrading a port, MacPorts deactivates but does not uninstall the current version as a safety feature. This allows the user to easily revert to the old version if the update causes breaking changes.[71]


MacPorts Meeting 2018 Badges.
MacPorts developers at the 2019 meeting in Scout Center Bohinj, Slovenia.[72]

Packages are the responsibility of individual maintainers, who are mentioned within the portfile. They are expected to update the port and apply bug-fixes where required. Anybody who wants to modify a portfile should alert the maintainer before applying the changes, although this isn't always required for minor modifications.[73][74]

Anyone is able to contribute to MacPorts, generally via pull requests, and contributors can apply for commit rights following a good track record as a maintainer.[75] A team of MacPorts members, known as the project managers, help to lead and coordinate the project.[76]

Starting from 2016, meetings have occasionally been held once a year.[77] They normally take place in Slovenia, and allow for MacPorts members to work on future development.[72]

Data collection[edit]

By default, MacPorts does not collect any statistics. However, users can optionally submit information by running sudo port install mpstats. This sends details once a week on which ports are installed, as well as various system properties. The information is then used to determine which hardware to support and to understand how quickly new MacPorts releases are adopted.[78]

Users can view analytics data on the MacPorts website.[79]

See also[edit]


  1. ^ "MacPortsHistory".
  2. ^ "MacPorts 2.7.2 now available". Retrieved 13 March 2022.
  3. ^ Mark Weinem, ed. (2007-10-17). "Jordan K. Hubbard: The invention of the FreeBSD Ports system, its drawbacks and the merits of MacPorts". 10 years of pkgsrc — pkgsrc and the concepts of package management 1997-2007 (part 1). NetBSD. Retrieved 2019-08-07.
  4. ^ "DarwinPorts project announces New Hosting and New Name". (archived). August 7, 2006. Retrieved 2007-03-05.
  5. ^ "Mac OS X:Build from source:MacPorts - Gramps". Retrieved 2021-08-06.
  6. ^ "MacPorts". January 5, 2011. Archived from the original on September 26, 2010. Retrieved 2010-10-15.
  7. ^ "MacPorts - 2020 - Google Summer of Code Archive". Retrieved 2021-08-06.
  8. ^ "Does MacPorts work on Apple Silicon? - Does It ARM". Retrieved 2021-08-06.
  9. ^ "Install and Testing MacPorts on an M1 Mac". RickMakes. 2020-12-17. Retrieved 2021-08-06.
  10. ^ "Migrating a MacPorts install to a new major OS version or CPU architecture". MacPorts. Retrieved 2013-05-27.
  11. ^ a b "3.1.3. port sync". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  12. ^ a b "3.1.2. port selfupdate". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  13. ^ a b c Rider, Stephen. "MacPorts Cheat Sheet". Retrieved 6 August 2021.{{cite web}}: CS1 maint: url-status (link)
  14. ^ "3.1.18. port upgrade". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  15. ^ "3.3.3. Upgrading Outdated Ports". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  16. ^ a b Parker, Shawn (2009-07-14). "Excluding packages from MacPorts operations". The Gippy Pages. Retrieved 2021-08-06.
  17. ^ "3.1.7. port search". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  18. ^ "3.1.11. port install". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  19. ^ "Using MacPorts". University of Michigan - Knowledge Base. 2020-05-27. Retrieved 2021-08-06.
  20. ^ "4.4. Port Variants". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  21. ^ "youtube-dl | MacPorts". Retrieved 2021-08-06.
  22. ^ a b "macports-ports/Portfile at master · macports/macports-ports". GitHub. Retrieved 2021-08-06.
  23. ^ a b "3.2. Port Variants". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  24. ^ a b "Ports | MacPorts". Retrieved 2021-08-06.
  25. ^ a b Blog, Arjun Salyan's. "GSoC'19: Wrapping up the Project". Retrieved 2021-08-08.
  26. ^ a b Blog, Arjun Salyan's. "Google Summer of Code 2020". Retrieved 2021-08-08.
  27. ^ Miklavec, Mojca (19 July 2021). "New website". Retrieved 2021-08-08.{{cite web}}: CS1 maint: url-status (link)
  28. ^ "Api Root - Django REST framework". Retrieved 8 August 2021.{{cite web}}: CS1 maint: url-status (link)
  29. ^ "The MacPorts Project -- Home". Retrieved 2021-08-08.
  30. ^ a b "10 years of pkgsrc - pkgsrc and the concepts of package management 1997-2007 (part 1)". Retrieved 2021-08-07.
  31. ^ Cao (2017-02-24). "The Mac Observer Interview with Jordan Hubbard". Retrieved 2021-08-07.
  32. ^ a b "MacPortsHistory – MacPorts". Retrieved 2021-08-06.
  33. ^ "MacPorts 101". Retrieved 2021-08-06.
  34. ^ "Mac OS Forge". Archived from the original on 2010-08-20. Retrieved 2010-08-17.
  35. ^ "MacPorts". GitHub. Retrieved 2021-08-05.
  36. ^ Schmidt, Ryan (19 August 2016). "Goodbye Mac OS Forge, hello GitHub". Retrieved 2021-08-07.{{cite web}}: CS1 maint: url-status (link)
  37. ^ Markus Weissmann (April 28, 2005). "DarwinPorts v1.0". (archived). Archived from the original on 2006-06-29. Retrieved 2007-03-05.
  38. ^ "3000 ports landmark". (archived). December 17, 2005. Archived from the original on 2006-06-29. Retrieved 2007-03-05.
  39. ^ Joshua Root (2011-07-22). "MacPorts 2.0.0 has been released". MacPorts-announce (Mailing list). Retrieved 2019-08-17.
  40. ^ Joshua Root (2012-05-11). "Prebuilt archives available for Lion". MacPorts-announce (Mailing list). Retrieved 2019-03-01.
  41. ^ "Search ports | MacPorts". Retrieved 2021-08-05.{{cite web}}: CS1 maint: url-status (link)
  42. ^ "The MacPorts Project -- Contact Us". Retrieved 2021-08-05.
  43. ^ "Mailman 3 [Linux-SIG] Draft PEP: Graceful cooperation between external and Python package managers - Linux-sig -". Retrieved 2021-08-06.
  44. ^ "Chapter 4. Installing Applications: Packages and Ports". Retrieved 2021-09-07.
  45. ^ "5.2. Global Variables". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  46. ^ "Install MacPorts". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  47. ^ "FAQ – MacPorts". Retrieved 2021-08-06.
  48. ^ "Fink - Home". Retrieved 2021-08-06.
  49. ^ "Package Management". Ubuntu. Retrieved 2021-08-08.
  50. ^ "Bottles (Binary Packages)". Homebrew Documentation. Retrieved 2021-08-08.
  51. ^ "All Builds | MacPorts". Retrieved 2021-08-08.
  52. ^ a b "3.4.1. Binary Archives". Retrieved 2021-08-08.{{cite web}}: CS1 maint: url-status (link)
  53. ^ Bharati, Rajdeep (2019-08-26). "MacPorts-Buildbot GSoC Report". Medium. Retrieved 2021-08-08.
  54. ^ "4.8. MacPorts' buildbot". Retrieved 2021-08-08.{{cite web}}: CS1 maint: url-status (link)
  55. ^ "Buildbot". Retrieved 2021-08-08.
  56. ^ "Chapter 4. Portfile Development". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  57. ^ "PKGBUILD - ArchWiki". Retrieved 2021-08-06.
  58. ^ "Formula Cookbook". Homebrew Documentation. Retrieved 2021-08-06.
  59. ^ a b c d e "5.3. Port Phases". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  60. ^ "ESO - Using the MacPorts Pipeline Repository". Retrieved 2021-08-07.
  61. ^ "3.1.8. port info". Retrieved 2021-08-07.{{cite web}}: CS1 maint: url-status (link)
  62. ^ "5.9.2. PortGroup github". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  63. ^ "4.5.2. Creating Source Code Patches". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  64. ^ "macports-ports/Portfile at 388977d9088455ede9fe4cc3a13af48e9c3ab067 · macports/macports-ports". GitHub. Retrieved 2021-08-06.
  65. ^ "5.3.7. Configure Phase Keywords". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  66. ^ "macports-ports/Portfile at a4fb1ec6494bd176876b1637fa9f000e08615f96 · macports/macports-ports". GitHub. Retrieved 2021-08-06.
  67. ^ "DESTDIR (GNU Coding Standards)". Retrieved 2021-08-06.
  68. ^ "3.4. Port Binaries". Retrieved 2021-08-07.{{cite web}}: CS1 maint: url-status (link)
  69. ^ "MacOS – How to download pre-built binaries from MacPorts without installing – iTecTec". Retrieved 2021-08-07.
  70. ^ a b "6.3. Port Images". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  71. ^ "3.3.4. Removing Inactive Version(s) of Upgraded Port(s)". Retrieved 2021-08-06.{{cite web}}: CS1 maint: url-status (link)
  72. ^ a b "Meetings/MacPortsMeeting2019 – MacPorts". Retrieved 2021-08-08.
  73. ^ "NewCommittersGuide – MacPorts". Retrieved 2021-08-07.
  74. ^ "4.2. Creating a Portfile". Retrieved 2021-08-07.{{cite web}}: CS1 maint: url-status (link)
  75. ^ "7.6. MacPorts Membership". Retrieved 2021-08-07.{{cite web}}: CS1 maint: url-status (link)
  76. ^ "The MacPorts Project Team". Retrieved 2021-08-07.{{cite web}}: CS1 maint: url-status (link)
  77. ^ "Meetings – MacPorts". Retrieved 2021-08-08.
  78. ^ "FAQ - Statistics | MacPorts". Retrieved 2021-08-05.
  79. ^ "Statistics | MacPorts". Retrieved 2021-08-05.

External links[edit]