Various macOS fixes

This commit is contained in:
Brian Zalewski 2024-05-03 04:07:06 +00:00
parent 36cf2e0cce
commit dc25b5b227
14 changed files with 98 additions and 35 deletions

View file

@ -21,12 +21,12 @@ if [ -f "$(dirname "$0")/_/husky.sh" ]; then
logger info 'This git hook is configured to run even when --no-verify is used. In order to bypass this prompt, use the -n flag instead.' logger info 'This git hook is configured to run even when --no-verify is used. In order to bypass this prompt, use the -n flag instead.'
logger info 'Opening a `git commit` dialog' logger info 'Opening a `git commit` dialog'
if ! type pnpx > /dev/null && type npm > /dev/null; then if ! type pnpx > /dev/null && type npm > /dev/null; then
npm install -g pnpm npm install --no-progress -g pnpm
elif ! type pnpx > /dev/null; then elif ! type pnpx > /dev/null; then
logger error '`pnpm` or `npm` must be installed' logger error '`pnpm` or `npm` must be installed'
fi fi
if ! type git-cz &> /dev/null; then if ! type git-cz &> /dev/null; then
pnpm install -g commitizen pnpm install --no-progress -g commitizen
fi fi
exec < /dev/tty && (git-cz --hook || true) exec < /dev/tty && (git-cz --hook || true)
fi fi

View file

@ -146,6 +146,13 @@ upgradeDarwin() {
export SUDO_PASSWORD export SUDO_PASSWORD
fi fi
### Ensure Rosetta 2 is installed
if /usr/bin/pgrep -q oahd; then
logg info 'Rosetta 2 is already installed'
else
logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license
fi
### Run upgrade process ### Run upgrade process
logg info 'Checking for available OS upgrades' logg info 'Checking for available OS upgrades'
UPDATE_CHECK="$(softwareupdate -l 2>&1)" UPDATE_CHECK="$(softwareupdate -l 2>&1)"

View file

@ -504,7 +504,7 @@ installSystemPips() {
if command -v pip3 > /dev/null; then if command -v pip3 > /dev/null; then
if command -v python3 > /dev/null; then if command -v python3 > /dev/null; then
if ! python3 -m certifi > /dev/null; then if ! python3 -m certifi > /dev/null; then
pip3 install certifi pip3 install --break-system-packages certifi
else else
logg info 'certifi is available to python3' logg info 'certifi is available to python3'
fi fi
@ -664,7 +664,7 @@ installBrewPackages() {
ensureBrewPackageInstalled "volta" ensureBrewPackageInstalled "volta"
volta install node@latest & volta install node@latest &
volta install yarn@latest & volta install yarn@latest &
npm install -g npm@latest & npm install --no-progress -g npm@latest &
ensureBrewPackageInstalled "pipx" ensureBrewPackageInstalled "pipx"
pipx ensurepath & pipx ensurepath &
ensureBrewPackageInstalled "gh" ensureBrewPackageInstalled "gh"
@ -685,6 +685,8 @@ ensureMacportsInstalled() {
logg info 'Cloning source for macports to /opt/mports/macports-base' && sudo git clone --branch v2.8.0 --depth 1 https://github.com/macports/macports-base.git /opt/mports/macports-base logg info 'Cloning source for macports to /opt/mports/macports-base' && sudo git clone --branch v2.8.0 --depth 1 https://github.com/macports/macports-base.git /opt/mports/macports-base
cd /opt/mports/macports-base cd /opt/mports/macports-base
logg info 'Building macports' && sudo bash --noprofile --norc -c './configure --enable-readline && make && make install && make distclean' logg info 'Building macports' && sudo bash --noprofile --norc -c './configure --enable-readline && make && make install && make distclean'
logg info 'Adding /opt/local/bin to PATH because port is installed there'
export PATH="/opt/local/bin:$PATH"
logg info 'Running sudo port selfupdate' && sudo port selfupdate logg info 'Running sudo port selfupdate' && sudo port selfupdate
fi fi
fi fi
@ -731,29 +733,31 @@ rustUpInit() {
} }
zapInstall() { zapInstall() {
if ! command -v zap > /dev/null; then if [ ! -d /Applications ] && [ ! -d /System ]; then
### Architecture if ! command -v zap > /dev/null; then
if [ -z ${ARCH+x} ]; then ### Architecture
MACHINE_ARCH="$(uname -m)" if [ -z ${ARCH+x} ]; then
if [ "$MACHINE_ARCH" = "amd64" ]; then MACHINE_ARCH="$(uname -m)"
ARCH="amd64" if [ "$MACHINE_ARCH" = "amd64" ]; then
elif [ "$MACHINE_ARCH" = "x86_64" ]; then ARCH="amd64"
ARCH="amd64" elif [ "$MACHINE_ARCH" = "x86_64" ]; then
elif [ "$MACHINE_ARCH" = "i386" ]; then ARCH="amd64"
ARCH="386" elif [ "$MACHINE_ARCH" = "i386" ]; then
elif [ "$MACHINE_ARCH" = "i686" ]; then ARCH="386"
ARCH="386" # both are 32bit, should be compatible elif [ "$MACHINE_ARCH" = "i686" ]; then
elif [ "$MACHINE_ARCH" = "aarch64" ]; then ARCH="386" # both are 32bit, should be compatible
ARCH="arm64" elif [ "$MACHINE_ARCH" = "aarch64" ]; then
elif [ "$MACHINE_ARCH" = "arm64" ]; then ARCH="arm64"
ARCH="arm64" elif [ "$MACHINE_ARCH" = "arm64" ]; then
elif [ "$MACHINE_ARCH" = "arm" ]; then ARCH="arm64"
ARCH="arm" elif [ "$MACHINE_ARCH" = "arm" ]; then
fi ARCH="arm"
export ARCH fi
export ARCH
fi
logg info 'Downloading zap to /usr/local/bin/zap' && sudo curl -sSL --output /usr/local/bin/zap "https://github.com/srevinsaju/zap/releases/download/continuous/zap-${ARCH}"
logg info 'Making /usr/local/bin/zap executable' && sudo chmod +x /usr/local/bin/zap
fi fi
logg info 'Downloading zap to /usr/local/bin/zap' && sudo curl -sSL --output /usr/local/bin/zap "https://github.com/srevinsaju/zap/releases/download/continuous/zap-${ARCH}"
logg info 'Making /usr/local/bin/zap executable' && sudo chmod +x /usr/local/bin/zap
fi fi
} }
@ -763,6 +767,17 @@ addFlathub() {
fi fi
} }
setupLinuxHomebrewFonts() {
if [ ! -d /Applications ] && [ ! -d /System ]; then
logg info 'Tapping homebrew/linux-fonts' && brew tap homebrew/linux-fonts
logg info 'Symlinking linuxbrew/share/fonts to /usr/local/share' && sudo ln -s /home/linuxbrew/.linuxbrew/share/fonts -t /usr/local/share
if command -v fc-cache > /dev/null; then
logg info 'Running sudo fc-cache -fv' && sudo fc-cache -fv
else
logg warn 'fc-cache binary not available for setting up Linux Homebrew fonts'
fi
}
# TODO - Add install on macOS for macports # TODO - Add install on macOS for macports
if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then
logg info 'The DEBUG or DEBUG_MODE environment variable is set so preliminary system tweaks will be run synchronously' logg info 'The DEBUG or DEBUG_MODE environment variable is set so preliminary system tweaks will be run synchronously'
@ -787,6 +802,7 @@ if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then
setupSnap setupSnap
showNotificationCenter showNotificationCenter
zapInstall zapInstall
setupLinuxHomebrewFonts
else else
addFlathub & addFlathub &
allocateSwap & allocateSwap &
@ -809,6 +825,7 @@ else
setupSnap & setupSnap &
showNotificationCenter & showNotificationCenter &
zapInstall & zapInstall &
setupLinuxHomebrewFonts &
wait wait
fi fi

View file

@ -4,6 +4,9 @@
# Standard Homebrew taps # Standard Homebrew taps
tap "homebrew/cask-versions" # Initially added to support "visual-studio" cask tap "homebrew/cask-versions" # Initially added to support "visual-studio" cask
tap "homebrew/bundle" tap "homebrew/bundle"
tap "homebrew/autoupdate"
tap "homebrew/services"
tap "homebrew/cask-fonts"
if OS.mac? if OS.mac?
brew "coreutils" brew "coreutils"
@ -27,6 +30,7 @@ brew "jq"
brew "moreutils" brew "moreutils"
brew "node" brew "node"
brew "openssh" brew "openssh"
brew "pinentry-mac"
brew "pipx" brew "pipx"
brew "pkg-config" brew "pkg-config"
brew "progress" brew "progress"
@ -41,5 +45,5 @@ brew "yarn"
brew "yq" brew "yq"
brew "zx" brew "zx"
cask "docker" cask "docker"
cask "java" unless system "/usr/libexec/java_home --failfast" cask "java@beta" unless system "/usr/libexec/java_home --failfast"
cask "macfuse" cask "macfuse"

View file

@ -63,9 +63,15 @@
<key>ProfileCurrentVersion</key> <key>ProfileCurrentVersion</key>
<real>2.0699999999999998</real> <real>2.0699999999999998</real>
<key>SecureKeyboardEntry</key> <key>SecureKeyboardEntry</key>
<false/> <true/>
<key>ShowLineMarks</key>
<integer>0</integer>
<key>Startup Window Settings</key> <key>Startup Window Settings</key>
<string>Betelgeuse</string> <string>Betelgeuse</string>
<key>StringEncodings</key>
<array>
<string>4</string>
</array>
<key>TTAppPreferences Selected Tab</key> <key>TTAppPreferences Selected Tab</key>
<integer>1</integer> <integer>1</integer>
<key>Window Settings</key> <key>Window Settings</key>

View file

@ -0,0 +1,2 @@
[global]
break-system-packages = true

View file

@ -17,7 +17,7 @@ fi
# Basic command aliases for verbosity / simplicity # Basic command aliases for verbosity / simplicity
alias cp='cp -v' alias cp='cp -v'
alias ln='ln -sriv' # alias ln='ln -sriv' # ln: illegal option -- r
alias mv='mv -vi' alias mv='mv -vi'
alias rm='rm -vi' alias rm='rm -vi'

View file

@ -429,7 +429,9 @@ defaults write com.apple.dock show-recents -bool false
#defaults write com.apple.dock showLaunchpadGestureEnabled -int 0 #defaults write com.apple.dock showLaunchpadGestureEnabled -int 0
# Reset Launchpad, but keep the desktop wallpaper intact # Reset Launchpad, but keep the desktop wallpaper intact
find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -delete if [ -d "${HOME}/Library/Application Support/Dock" ]; then
find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -delete
fi
# Add iOS & Watch Simulator to Launchpad # Add iOS & Watch Simulator to Launchpad
sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" "/Applications/Simulator.app" sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" "/Applications/Simulator.app"

View file

@ -188,6 +188,11 @@ ensureBasicDeps() {
XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')" XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')"
logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG" logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG"
fi fi
if /usr/bin/pgrep -q oahd; then
logg info 'Rosetta 2 is already installed'
else
logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license
fi
elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then
### Windows ### Windows
logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync

View file

@ -155,6 +155,11 @@ ensureBasicDeps() {
XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')" XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')"
logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG" logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG"
fi fi
if /usr/bin/pgrep -q oahd; then
logg info 'Rosetta 2 is already installed'
else
logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license
fi
elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then
### Windows ### Windows
logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync

View file

@ -124,6 +124,11 @@ ensureBasicDeps() {
XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')" XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')"
logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG" logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG"
fi fi
if /usr/bin/pgrep -q oahd; then
logg info 'Rosetta 2 is already installed'
else
logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license
fi
elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then
### Windows ### Windows
logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync

View file

@ -38,6 +38,11 @@ ensureBasicDeps() {
XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')" XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')"
logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG" logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG"
fi fi
if /usr/bin/pgrep -q oahd; then
logg info 'Rosetta 2 is already installed'
else
logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license
fi
elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then
### Windows ### Windows
logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync

View file

@ -188,6 +188,11 @@ ensureBasicDeps() {
XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')" XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')"
logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG" logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG"
fi fi
if /usr/bin/pgrep -q oahd; then
logg info 'Rosetta 2 is already installed'
else
logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license
fi
elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then
### Windows ### Windows
logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync

View file

@ -12619,7 +12619,7 @@ softwarePackages:
else else
logg info 'Installing Tabby plugins defined in '"${XDG_CONFIG_HOME:-$HOME/.config}/tabby/plugins/package.json"'' logg info 'Installing Tabby plugins defined in '"${XDG_CONFIG_HOME:-$HOME/.config}/tabby/plugins/package.json"''
cd "${XDG_CONFIG_HOME:-$HOME/.config}/tabby/plugins" cd "${XDG_CONFIG_HOME:-$HOME/.config}/tabby/plugins"
npm install --quiet npm install --quiet --no-progress
logg success 'Finished installing Tabby plugins' logg success 'Finished installing Tabby plugins'
fi fi
else else
@ -13558,8 +13558,8 @@ softwarePackages:
# which should correlate to the Coc extensions defined in `${XDG_CONFIG_HOME:-$HOME/.config}/vim/vimrc`. # which should correlate to the Coc extensions defined in `${XDG_CONFIG_HOME:-$HOME/.config}/vim/vimrc`.
installCocExtensions() { installCocExtensions() {
if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions/package.json" ]; then if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions/package.json" ]; then
logg info "Running npm i --no-package-lock in ${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions" logg info "Running npm i --no-progress --no-package-lock in ${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions"
cd "${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions" && npm i --no-package-lock cd "${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions" && npm i --no-progress --no-package-lock
logg info "Running vim +CocUpdateSync +qall" && vim +CocUpdateSync +qall logg info "Running vim +CocUpdateSync +qall" && vim +CocUpdateSync +qall
else else
logg info "Skipping Coc extension installation because ${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions/package.json is missing" logg info "Skipping Coc extension installation because ${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions/package.json is missing"
@ -13980,12 +13980,12 @@ softwarePackages:
if sudo cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/vscode/package.json" /package.json; then if sudo cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/vscode/package.json" /package.json; then
logg info 'Successfully copied linter fallback configurations package.json to /package.json' logg info 'Successfully copied linter fallback configurations package.json to /package.json'
logg info 'Installing system root directory node_modules' logg info 'Installing system root directory node_modules'
cd / && sudo npm i --quiet --no-package-lock || EXIT_CODE=$? cd / && sudo npm i --quiet --no-progress --no-package-lock || EXIT_CODE=$?
else else
logg warn 'Unable to successfully copy linter fallback configurations package.json to /package.json' logg warn 'Unable to successfully copy linter fallback configurations package.json to /package.json'
logg info 'Installing linter fallback configurations node_modules to home directory instead' logg info 'Installing linter fallback configurations node_modules to home directory instead'
cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/vscode/package.json" "$HOME/package.json" cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/vscode/package.json" "$HOME/package.json"
cd ~ && npm i --quiet --no-package-lock || EXIT_CODE=$? cd ~ && npm i --quiet --no-progress --no-package-lock || EXIT_CODE=$?
fi fi
### Log message if install failed ### Log message if install failed
if [ -n "$EXIT_CODE" ]; then if [ -n "$EXIT_CODE" ]; then