Skip to content

Instantly share code, notes, and snippets.

@ilg-ul
Last active November 5, 2016 10:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilg-ul/439b0a8fe844ae4d551f to your computer and use it in GitHub Desktop.
Save ilg-ul/439b0a8fe844ae4d551f to your computer and use it in GitHub Desktop.
Install MacPorts in /opt/macports from sources.
#!/usr/bin/env bash
if [[ ${DEBUG} != "" ]]; then
set -x
fi
set -o errexit
set -o pipefail
set -o nounset
IFS=$'\n\t'
# https://gist.github.com/ilg-ul/383869cbb01f61a51c4d
# ----------------------------------------------------------------------------
# https://guide.macports.org/chunked/installing.macports.html
MP_VERSION="2.3.4"
MP_PREFIX="/opt/macports"
MP_BUILD_FOLDER="~/Work/MacPorts"
mkdir -p "${MP_BUILD_FOLDER}"
cd "${MP_BUILD_FOLDER}"
rm -rf "MacPorts-${MP_VERSION}"
curl "https://distfiles.macports.org/MacPorts/MacPorts-${MP_VERSION}.tar.bz2" | tar -x -v -f -
cd MacPorts-${MP_VERSION}
# Play safe, exclude possible trouble sources from PATH.
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
./configure --prefix="${MP_PREFIX}"
make
echo 'Enter sudo password'
# Potentially dangerous!
sudo rm -rf "${MP_PREFIX}"
sudo mkdir "${MP_PREFIX}"
sudo make install
export PATH="${MP_PREFIX}/bin":"${MP_PREFIX}/sbin":$PATH
sudo port -v selfupdate
# To use MacPorts, add something like this to ~/.profile
# alias mp='export PATH=/opt/macports/bin:/opt/macports/sbin:$PATH'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment