-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall_antigravity
More file actions
executable file
·132 lines (111 loc) · 3.9 KB
/
Copy pathinstall_antigravity
File metadata and controls
executable file
·132 lines (111 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
set -eo pipefail
# --- Configuration ---
# Default repo URL (can be overridden by env var)
: "${GIT_REPO_URL:=https://github.com/BOTOOM/google-antigravity-bin-arch.git}"
: "${CLONED_REPO_DIR_NAME:=google-antigravity-bin-arch}"
: "${PKGBUILD_SUBDIR:=package}"
: "${ANTIGRAVITY_PKG_NAME:=google-antigravity-bin}"
# --- Helper Functions ---
log() {
echo "[INFO] $(date +'%T') - $1"
}
error_exit() {
echo "[ERROR] $(date +'%T') - $1" >&2
exit 1
}
check_command() {
command -v "$1" >/dev/null 2>&1 || error_exit "Required command '$1' not found. Please install it."
}
get_installed_version() {
local pkg_name="$1"
if pacman -Q "$pkg_name" &>/dev/null; then
pacman -Q "$pkg_name" | awk '{print $2}'
else
echo "" # Not installed
fi
}
get_pkgbuild_version() {
local pkgbuild_file="$1"
if [ ! -f "$pkgbuild_file" ]; then
error_exit "PKGBUILD file not found at $pkgbuild_file"
fi
(
# shellcheck source=/dev/null
source "$pkgbuild_file"
if [ -z "${pkgver:-}" ] || [ -z "${pkgrel:-}" ]; then
error_exit "pkgver or pkgrel not defined in $pkgbuild_file"
fi
echo "${pkgver}-${pkgrel}"
)
}
# --- Main Script Logic ---
main() {
log "Starting Google Antigravity Installer..."
check_command "git"
check_command "makepkg"
check_command "pacman"
# Create temp dir
TEMP_DIR=$(mktemp -d --suffix=-antigravity-install)
log "Created temporary directory: $TEMP_DIR"
cleanup() {
rm -rf "$TEMP_DIR"
log "Cleanup finished."
}
trap cleanup EXIT
# Clone repo
log "Cloning repository..."
if ! git clone --depth 1 "$GIT_REPO_URL" "$TEMP_DIR/$CLONED_REPO_DIR_NAME"; then
error_exit "Failed to clone repository."
fi
BUILD_DIR="$TEMP_DIR/$CLONED_REPO_DIR_NAME/$PKGBUILD_SUBDIR"
if [ ! -d "$BUILD_DIR" ]; then
error_exit "Build directory not found: $BUILD_DIR"
fi
cd "$BUILD_DIR"
# Check Versions
PKGBUILD_VERSION=$(get_pkgbuild_version "PKGBUILD")
INSTALLED_VERSION=$(get_installed_version "$ANTIGRAVITY_PKG_NAME")
log "Version available in repo: $PKGBUILD_VERSION"
PROCEED_WITH_BUILD=false
if [ -n "$INSTALLED_VERSION" ]; then
log "Currently installed version: $INSTALLED_VERSION"
if [ "$INSTALLED_VERSION" == "$PKGBUILD_VERSION" ]; then
printf "%s version %s is already installed and up-to-date. Reinstall anyway? (y/N): " "$ANTIGRAVITY_PKG_NAME" "$PKGBUILD_VERSION" >&2
read -r reinstall_choice </dev/tty
if [[ "$reinstall_choice" =~ ^[Yy]$ ]]; then
PROCEED_WITH_BUILD=true
else
log "Exiting without reinstallation."
fi
else
# Version differs (upgrade or downgrade)
printf "Do you want to build and install version %s? (Y/n): " "$PKGBUILD_VERSION" >&2
read -r upgrade_choice </dev/tty
if [[ ! "$upgrade_choice" =~ ^[Nn]$ ]]; then # Default to Yes
PROCEED_WITH_BUILD=true
else
log "Exiting without building new version."
fi
fi
else
log "$ANTIGRAVITY_PKG_NAME is not currently installed."
printf "Install %s version %s? (Y/n): " "$ANTIGRAVITY_PKG_NAME" "$PKGBUILD_VERSION" >&2
read -r install_new_choice </dev/tty
if [[ ! "$install_new_choice" =~ ^[Nn]$ ]]; then # Default to Yes
PROCEED_WITH_BUILD=true
else
log "Exiting without installation."
fi
fi
if [ "$PROCEED_WITH_BUILD" = false ]; then
exit 0
fi
log "Building and installing package..."
# Using --noconfirm for automated build phases, but pacman might still ask for sudo password via tty
if ! makepkg -si --noconfirm --needed </dev/tty; then
error_exit "Installation failed."
fi
log "Installation successful!"
}
main