- Installing MacPorts
Installing MacPorts
Introduction
This document describes the process for installing MacPorts, based on the MacPorts Installation Guide. There are also more instructions in the MacPorts Documentation. All options and alternatives are not described here, just one relatively simple way of installing MacPorts.
The GPG signatures for the installer can be downloaded from https://distfiles.macports.org/MacPorts/
Installing X11
Apple's X11 is installed as standard on Leopard (10.5) and Snow Leopard (10.6). On Tiger (10.4) it is an optional install. It can be installed from the original installation DVDs.
Both the X11 and X11SDK are needed. The X11SDK is part of the
Xcode Tools package (see the Xcode Tools section
below). You can check whether these are installed by looking for
com.apple.pkg.X11User.bom
and com.apple.pkg.X11SDKLeo.bom
in
/Library/Receipts/boms/
. On Mac OS X 10.4, the files are named
X11User.pkg
and X11SDK.pkg
in /Library/Receipts/
.
The following command should list these packages, if found:
Note: Only tested on Tiger.
$ find -E /Library/Receipts -regex '.*(com\.apple\.pkg\.X11(User|SDKLeo)\.bom|X11(User|SDK)\.pkg)'
Xcode Tools
Whilst the Xcode Tools package is included on the installation DVDs, it is recommended to download the latest version from the Apple Developer's Connection website. You have to register to download the tools. The free membership package suffices our needs. Note: The Xcode Tools package is a significant download size. The download sizes are shown against each download link.
Install the Xcode Tools and X11 SDK packages as follows:
Login to the Apple Developer Connection
Follow the link to the "Downloads" section
Select "Developer Tools" from the "Downloads" side bar
Search the Developer Tools page for the latest version of Xcode for your version of Mac OS X
At the time of writing, the versions are:
Mac OS X Xcode Tools Version --------------- ------------------- 10.4 Tiger 2.5 10.5 Leopard 3.1.4 10.6 Snow Leopard 3.2.1
Run the Xcode Tools package installer
Select the "Customize" option and open the "Applications" category and ensure that the "X11 SDK" option is selected
Make sure the command line development option is also selected
Select the "Install" option
MacPorts
To install the binary version of MacPorts:
Download the latest MacPorts-1.x.x.dmg disk image from the MacPorts download directory. Don't choose those containing -rc or -beta in their file name.
Run the installer choosing the "easy" installation option
That's it. MacPorts is now installed.
Managing Ports
Updating/Upgrading
Run sudo port selfupdate
periodically to update the local ports tree with
the global MacPorts repository.
Then run sudo port upgrade outdated
to upgrade any outdated installed ports.
Querying
Ports needing update:
$ sudo port selfupdate
$ port outdated
Installed ports:
$ port -qv installed
Ports specifically requested for installation:
$ port -qv installed requested
For a unique list, with duplicates removed:
$ port -qv installed requested | cut -d ' ' -f 4 | sort | uniq
Show list of installed files for a port
$ port -q contents <portname>
Ports that have older versions that could be removed
$ port installed inactive
Find which port a file belongs to:
$ port provides /path/to/file
Uninstall
$ sudo port uninstall <portname>
Consider also using the --follow-dependencies
to also remove automatically
installed dependencies that are not longer being used.
Uninstall a specific version:
$ sudo port uninstall ghc @7.8.3_4
Uninstall all inactive ports (ports with newer versions installed):
$ sudo port uninstall inactive
Cleanup
Remove build files for failed build:
$ sudo port clean gpsbabel
Remove unused automatically installed dependencies:
$ port echo leaves
$ sudo port uninstall --follow-dependencies leaves
Mark as not Requested
$ sudo port unsetrequested <portname>
Installing Older Port Versions
Essentially, if you still have the older version installed, simply execute
sudo port activate ${PACKAGE} @${VERSION}
, otherwise refer to the Macports
Wiki page titled
InstallingOlderPort.
port -v installed ossp-uuid
will list the currently installed versions.
sudo port activate <portname>
will list available versions and prompt for a
choice.
Deactivate a port
$ sudo port deactivate <portname>
Builds
Applications are built under /opt/local/var/macports/build/
Building Modified Portfile
These notes use information from 'MacPorts wiki—How to install an older version of a port' and 'Chapter 7, MacPorts Project' of the MacPorts Guide.
Clone the MacPorts git repository, e.g.
git clone --depth 1 https://github.com/macports/macports-ports.git
Create and checkout a new working branch, e.g.
git checkout -b git-fix
Modify the Portfile and create patches as desired. Increment the
revision
attribute in the Portfile.Change the working directory to that of the Portfile being build, e.g.
cd devel/git
Check the Portfile syntax
$ port lint --nitpick
Optionally run any existing tests
$ sudo port test
Build the port. Note that the port name is excluded from the command.
$ sudo port install -vst
The port should be installed with the new revision, e.g.:
$ port -qv installed git
If submitting a patch to the MacPorts project, follow the MacPorts guide on contributing to MacPorts and the guidelines for commit messages.
Migration—After Upgrading macOS
Make sure you also upgrade Xcode to the latest version that supports the macOS that you're interested in. Also, check the MacPorts wiki under the 'MacPorts Support' section which should have an item 'Problems with ports on specific releases of the Mac operating system'. It's probably a really good idea to check that before deciding to upgrade.
See https://trac.macports.org/wiki/Migration
Usage Statistics
See http://stats.macports.neverpanic.de/faq
Trouble-shooting
qlandkartegt port fails to build gpsbabel
Either download and install the Mac OS X version of GPSBabel from
https://www.gpsbabel.org/download.html or install the gpsbabel
port first.
On macOS 10.12 Sierra, gpsbabel can be built as follows:
$ sudo port install gpsbabel +qt4
-- Frank Dean - 31 Mar 2017
Builds failing to find stdlib
See:
Tk Deprecation Warning in macOS 10.15 (Catalina) running gitk
DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.
Resovled by installing the GUI toolkit for Tcl, Tk. MacPorts provides
this in the tk
package.
$ sudo port install tk
-- Frank Dean - 06 Jan 2020
Gitk
Blank Views
When quitting gitk
, the following error message is displayed:
Error in startup script: window "." was deleted before its visibility changed
while executing
"tkwait visibility ."
This is an issue with tk
and tcl
version 8.6.11. Activating the
older 8.6.10 versions may resolve the issue as a temporary workaround.
See also:
- Macports—How to install an older version of a port
- gitk: check main window visibility before waiting for it to show #944
- https://github.com/Homebrew/homebrew-core/issues/68798
Java version not detected
References
-- Frank Dean - 07 Feb 2010
Related Topics: AppleMaciBook, EmacsTips, InstallingKitlistMacOSX, MacKeyboardTips, Xcode