Last active
January 18, 2024 05:20
-
-
Save trinitronx/6217746 to your computer and use it in GitHub Desktop.
Script to download & install XCode Command Line tools on OSX 10.7 or 10.8. Lifted from jedi4ever/veewee template.
This file contains 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
#!/bin/sh | |
# 2021-12-09: | |
# This script is no longer supported! | |
# Apple broke all direct downloads without logging with an Apple ID first. | |
# The number of hoops that a script would need to jump through to login, | |
# store cookies, and download is prohibitive. | |
# Now we all must manually download and mirror the files for this to work at all :'-( | |
OSX_VERS=$(sw_vers -productVersion | awk -F "." '{print $2}') | |
# Get Xcode CLI tools | |
# https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/index-3905972D-B609-49CE-8D06-51ADC78E07BC.dvtdownloadableindex | |
# https://developer.apple.com/downloads/index.action | |
TOOLS=clitools.dmg | |
if [ ! -f "$TOOLS" ]; then | |
if [ "$OSX_VERS" -eq 7 ]; then | |
DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_xcode_os_x_lion_april_2013.dmg | |
elif [ "$OSX_VERS" -eq 8 ]; then | |
DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_xcode_os_x_mountain_lion_april_2013.dmg | |
elif [ "$OSX_VERS" -eq 9 ]; then | |
DMGURL=http://adcdownload.apple.com/Developer_Tools/command_line_tools_os_x_mavericks_for_xcode__late_october_2013/command_line_tools_os_x_mavericks_for_xcode__late_october_2013.dmg | |
elif [ "$OSX_VERS" -eq 10 ]; then | |
DMGURL=http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_OS_X_10.10_for_Xcode_6.3.2/commandlinetoolsosx10.10forxcode6.3.2.dmg | |
elif [ "$OSX_VERS" -eq 11 ]; then | |
DMGURL=http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_OS_X_10.11_for_Xcode_7.3.1/Command_Line_Tools_OS_X_10.11_for_Xcode_7.3.1.dmg | |
elif [ "$OSX_VERS" -eq 12 ]; then | |
DMGURL=http://adcdownload.apple.com/Developer_Tools/Command_Line_Tools_macOS_10.12_for_Xcode_8.1/Command_Line_Tools_macOS_10.12_for_Xcode_8.1.dmg | |
elif [ "$OSX_VERS" -eq 14 ]; then | |
DMGURL=https://download.developer.apple.com/Developer_Tools/Command_Line_Tools_for_Xcode_11_GM_Seed/Command_Line_Tools_for_Xcode_11_GM_Seed.dmg | |
fi | |
curl "$DMGURL" -o "$TOOLS" | |
fi | |
TMPMOUNT=`/usr/bin/mktemp -d /tmp/clitools.XXXX` | |
hdiutil attach "$TOOLS" -mountpoint "$TMPMOUNT" | |
installer -pkg "$(find $TMPMOUNT -name '*.mpkg' -o -name '*.pkg')" -target / | |
hdiutil detach "$TMPMOUNT" | |
rm -rf "$TMPMOUNT" | |
rm "$TOOLS" | |
exit |
@TheTechRobo yeah that would probably work. However, it defeats the original purpose of this script: unattended automated Xcode installations.
This type of broken download URL problem is why Homebrew doesn't accept certain apps. It's too much of a nightmare to keep things working when URLs break, move behind paywall or login, redirect to unverified third-party domain, etc...
Would be better than nothing tho, especially sinc eyou can use the same cookies file for many machines
So, I figured out another way around having to maintain URLs for the CLT packages... I ended up deprecating this script and using an AppleScript instead
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Might work if you pass in a cookies.txt file to curl ... the
-b cookies.txt
option should do it.Just make sure you export it in the old Netscape format. Lots of FF and Chrome extensions to do this.
You can just login with an apple id and export the cookies.txt then pass it in.
Not pretty but it would probably work.
Unforutnately I can't test - I moved away from mac completely recently.