Initial release | 2002[1] |
---|---|
Stable release | |
Repository | |
Written in | Tcl [3] and C |
Operating system | macOS, Darwin |
Platform | IA-32, x86-64, PowerPC, ARM |
Available in | English |
Type | Package management system |
License | BSD |
Website | www |
MacPorts, formerly DarwinPorts, [4] is a package manager for macOS and Darwin. It is an open-source software project that aims to simplify the installation of other open source software. [5] It is similar in function to Fink and the BSD ports collections.
MacPorts supports universal binaries for PowerPC, Intel-based, [6] and Apple silicon versions of macOS, [7] [8] but migrating from a PowerPC installation of MacPorts to a version on an Intel Mac requires reinstalling all installed ports. [9]
There are three main usage modes of port
that assist in updating installed software:
sync
updates the local ports tree. It does not upgrade any installed packages, but instead retrieves information about new and updated software. It is similar in function to brew update
or apt update
. [10] selfupdate
has the same functionality as sync
but also updates the MacPorts system. [11] In most cases, this should be used in preference to just running sync
by itself, [10] and it is recommended to run this each time before using MacPorts. [12] upgrade
upgrades any installed ports and its dependencies to the latest version found in the local ports tree. It is similar in function to apt upgrade
. [13] As an example, one common task is to update outdated ports. This can be done by running the following: [14]
sudoportselfupdate sudoportupgradeoutdated
MacPorts supports logical operators such as and, or and not, [15] as well as glob patterns (enabled by default) and regex (enabled via --regex
). [16] For instance, to update outdated ports excluding all PHP versions, change the above command to the following: [15]
sudoportselfupdate sudoportupgradeoutdatedandnotphp*
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. [17] For example, both LibreOffice and Texmaker can be installed by running the following: [12] [18]
sudoportinstalllibreofficetexmaker
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. [11]
Variants provide different options that may be invoked when installing a port. Common actions include adding or removing dependencies and changing build arguments. [19] 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. [20] [21] Variants can be included or removed using the +
or -
symbols, so the ffmpeg variant can be disabled by running the following:
sudoportinstallyoutube-dl-ffmpeg
Multiple variants can be listed one after another by separating them with a space. As an example, it is possible to disable the default prefork MPM in the apache2 port in favour of worker MPM: [22]
sudoportinstallapache2-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. [22] [23]
The MacPorts Ports website was implemented during Google Summer of Code 2019, [24] with major UI improvements made within the same program in 2020. [25] [26] It displays information about individual ports, such as installation statistics and build-history. [24] These statistics are also available via an API. [27] Users can optionally login to be notified when a port has been updated. [25]
There is also a separate MacPorts homepage, that provides information on the project as well as instructions on how to install it. [28]
MacPorts was started in 2002 with the involvement of a number of Apple Inc. employees, including Landon Fuller, Kevin Van Vechten, and Jordan Hubbard. [29] 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. [31] [32]
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. [33] So as to indicate the project's emphasis on macOS, its name was changed to MacPorts. [31]
When Apple closed Mac OS Forge in 2016, the project moved to GitHub. [34] 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. [35]
Version 1.0 was released on April 28, 2005. [36] In December 2005 the project reached a milestone, surpassing 3000 ports. [37] 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. [38] [39] As of May 2023 [update] , MacPorts has over 33,600 ports [40] and best-effort support can be sourced from the community. [41]
MacPorts installs software on top of the operating system, providing newer versions of pre-installed packages or software that is not 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. [42]
In contrast to the FreeBSD Ports Collection, which installs its software in /usr/local
, [43] MacPorts stores its data in /opt/local
by default, [44] although this can be modified when compiling MacPorts from source. [45] 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. [46] Fink follows a similar approach, installing its data into /sw
by default. [47]
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. [48] Similar to Homebrew, MacPorts takes the approach of having different builders for different operating system versions and architectures. [49] [50] 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. [51] 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. [52] [53] It is also possible to view recent buildbot events on a dedicated activity page. [54]
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
. [51]
MacPorts stores the instructions required to build a port in a port description file, otherwise known as a portfile. [55] This is similar to how the AUR use shell scripts known as a PKGBUILD, [56] or how Homebrew use ruby scripts as a formula. [57] 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: [21]
# -*- 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=2PortSystem1.0PortGroupgithub1.0PortGroupmakefile1.0github.setuphashcathashcat6.2.3v github.tarball_fromarchive categoriessecurity licenseMIT platformsdarwin maintainers@gaming-hackeropenmaintainer descriptionWorld'sfastestandmostadvancedpasswordrecoveryutility. long_descriptionhashcatistheworld'sfastestandmostadvanced\passwordrecoveryutility,supportingfiveuniquemodes\ofattackforover200highly-optimizedhashingalgorithms.\hashcatcurrentlysupportsCPUs,GPUs,andotherhardware\acceleratorsonLinux,Windows,andmacOS,andhas\facilitiestohelpenabledistributedpasswordcracking homepagehttps://hashcat.net/hashcat/build.target{}checksumsrmd1608bb501834a320aaac3de149c5ab39c2eb89ee968\sha256c0be1c6693ee1f35c7bef1f79bf9e30a954f717ef42d00e37787aaeff3271e51\size6222424
Each portfile has pre-defined stages that can be manually configured via the portfile. [58] These include the following:
Fetch
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. [61] They are removed, along with temporary build files, when the installation is complete.
Checksum
Checksums are always defined within the portfile, since they are different for different files. The checksums of the downloaded files are compared to those in the portfile to see whether they match. [58]
Only one compressed file is downloaded for Hashcat, so only one checksum is required in the portfile.
Patch
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. [62]
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): [63]
patchfilesprefix.patch
Configure
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
. [64]
Build
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
.
Test
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 is therefore not executed when installing a port. [58]
This hashcat port has not defined a test stage. When defined, it might look like the following (from ImageMagick): [65]
test.runyes test.targetcheck test.envDYLD_LIBRARY_PATH=${worksrcpath}/magick/.libs
Destroot
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. [58]
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. [66]
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. [67] [68]
Install
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. [69]
Activate
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. [58]
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. [69] [12]
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. [70]
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 is not always required for minor modifications. [72] [73]
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. [74] A team of MacPorts members, known as the project managers, help to lead and coordinate the project. [75]
Starting from 2016, meetings have occasionally been held once a year. [76] They normally take place in Slovenia, and allow for MacPorts members to work on future development. [71]
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. [77]
Users can view analytics data on the MacPorts website. [78]
Irssi is an Internet Relay Chat (IRC) client program for Linux, FreeBSD, macOS and Microsoft Windows. It was originally written by Timo Sirainen, and released under the terms of the GNU GPL-2.0-or-later in January 1999.
Darwin is the core Unix-like operating system of macOS, iOS, watchOS, tvOS, iPadOS, audioOS, visionOS, and bridgeOS. It previously existed as an independent open-source operating system, first released by Apple Inc. in 2000. It is composed of code derived from NeXTSTEP, FreeBSD, other BSD operating systems, Mach, and other free software projects' code, as well as code developed by Apple. Darwin's official mascot is Hexley the Platypus.
The Fink project is an effort to port and package open-source Unix programs to macOS. Fink uses dpkg and APT, as well as its own frontend program, fink
.
Portage is a package management system originally created for and used by Gentoo Linux and also by ChromeOS, Calculate, and Funtoo Linux among others. Portage is based on the concept of ports collections. Gentoo is sometimes referred to as a meta-distribution due to the extreme flexibility of Portage, which makes it operating-system-independent. The Gentoo/Alt project was concerned with using Portage to manage other operating systems, such as BSDs, macOS and Solaris. The most notable of these implementations is the Gentoo/FreeBSD project.
pkgsrc is a package management system for Unix-like operating systems. It was forked from the FreeBSD ports collection in 1997 as the primary package management system for NetBSD. Since then it has evolved independently; in 1999, support for Solaris was added, followed by support for other operating systems.
netcat is a computer networking utility for reading from and writing to network connections using TCP or UDP. The command is designed to be a dependable back-end that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and investigation tool, since it can produce almost any kind of connection its user could need and has a number of built-in capabilities.
sudo is a program for Unix-like computer operating systems that enables users to run programs with the security privileges of another user, by default the superuser. It originally stood for "superuser do", as that was all it did, and this remains its most common usage; however, the official Sudo project page lists it as "su 'do'". The current Linux manual pages for su define it as "substitute user", making the correct meaning of sudo "substitute user, do", because sudo can run a command as other users as well.
TrueOS is a discontinued Unix-like, server-oriented operating system built upon the most recent releases of FreeBSD-CURRENT.
yes
is a command on Unix and Unix-like operating systems, which outputs an affirmative response, or a user-defined string of text, continuously until killed.
Ports collections are the sets of makefiles and patches provided by the BSD-based operating systems, FreeBSD, NetBSD, and OpenBSD, as a simple method of installing software or creating binary packages. They are usually the base of a package management system, with ports handling package creation and additional tools managing package removal, upgrade, and other tasks. In addition to the BSDs, a few Linux distributions have implemented similar infrastructure, including Gentoo's Portage, Arch's Arch Build System (ABS), CRUX's Ports and Void Linux's Templates.
The FreeBSD Ports collection is a package management system for the FreeBSD operating system. Ports in the collection vary with contributed software. There were 38,487 ports available in February 2020 and 36,504 in September 2024. It has also been adopted by NetBSD as the basis of its pkgsrc system.
Kernel-based Virtual Machine (KVM) is a free and open-source virtualization module in the Linux kernel that allows the kernel to function as a hypervisor. It was merged into the mainline Linux kernel in version 2.6.20, which was released on February 5, 2007. KVM requires a processor with hardware virtualization extensions, such as Intel VT or AMD-V. KVM has also been ported to other operating systems such as FreeBSD and illumos in the form of loadable kernel modules.
This is a comparison of notable free and open-source configuration management software, suitable for tasks like server configuration, orchestration and infrastructure as code typically performed by a system administrator.
Nix is a cross-platform package manager for Unix-like systems, and a tool to instantiate and manage those systems, invented in 2003 by Eelco Dolstra.
RPM Package Manager (RPM) is a free and open-source package management system. The name RPM refers to the .rpm
file format and the package manager program itself. RPM was intended primarily for Linux distributions; the file format is the baseline package format of the Linux Standard Base.
SMPlayer is a cross-platform graphical front-end for MPlayer and mpv and forks of Mplayer using GUI widgets offered by Qt. SMPlayer is free and open-source software subject to the terms of the GNU General Public License version 2 or later. SMplayer has been localized in more than 30 languages.
Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's operating system, macOS, as well as Linux. The name is intended to suggest the idea of building software on the Mac depending on the user's taste. Originally written by Max Howell, the package manager has gained popularity in the Ruby on Rails community and earned praise for its extensibility. Homebrew has been recommended for its ease of use as well as its integration into the command-line interface. Homebrew is a member of the Open Source Collective, and is run entirely by unpaid volunteers.
Void Linux is an independent Linux distribution that uses the X Binary Package System (XBPS) package manager, which was designed and implemented from scratch, and the runit init system. Excluding binary kernel blobs, a base install is composed entirely of free software.
doas is a program to execute commands as another user. The system administrator can configure it to give specified users privileges to execute specified commands. It is free and open-source under the ISC license and available in Unix and Unix-like operating systems.