Skip to content

Commit 2ce8fa4

Browse files
committed
Trigger Mac git install.
1 parent 5ce9bff commit 2ce8fa4

1 file changed

Lines changed: 34 additions & 4 deletions

File tree

baremetal-bootstrap

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,39 @@ fi
5959

6060

6161
# main()
62-
echo "## Installing git."
63-
sudo apt-get -y update
64-
sudo apt-get -y install git-core build-essential
62+
63+
if [ -z "$(which git)" ]; then
64+
echo "## Installing git."
65+
sudo apt-get -y update
66+
sudo apt-get -y install git-core build-essential
67+
elif git --version 2>&1 >/dev/null | grep -q 'xcode-select'; then
68+
echo "## Triggering Xcode Command Line Tools installation. Either complete"
69+
echo "## that process or install git into your PATH yourself, then press"
70+
echo "## [ENTER] to continue."
71+
read WAIT_FOR_INSTALL_TO_FINISH
72+
if [ ! -x /Library/Developer/CommandLineTools/usr/bin/git ]; then
73+
echo "!! Git installation appears to have failed."
74+
echo "!! Please manually install and retry. Aborting."
75+
exit 5
76+
fi
77+
else
78+
echo "## Git appears to already be installed."
79+
fi
80+
81+
# Alternative fully automated approach:
82+
# Ref: https://apple.stackexchange.com/a/121044/17403
83+
#
84+
# xcode-select --install
85+
# sleep 1
86+
# osascript <<EOD
87+
# tell application "System Events"
88+
# tell process "Install Command Line Developer Tools"
89+
# keystroke return
90+
# click button "Agree" of window "License Agreement"
91+
# end tell
92+
# end tell
93+
# EOD
94+
6595

6696
echo "## Cloning repo."
6797
git clone -b $GIT_BRANCH $REPO_CLONE_URL repo
@@ -73,7 +103,7 @@ cd "${INSTALL_DIR}"
73103

74104
if [ ! -x "${BOOTSTRAP_SCRIPT}" ] ; then
75105
echo "!! Bootstrap script is not present. Exiting."
76-
exit 5
106+
exit 6
77107
fi
78108

79109
echo "## Executing bootstrap script."

0 commit comments

Comments
 (0)