-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·178 lines (150 loc) · 5.74 KB
/
install.sh
File metadata and controls
executable file
·178 lines (150 loc) · 5.74 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/bash
# Install Spur — AI-native job scheduler
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/ROCm/spur/main/install.sh | bash
#
# # Install nightly:
# curl -fsSL https://raw.githubusercontent.com/ROCm/spur/main/install.sh | bash -s -- nightly
#
# # Install a specific version:
# curl -fsSL https://raw.githubusercontent.com/ROCm/spur/main/install.sh | bash -s -- v0.1.0
#
# # Install to a custom directory:
# curl -fsSL https://raw.githubusercontent.com/ROCm/spur/main/install.sh | INSTALL_DIR=/opt/spur/bin bash
#
# # Uninstall:
# curl -fsSL https://raw.githubusercontent.com/ROCm/spur/main/install.sh | bash -s -- uninstall
set -euo pipefail
REPO="ROCm/spur"
INSTALL_DIR="${INSTALL_DIR:-${HOME}/.local/bin}"
BINARIES="spur spurctld spurd spurdbd spurrestd"
SYMLINKS="sbatch srun squeue scancel sinfo sacct scontrol"
log() { echo "==> $*"; }
err() { echo "ERROR: $*" >&2; exit 1; }
usage() {
cat <<'EOF'
Spur installer — AI-native job scheduler
USAGE:
install.sh [OPTIONS] [VERSION]
VERSION:
latest Install the latest stable release (default)
nightly Install the latest nightly build
v0.1.0 Install a specific version
uninstall Remove Spur binaries
OPTIONS:
-h, --help Show this help message
-d, --dir DIR Install directory (default: ~/.local/bin)
ENVIRONMENT:
INSTALL_DIR Override install directory (same as --dir)
EXAMPLES:
# Install latest stable
curl -fsSL https://raw.githubusercontent.com/ROCm/spur/main/install.sh | bash
# Install nightly
curl -fsSL https://raw.githubusercontent.com/ROCm/spur/main/install.sh | bash -s -- nightly
# Install to /opt/spur/bin
curl -fsSL https://raw.githubusercontent.com/ROCm/spur/main/install.sh | bash -s -- -d /opt/spur/bin
# Uninstall
curl -fsSL https://raw.githubusercontent.com/ROCm/spur/main/install.sh | bash -s -- uninstall
EOF
exit 0
}
do_uninstall() {
log "Uninstalling Spur from ${INSTALL_DIR}/"
local removed=0
for f in ${BINARIES} ${SYMLINKS}; do
if [ -e "${INSTALL_DIR}/${f}" ]; then
rm -f "${INSTALL_DIR}/${f}"
echo " removed ${f}"
removed=$((removed + 1))
fi
done
if [ "${removed}" -eq 0 ]; then
log "No Spur files found in ${INSTALL_DIR}/"
else
log "Removed ${removed} file(s). Spur has been uninstalled."
fi
exit 0
}
# --- Parse arguments ---
VERSION="latest"
while [ $# -gt 0 ]; do
case "$1" in
-h|--help) usage ;;
-d|--dir) INSTALL_DIR="$2"; shift 2 ;;
uninstall) do_uninstall ;;
*) VERSION="$1"; shift ;;
esac
done
# --- Platform check ---
OS=$(uname -s)
ARCH=$(uname -m)
[ "$OS" = "Linux" ] || err "Spur currently supports Linux only (got ${OS})"
[ "$ARCH" = "x86_64" ] || err "Spur currently supports x86_64 only (got ${ARCH})"
# --- glibc check (binaries built on manylinux_2_28, require glibc >= 2.28) ---
GLIBC_VER=$(ldd --version 2>&1 | head -1 | grep -oE '[0-9]+\.[0-9]+$' || echo "0")
if [ "$(printf '%s\n' "2.28" "${GLIBC_VER}" | sort -V | head -1)" != "2.28" ]; then
err "Spur requires glibc >= 2.28 (found ${GLIBC_VER}). Supported: Ubuntu 20.04+, Debian 10+, RHEL 8+, Fedora 28+"
fi
# --- Resolve version ---
if [ "$VERSION" = "latest" ]; then
log "Fetching latest release..."
VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \
| grep '"tag_name"' | head -1 | cut -d'"' -f4) \
|| err "No releases found. Create one with: gh release create v0.1.0"
fi
log "Installing Spur ${VERSION}"
# --- Download ---
TMPDIR=$(mktemp -d)
trap 'rm -rf "${TMPDIR}"' EXIT
if [ "$VERSION" = "nightly" ]; then
# Nightly tarballs include date+sha in the name — find the .tar.gz asset
TARBALL=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/tags/nightly" \
| grep '"name"' | grep '\.tar\.gz"' | grep -v sha256 | head -1 | cut -d'"' -f4) \
|| err "Could not find nightly release assets"
else
TARBALL="spur-${VERSION}-linux-amd64.tar.gz"
fi
URL="https://github.com/${REPO}/releases/download/${VERSION}/${TARBALL}"
log "Downloading ${TARBALL}..."
curl -fSL -o "${TMPDIR}/${TARBALL}" "${URL}" \
|| err "Download failed. Check that release ${VERSION} exists at https://github.com/${REPO}/releases"
# --- Verify checksum if available ---
SHA_URL="${URL}.sha256"
if curl -fsSL -o "${TMPDIR}/${TARBALL}.sha256" "${SHA_URL}" 2>/dev/null; then
log "Verifying checksum..."
(cd "${TMPDIR}" && sha256sum -c "${TARBALL}.sha256") || err "Checksum mismatch"
fi
# --- Extract ---
log "Extracting..."
tar xzf "${TMPDIR}/${TARBALL}" -C "${TMPDIR}"
# --- Install ---
mkdir -p "${INSTALL_DIR}"
# Find the extracted directory (name varies for nightly)
EXTRACTED=$(find "${TMPDIR}" -maxdepth 1 -type d -name 'spur-*' | head -1)
[ -n "${EXTRACTED}" ] || err "Could not find extracted directory"
cp -f "${EXTRACTED}"/bin/* "${INSTALL_DIR}/"
chmod +x "${INSTALL_DIR}/spur" "${INSTALL_DIR}/spurctld" "${INSTALL_DIR}/spurd" \
"${INSTALL_DIR}/spurdbd" "${INSTALL_DIR}/spurrestd"
# --- Verify ---
if ! "${INSTALL_DIR}/spur" --version >/dev/null 2>&1; then
# Binary exists but --version may not be implemented yet
if [ -x "${INSTALL_DIR}/spur" ]; then
log "Binaries installed (version flag not yet supported)"
else
err "Installation verification failed"
fi
fi
# --- PATH hint ---
log "Installed to ${INSTALL_DIR}/"
log "Binaries: ${BINARIES}"
log "Symlinks: ${SYMLINKS}"
if ! echo "$PATH" | tr ':' '\n' | grep -qx "${INSTALL_DIR}"; then
echo ""
echo "Add to your PATH:"
echo " export PATH=\"${INSTALL_DIR}:\$PATH\""
echo ""
echo "Or add to ~/.bashrc:"
echo " echo 'export PATH=\"${INSTALL_DIR}:\$PATH\"' >> ~/.bashrc"
fi
log "Done."