feat: add macos commandlinetools (for pyenv, brew, etc)

This commit is contained in:
AJ ONeal
2024-01-09 02:20:13 +00:00
parent 63a08e8ace
commit e00fe40725
3 changed files with 118 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
---
title: XCode Command Line Tools
homepage: https://webinstall.dev/commandlinetools
tagline: |
The XCode Command Line Tools include git, swift, make, clang, and other developer tools
---
## Cheat Sheet
> The developer tools provided by Apple for macOS.
- git
- swift
- make
- clang
- etc
This is also part of [webi-essentials](../webi-essentials/).
## Table of Contents
- Files
- Manual Install
- macOS
- Linux
- Alpine
- Windows
### Files
These are the files / directories that are created and/or modified with this
install:
```sh
/Library/Developer/CommandLineTools/
```
### How to Install Manually
It's very easy to start the installer:
```sh
xcode-select --install
```
The trick is to also have a mechanism to know when it has finished:
```sh
while ! test -x /Library/Developer/CommandLineTools/usr/bin/git ||
! test -x /Library/Developer/CommandLineTools/usr/bin/make; do
sleep 0.25
done
echo "Command Line Tools Installed"
```

View File

@@ -0,0 +1,62 @@
#!/bin/sh
set -e
set -u
fn_install_xcode_commandlinetools() { (
b_os="$(uname -s)"
if test "${b_os}" != 'Darwin'; then
echo >&2 'XCode Command Line Tools are for macOS only'
return 1
fi
# streamline the output to be pretty
fn_check_pkg '/Library/Developer/CommandLineTools/usr/bin/clang' 'clang'
fn_check_pkg '/Library/Developer/CommandLineTools/usr/bin/git' 'git'
fn_check_pkg '/Library/Developer/CommandLineTools/usr/bin/make' 'make'
echo >&2 ""
# git
if xcode-select -p > /dev/null 2> /dev/null; then
echo ""
return 0
fi
cmd_xcode_cli_tools_install="xcode-select --install"
echo " Running $(t_cmd "${cmd_xcode_cli_tools_install}")"
$cmd_xcode_cli_tools_install 2> /dev/null
echo ""
echo ">>> $(t_attn 'ACTION REQUIRED') <<<"
echo ""
echo " $(t_attn "Click") '$(t_bold 'Install')' $(t_attn "in the pop-up")"
echo " (it may appear $(t_em 'under') this window)"
echo ""
echo "^^^ $(t_attn 'ACTION REQUIRED') ^^^"
echo ""
printf " waiting %s to finish installing Command Line Developer Tools ..." "$(t_em 'for you')"
while ! test -x /Library/Developer/CommandLineTools/usr/bin/git ||
! test -x /Library/Developer/CommandLineTools/usr/bin/make; do
sleep 0.25
done
echo " $(t_info 'OK')"
echo " Installed to $(t_path '/Library/Developer/CommandLineTools/')"
sleep 1
); }
fn_check_pkg() { (
a_pkg="${1}"
a_pkgname="${2:-$a_pkg}"
printf >&2 ' %s %s %s' \
"$(t_dim "Checking for")" \
"$(t_pkg "${a_pkgname}")" \
"$(t_dim "...")"
if command -v "${a_pkg}" > /dev/null; then
echo >&2 " $(t_dim 'OK')"
return 0
fi
echo >&2 ' missing'
); }
fn_install_xcode_commandlinetools

1
xcode-cli Symbolic link
View File

@@ -0,0 +1 @@
commandlinetools