Change installer scripts to prefer system-wide installation in /usr/local/bin, warn about user bin precedence, and offer to remove user bin versions after successful system installation
This commit is contained in:
@@ -282,33 +282,45 @@ determine_install_strategy() {
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
local install_type=$(echo "$current_info" | cut -d: -f2)
|
||||
|
||||
# Strategy 1: Check user bin directory first
|
||||
if check_user_bin_setup; then
|
||||
print_status "User bin directory is available and in PATH"
|
||||
# Strategy: Prefer system installation for all users
|
||||
if [[ $EUID -eq 0 ]] || sudo -n true 2>/dev/null; then
|
||||
print_status "Installing system-wide for all users"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
|
||||
# Check if borg exists in user bin
|
||||
# Warn if user bin has borg
|
||||
if [[ -f "$USER_BIN_DIR/borg" ]]; then
|
||||
print_status "Borg CLI found in user bin directory"
|
||||
print_warning "Borg CLI found in user bin directory ($USER_BIN_DIR)"
|
||||
print_status "This might take precedence if $USER_BIN_DIR is in PATH before system paths"
|
||||
fi
|
||||
else
|
||||
print_status "No sudo access, checking user bin directory"
|
||||
if check_user_bin_setup; then
|
||||
print_status "User bin directory is available and in PATH"
|
||||
|
||||
# Check for version symlink
|
||||
if check_version_symlink; then
|
||||
print_status "Version symlink found: $CURRENT_SYMLINK_VERSION"
|
||||
INSTALL_STRATEGY="user_update"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
# Check if borg exists in user bin
|
||||
if [[ -f "$USER_BIN_DIR/borg" ]]; then
|
||||
print_status "Borg CLI found in user bin directory"
|
||||
|
||||
# Check for version symlink
|
||||
if check_version_symlink; then
|
||||
print_status "Version symlink found: $CURRENT_SYMLINK_VERSION"
|
||||
INSTALL_STRATEGY="user_update"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
else
|
||||
print_status "No version symlink found, will create one"
|
||||
INSTALL_STRATEGY="user_upgrade"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
fi
|
||||
else
|
||||
print_status "No version symlink found, will create one"
|
||||
INSTALL_STRATEGY="user_upgrade"
|
||||
print_status "Borg CLI not found in user bin, will install there"
|
||||
INSTALL_STRATEGY="user_install"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
fi
|
||||
else
|
||||
print_status "Borg CLI not found in user bin, will install there"
|
||||
INSTALL_STRATEGY="user_install"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
print_error "Cannot install system-wide (no sudo) and user bin not available"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
print_status "User bin directory not available, using system installation"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
fi
|
||||
|
||||
print_status "Installation strategy: $INSTALL_STRATEGY"
|
||||
@@ -427,6 +439,34 @@ verify_borg_installation() {
|
||||
if command_exists borg; then
|
||||
local version=$(borg --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n 1)
|
||||
print_success "Borg CLI installed: $version"
|
||||
|
||||
# Check for user bin versions and offer removal
|
||||
if [[ -d "$USER_BIN_DIR" ]] && [[ "$TARGET_DIR" == "$SYSTEM_INSTALL_DIR" ]]; then
|
||||
local user_versions=()
|
||||
for file in "$USER_BIN_DIR"/borg*; do
|
||||
if [[ -f "$file" ]]; then
|
||||
user_versions+=("$file")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#user_versions[@]} -gt 0 ]]; then
|
||||
print_warning "Found borg binaries in user bin directory:"
|
||||
for file in "${user_versions[@]}"; do
|
||||
echo " $file"
|
||||
done
|
||||
echo
|
||||
read -p "Would you like to remove these user bin versions? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
for file in "${user_versions[@]}"; do
|
||||
rm -f "$file"
|
||||
print_status "Removed $file"
|
||||
done
|
||||
print_success "Removed all user bin versions"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "Borg CLI installation verification failed"
|
||||
|
||||
@@ -16,6 +16,7 @@ NC='\033[0m' # No Color
|
||||
# Configuration
|
||||
GITHUB_REPO="git-ecosystem/git-credential-manager"
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
USER_BIN_DIR="$HOME/bin"
|
||||
TEMP_DIR="/tmp/gcm-install"
|
||||
|
||||
# Function to print colored output
|
||||
@@ -451,6 +452,19 @@ verify_installation() {
|
||||
# Check all presets
|
||||
configure_git_presets
|
||||
|
||||
# Check for user bin version and offer removal
|
||||
if [[ -f "$USER_BIN_DIR/git-credential-manager" ]]; then
|
||||
print_warning "Found git-credential-manager in user bin directory ($USER_BIN_DIR)"
|
||||
print_status "This might take precedence if $USER_BIN_DIR is in PATH before system paths"
|
||||
echo
|
||||
read -p "Would you like to remove the user bin version? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
rm -f "$USER_BIN_DIR/git-credential-manager"
|
||||
print_success "Removed user bin version"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "git-credential-manager installation verification failed"
|
||||
|
||||
@@ -158,33 +158,45 @@ determine_install_strategy() {
|
||||
local current_version=$(echo "$current_info" | cut -d: -f1)
|
||||
local install_type=$(echo "$current_info" | cut -d: -f2)
|
||||
|
||||
# Strategy 1: Check user bin directory first
|
||||
if check_user_bin_setup; then
|
||||
print_status "User bin directory is available and in PATH"
|
||||
# Strategy: Prefer system installation for all users
|
||||
if [[ $EUID -eq 0 ]] || sudo -n true 2>/dev/null; then
|
||||
print_status "Installing system-wide for all users"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
|
||||
# Check if tea exists in user bin
|
||||
# Warn if user bin has tea
|
||||
if [[ -f "$USER_BIN_DIR/tea" ]]; then
|
||||
print_status "Tea CLI found in user bin directory"
|
||||
print_warning "Tea CLI found in user bin directory ($USER_BIN_DIR)"
|
||||
print_status "This might take precedence if $USER_BIN_DIR is in PATH before system paths"
|
||||
fi
|
||||
else
|
||||
print_status "No sudo access, checking user bin directory"
|
||||
if check_user_bin_setup; then
|
||||
print_status "User bin directory is available and in PATH"
|
||||
|
||||
# Check for version symlink
|
||||
if check_version_symlink; then
|
||||
print_status "Version symlink found: $CURRENT_SYMLINK_VERSION"
|
||||
INSTALL_STRATEGY="user_update"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
# Check if tea exists in user bin
|
||||
if [[ -f "$USER_BIN_DIR/tea" ]]; then
|
||||
print_status "Tea CLI found in user bin directory"
|
||||
|
||||
# Check for version symlink
|
||||
if check_version_symlink; then
|
||||
print_status "Version symlink found: $CURRENT_SYMLINK_VERSION"
|
||||
INSTALL_STRATEGY="user_update"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
else
|
||||
print_status "No version symlink found, will create one"
|
||||
INSTALL_STRATEGY="user_upgrade"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
fi
|
||||
else
|
||||
print_status "No version symlink found, will create one"
|
||||
INSTALL_STRATEGY="user_upgrade"
|
||||
print_status "Tea CLI not found in user bin, will install there"
|
||||
INSTALL_STRATEGY="user_install"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
fi
|
||||
else
|
||||
print_status "Tea CLI not found in user bin, will install there"
|
||||
INSTALL_STRATEGY="user_install"
|
||||
TARGET_DIR="$USER_BIN_DIR"
|
||||
print_error "Cannot install system-wide (no sudo) and user bin not available"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
print_status "User bin directory not available, using system installation"
|
||||
INSTALL_STRATEGY="system_install"
|
||||
TARGET_DIR="$SYSTEM_INSTALL_DIR"
|
||||
fi
|
||||
|
||||
print_status "Installation strategy: $INSTALL_STRATEGY"
|
||||
@@ -411,6 +423,34 @@ verify_tea_installation() {
|
||||
if command_exists tea; then
|
||||
local version=$(tea --version 2>/dev/null | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' | head -n 1)
|
||||
print_success "Tea CLI installed: $version"
|
||||
|
||||
# Check for user bin versions and offer removal
|
||||
if [[ -d "$USER_BIN_DIR" ]] && [[ "$TARGET_DIR" == "$SYSTEM_INSTALL_DIR" ]]; then
|
||||
local user_versions=()
|
||||
for file in "$USER_BIN_DIR"/tea*; do
|
||||
if [[ -f "$file" ]]; then
|
||||
user_versions+=("$file")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#user_versions[@]} -gt 0 ]]; then
|
||||
print_warning "Found tea binaries in user bin directory:"
|
||||
for file in "${user_versions[@]}"; do
|
||||
echo " $file"
|
||||
done
|
||||
echo
|
||||
read -p "Would you like to remove these user bin versions? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
for file in "${user_versions[@]}"; do
|
||||
rm -f "$file"
|
||||
print_status "Removed $file"
|
||||
done
|
||||
print_success "Removed all user bin versions"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
else
|
||||
print_error "Tea CLI installation verification failed"
|
||||
|
||||
Reference in New Issue
Block a user