Last active
November 15, 2021 22:40
-
-
Save jlinoff/a16d5044e968ce7af109b841092be6e4 to your computer and use it in GitHub Desktop.
How i setup macports for monterey (MacOSX SDK 12)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How i fixed the SDK 12 warning from macports. | |
# Set me up as a sudo user. | |
# add this to /etc/sudoers (visudo) | |
# jlinoff ALL=(ALL) NOPASSWD: ALL | |
sudo dseditgroup -o edit -a jlinoff -t user admin | |
sudo dseditgroup -o edit -a jlinoff -t user wheel | |
# make sure xcode is installed and the license is accepted | |
xcode-select --install | |
xcodebuild -license accept | |
xcodebuild -version | |
xcode-select -version | |
# Check for the correct SDK | |
# ERROR: this showed no entry for MacOSX12.0.sdk | |
ls -l /Library/Developer/CommandLineTools/SDKs/ | |
# Get the SDK 12 path. | |
xcodebuild -sdk -version | grep ^Path: | grep MacOSX | |
# Link to it in thbe developer path for macports | |
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \ | |
/Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk | |
# verify - no warning should be reported. | |
sudo port install tree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Re-create an existing macports instalaation from scratch. | |
# | |
##set -ex | |
set -e | |
# Change this for a new version of macports | |
PKGURL="https://github.com/macports/macports-base/releases/download/v2.7.1/MacPorts-2.7.1-10.15-Catalina.pkg" | |
# Make sure the paths are correct. | |
export PATH="/opt/local/bin:/opt/local/sbin:$PATH" | |
export MANPATH="/opt/local/share/man:$MANPATH" | |
# add in my packages | |
if [ ! -f /tmp/pkgs.txt ] ; then | |
port installed >/tmp/pkgs.txt | |
fi | |
# download macports | |
if [ ! -f /tmp/macports.pkg ] ; then | |
curl -X GET -L "$PKGURL" \ | |
--out /tmp/macports.pkg | |
ls -l /tmp/macports.pkg | |
fi | |
# update sudo - not used here | |
#sudo dseditgroup -o edit -a $USER -t user admin | |
#sudo dseditgroup -o edit -a $USER -t user wheel | |
# remove macports | |
# URL: https://guide.macports.org/chunked/installing.macports.uninstalling.html | |
if [ -f /opt/local/bin/port ] ; then | |
sudo port -fp uninstall installed || true | |
sudo dscl . -delete /Users/macports || true | |
sudo dscl . -delete /Groups/macports || true | |
sudo rm -rf /opt/local | |
sudo rm -rf /Applications/DarwinPorts | |
sudo rm -rf /Applications/MacPorts | |
sudo rm -rf /Library/LaunchDaemons/org.macports.* | |
sudo rm -rf /Library/Receipts/DarwinPorts*.pkg | |
sudo rm -rf /Library/Receipts/MacPorts*.pkg | |
sudo rm -rf /Library/StartupItems/DarwinPortsStartup | |
sudo rm -rf /Library/Tcl/darwinports1.0 | |
sudo rm -rf /Library/Tcl/macports1.0 | |
sudo rm -rf ~/.macports | |
fi | |
# make sure xcode is installed and the license is accepted | |
xcode-select --install || true | |
sudo xcodebuild -license accept | |
xcodebuild -version | |
xcode-select -version | |
# Get the MacOSX.platform.sdk path. | |
SDKPATH=$(xcodebuild -sdk -version | grep ^Path: | grep -E 'MacOSX[0-9\.]*.sdk' | awk '{print $2}') | |
SDKFILE=$(basename "$SDKPATH") | |
DSTPATH="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$SDKFILE" | |
# Link to it in the developer path for macports | |
if [ ! -e "$DSTPATH" ] ; then | |
sudo ln -s "$SDKPATH" "$DSTPATH" | |
fi | |
# install macports using the built-in installer | |
sudo installer -pkg /tmp/macports.pkg -target / | |
# re-add all the packages from the previous install | |
# https://ports.macports.org/search/? | |
# order is important here. | |
PKGS=($(grep '^ ' /tmp/pkgs.txt | awk '{print $1}' | uniq)) | |
total=${#PKGS[@]} | |
for PKG in "${PKGS[@]}" ; do | |
i=$(( i + 1)) | |
printf 'INFO:%d: installing pkg %d of %d - %s' "$LINENO" "$i" "$total" "$PKG" | |
yes | sudo port install "$PKG" | |
done | |
# python-3.9 is my default version, to get pipenv to work i had to do this: | |
port select --set pip3 pip39 | |
pip3 install pipenv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment