MacOS fixes
This commit is contained in:
@@ -297,6 +297,10 @@ touch "$REPO_ROOT/Zsh/.zsh_secrets"
|
||||
TARGET_SHELL="$(command -v zsh)"
|
||||
CURRENT_LOGIN_SHELL=""
|
||||
|
||||
if is_macos && [ -x /bin/zsh ]; then
|
||||
TARGET_SHELL="/bin/zsh"
|
||||
fi
|
||||
|
||||
if command -v getent >/dev/null 2>&1; then
|
||||
CURRENT_LOGIN_SHELL="$(getent passwd "$(whoami)" | cut -d: -f7)"
|
||||
elif is_macos && command -v dscl >/dev/null 2>&1; then
|
||||
|
||||
@@ -46,7 +46,7 @@ detect_arch() {
|
||||
|
||||
install_tool() {
|
||||
local tool="$1"
|
||||
local platform arch version owner repo asset binary_rel formula url tmp_dir archive_path extracted_path target_path installed_path
|
||||
local platform arch version owner repo asset binary_rel formula url tmp_dir archive_path extracted_path target_path installed_path formula_prefix
|
||||
|
||||
platform="$(detect_platform)"
|
||||
arch="$(detect_arch)"
|
||||
@@ -74,7 +74,13 @@ install_tool() {
|
||||
printf '%s already installed via Homebrew\n' "$tool"
|
||||
fi
|
||||
|
||||
installed_path="$(command -v "$tool" || true)"
|
||||
formula_prefix="$(brew --prefix "$formula" 2>/dev/null || true)"
|
||||
if [ -n "$formula_prefix" ] && [ -x "$formula_prefix/bin/$tool" ]; then
|
||||
installed_path="$formula_prefix/bin/$tool"
|
||||
else
|
||||
installed_path="$(command -v "$tool" || true)"
|
||||
fi
|
||||
|
||||
if [ -z "$installed_path" ]; then
|
||||
printf 'Installed formula %s but %s is not on PATH\n' "$formula" "$tool" >&2
|
||||
exit 1
|
||||
|
||||
@@ -44,7 +44,7 @@ sync_repo_managed_secret_file() {
|
||||
}
|
||||
|
||||
backup_conflicting_home_files() {
|
||||
local backup_dir backed_up_any=0 source_file filename target_file
|
||||
local backup_dir backed_up_any=0 source_file filename target_file target_resolved source_resolved
|
||||
|
||||
backup_dir="$BACKUP_ROOT/$(date +%Y%m%d-%H%M%S)"
|
||||
|
||||
@@ -52,7 +52,19 @@ backup_conflicting_home_files() {
|
||||
filename="$(basename "$source_file")"
|
||||
target_file="$HOME/$filename"
|
||||
|
||||
if [ -e "$target_file" ] && [ ! -L "$target_file" ]; then
|
||||
if [ -L "$target_file" ]; then
|
||||
target_resolved="$(python3 -c 'import os,sys; print(os.path.realpath(sys.argv[1]))' "$target_file")"
|
||||
source_resolved="$(python3 -c 'import os,sys; print(os.path.realpath(sys.argv[1]))' "$source_file")"
|
||||
|
||||
if [ "$target_resolved" = "$source_resolved" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
mkdir -p "$backup_dir"
|
||||
mv "$target_file" "$backup_dir/$filename"
|
||||
echo "Backed up existing linked $target_file -> $backup_dir/$filename"
|
||||
backed_up_any=1
|
||||
elif [ -e "$target_file" ]; then
|
||||
mkdir -p "$backup_dir"
|
||||
mv "$target_file" "$backup_dir/$filename"
|
||||
echo "Backed up existing $target_file -> $backup_dir/$filename"
|
||||
|
||||
Reference in New Issue
Block a user