It's safe to say that the App Store has become more ubiquitous thanks to Apple's ecosystem. Before the advent of the iPhone, purchasing digital software often involved numerous steps such as redirecting payments to developer websites, waiting for license keys via email, and negotiating refunds.
Unraveling the Mysteries of MacPorts: Installation, Operation, and Utilization
Many users often assume that free and open-source software (FOSS) on Mac is scarce. However, in reality, Mac hosts some of the best free tools available.
What is MacPorts?
MacPorts is a system package for Mac, akin to functionalities and usage of Red Hat Package Management (RPM) and Advanced Package Tool (APT), installing DEB packages on Linux. In fact, MacPorts has its roots in the Ports system of FreeBSD.
You might not be aware that Darwin forms the “core” of Mac OS X. Even today's macOS has a robust UNIX-based foundation. This enables developers to easily create a “port” of free software applications running on Mac.
MacPorts is a collection of such software, akin to apps available in a store or installer. In the FreeBSD world, the ports system aids users in compiling software from source:
1. Begin by accessing the ports collection, a vast array of application descriptions and build instructions, stored in the “/usr/ports” directory with each port having its own subdirectory.
2. Then navigate to the application's directory and utilize the “make install” command. The Makefile constructs the application from scratch: fetching source code, compiling, and configuring the application.
In the example below, you can see the content of the Amarok music player port from KDE. You can even rebuild the entire system from source with the command “make world”.
MacPorts follows this model. When you select an application, the system will download, compile, and install that application on your Mac.
What types of ports are available?
The MacPorts repository houses a plethora of open-source applications similar to those found on Linux and related operating systems. If you're already familiar with Linux, you have ample opportunities to use your favorite applications among the over 19,000 available, but instead of installing and maintaining Unix-like applications, these applications are uniquely integrated into macOS.
You can find some useful applications such as the Emacs and VIM text editors and various other free applications.
If you're seeking a specific program, you can browse through the link above or use the command “port search”. Some available software includes:
- Servers: Standard FOSS servers including AMP (Apache web server, MySQL/Maria database server, and PHP/Python), SSH, SAMBA, and BIND DNS server.
- GNOME/KDE Software: If you're a Linux user, you can choose from ports ranging from GNOME port 325 to KDE port 274, ensuring you don't miss out on any software, from GNOME's GnuCash to KDE's Amarok. Other options include XFCE and NextStep for other computers.
- Text Processing: If you're coding or simply want to work in plain text, you're well covered. Text editors like Emacs and VIM are available to users, while applications and systems like Multimarkdown, DocBook, and LaTeX support code publishing in various formats.
- Programming Languages: Includes standard programming languages like Python, PHP, Ruby, as well as newer or specialized languages like CoffeeScript, Lua, and Kotlin. Other tools such as development environments (e.g., Qt Creator for Mac) and compilers (gcc) are also available.
Installation and Setup of MacPorts
Since MacPorts compiles software on Mac, you'll need some development tools. Your first task is to install Xcode, an application available in the App Store.
Download Apple Xcode for Mac and install it here: Download Apple Xcode for Mac
Next, open the Terminal app and enter the command below. A dialog box will appear on the screen for you to download and install Xcode command line tools:
xcode-select -install
Downloading the MacPorts front-end is as simple as downloading an app for your macOS version from the installation page: Download MacPorts
The MacPorts front-end is presented as a PKG file, so you'll see a familiar wizard window. It guides you through the installation process. Simply click Continue on the windows as there are no options for you to set up.
Once installation is complete, you won't see anything unusual present in the Applications folder like a typical Mac program. The port search application is a command-line program, so you'll need to activate Terminal (or your favorite Terminal app on Mac) to get started.
First up is updating the ports collection (descriptions of available applications):
sudo port selfupdate
Installing the First Port
After the update, you can begin searching for applications to install. In the Terminal window, you can search by keyword using port search commands. For example, if you want to find a file manager, you can search for similar apps on the App Store or use the command below:
port search 'file manager'
In the list of results, locate and select Krusader. The Linux powerhouse tool is enhanced with additional features like file synchronization and archive management. To install Krusader, run the command below:
sudo port install krusader
Of course, since you're running the 'sudo' command, you'll need to enter the Admin password. The installation process will take some time.
Before looking away from the screen, take a moment to check the automatic downloading and building of applications.
1. First, MacPorts determines the order in which ports should be installed based on their dependencies.
2. For each port, MacPorts will download its source repository from the server.
3. MacPorts will also verify that each port has an equal right by comparing the checksum of the repository with the port description.
4. Then, it'll unpack the source of the port.
5. If there's a configuration script to run before building the application, proceed with the following steps.
6. Build the software, involving compiling all the source into something that Mac can execute.
7. Once built, the resulting executable resides in its attribute directory, then registering the application with the system.
8. Finally, MacPorts will clean up all the sources.
At this point, you'll see a subdirectory containing your application within the Applications folder named MacPorts. In this example, the subdirectory is named KDE4, containing the Krusader application. Drag this folder to the Dock like other app folders, and you can open the app using Spotlight.
Updating and Removing Ports
To update the ports collection, you use the first command mentioned by Mytour above, which also updates MacPorts applications:
sudo port selfupdate
Next, you can list outdated ports by using the command:
port outdated
To upgrade the ports, you use the command:
sudo port upgrade
To upgrade subcommands, follow similar steps as installation, except it will overwrite old versions.
If you try to install an application but it fails, and you want to remove that application, use the uninstall command below:
sudo port uninstall pallet
Exploring MacPorts, how it works, installing, and utilizing MacPorts
Note that in the above command, it uninstalls pallet installation; you can replace pallet with the name of the application you want to uninstall.
The MacPorts project is an excellent solution providing open-source software. You have full access to all codes, in a specific format for installation and maintaining applications.
Hopefully, after delving into MacPorts, understanding how it operates, installing, and using MacPorts, you'll no longer consider free and open-source software (FOSS) on Mac as rare.