Skip to content

Commit 8072eae

Browse files
committed
feat(homebrew): install dev cask from script
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent 17841b4 commit 8072eae

3 files changed

Lines changed: 74 additions & 7 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ curl -LsSf https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install.sh |
2828

2929
**Homebrew dev cask (macOS Apple Silicon):**
3030

31+
```bash
32+
curl -LsSf https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install-dev.sh | sh
33+
```
34+
35+
Or install the cask directly:
36+
3137
```bash
3238
brew tap nvidia/openshell https://github.com/NVIDIA/OpenShell.git
3339
brew install --cask nvidia/openshell/openshell-dev

architecture/build-containers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ brew install --cask nvidia/openshell/openshell-dev
5252

5353
The archive exposes `openshell`, `openshell-gateway`, and `openshell-driver-vm` through cask `binary` stanzas. The gateway entrypoint is a wrapper that sets `OPENSHELL_DRIVER_DIR` to the bundled driver directory before executing the real gateway binary. The cask signs the VM driver with the Hypervisor entitlement during `postflight`.
5454

55+
`install-dev.sh` installs the same dev cask automatically on macOS Apple Silicon. On Linux amd64 and arm64, it installs the rolling development Debian package.
56+
5557
## Python Wheels
5658

5759
OpenShell also publishes Python wheels for `linux/amd64`, `linux/arm64`, and macOS ARM64.

install-dev.sh

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# Install the OpenShell development build from the rolling GitHub `dev` release.
66
#
77
# This script is intended as a convenient installer for development builds. It
8-
# currently supports Debian packages on Linux amd64 and arm64 only.
8+
# supports Debian packages on Linux amd64/arm64 and the Homebrew dev cask on
9+
# macOS Apple Silicon.
910
#
1011
set -e
1112

@@ -14,6 +15,9 @@ REPO="NVIDIA/OpenShell"
1415
GITHUB_URL="https://github.com/${REPO}"
1516
RELEASE_TAG="dev"
1617
CHECKSUMS_NAME="openshell-checksums-sha256.txt"
18+
HOMEBREW_TAP="nvidia/openshell"
19+
HOMEBREW_TAP_URL="${GITHUB_URL}.git"
20+
HOMEBREW_CASK="${HOMEBREW_TAP}/openshell-dev"
1721

1822
info() {
1923
printf '%s: %s\n' "$APP_NAME" "$*" >&2
@@ -26,7 +30,7 @@ error() {
2630

2731
usage() {
2832
cat <<EOF
29-
install-dev.sh - Install the OpenShell development Debian package
33+
install-dev.sh - Install the OpenShell development build
3034
3135
USAGE:
3236
curl -fsSL https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install-dev.sh -o install-dev.sh
@@ -41,7 +45,8 @@ NOTES:
4145
This installs the rolling development release from:
4246
${GITHUB_URL}/releases/tag/${RELEASE_TAG}
4347
44-
Only Linux amd64 and arm64 Debian packages are supported right now.
48+
Linux amd64 and arm64 install the development Debian package.
49+
macOS Apple Silicon installs the Homebrew dev cask.
4550
EOF
4651
}
4752

@@ -142,6 +147,26 @@ check_platform() {
142147
require_cmd dpkg
143148
}
144149

150+
check_homebrew_platform() {
151+
if [ "$(uname -s)" != "Darwin" ]; then
152+
error "unsupported OS: $(uname -s); Homebrew dev cask requires macOS"
153+
fi
154+
155+
case "$(uname -m)" in
156+
arm64|aarch64)
157+
;;
158+
*)
159+
error "unsupported architecture: $(uname -m); Homebrew dev cask requires Apple Silicon"
160+
;;
161+
esac
162+
163+
if [ "$(id -u)" -eq 0 ]; then
164+
error "Homebrew must not be run as root; rerun this installer as your user"
165+
fi
166+
167+
require_cmd brew
168+
}
169+
145170
get_deb_arch() {
146171
_arch="$(dpkg --print-architecture)"
147172

@@ -228,6 +253,7 @@ remove_local_gateway_registration() {
228253

229254
# The install-dev gateway is a user service. Replace the CLI registration
230255
# directly instead of asking `gateway destroy` to tear down Docker resources.
256+
# shellcheck disable=SC2016
231257
as_target_user sh -c '
232258
config_dir=$1
233259
rm -rf "${config_dir}/gateways/local"
@@ -259,21 +285,54 @@ register_local_gateway() {
259285
esac
260286
}
261287

288+
install_homebrew_cask() {
289+
check_homebrew_platform
290+
291+
info "tapping ${HOMEBREW_TAP}..."
292+
brew tap "${HOMEBREW_TAP}" "${HOMEBREW_TAP_URL}"
293+
294+
if brew list --cask openshell-dev >/dev/null 2>&1; then
295+
info "reinstalling ${HOMEBREW_CASK}..."
296+
brew reinstall --cask "${HOMEBREW_CASK}"
297+
else
298+
info "installing ${HOMEBREW_CASK}..."
299+
brew install --cask "${HOMEBREW_CASK}"
300+
fi
301+
302+
_brew_prefix="$(brew --prefix)"
303+
_openshell_bin="${_brew_prefix}/bin/openshell"
304+
if [ -x "$_openshell_bin" ]; then
305+
_installed_version="$("$_openshell_bin" --version 2>/dev/null || true)"
306+
if [ -n "$_installed_version" ]; then
307+
info "installed ${_installed_version} via Homebrew"
308+
else
309+
info "installed OpenShell development cask via Homebrew"
310+
fi
311+
else
312+
info "installed OpenShell development cask via Homebrew"
313+
fi
314+
}
315+
262316
main() {
263-
while [ "$#" -gt 0 ]; do
264-
case "$1" in
317+
for arg in "$@"; do
318+
case "$arg" in
265319
--help)
266320
usage
267321
exit 0
268322
;;
269323
*)
270-
error "unknown option: $1"
324+
error "unknown option: $arg"
271325
;;
272326
esac
273-
shift
274327
done
275328

276329
require_cmd curl
330+
331+
if [ "$(uname -s)" = "Darwin" ]; then
332+
install_homebrew_cask
333+
return 0
334+
fi
335+
277336
check_platform
278337

279338
TARGET_USER="$(target_user)"

0 commit comments

Comments
 (0)