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#
1011set -e
1112
@@ -14,6 +15,9 @@ REPO="NVIDIA/OpenShell"
1415GITHUB_URL=" https://github.com/${REPO} "
1516RELEASE_TAG=" dev"
1617CHECKSUMS_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
1822info () {
1923 printf ' %s: %s\n' " $APP_NAME " " $* " >&2
@@ -26,7 +30,7 @@ error() {
2630
2731usage () {
2832 cat << EOF
29- install-dev.sh - Install the OpenShell development Debian package
33+ install-dev.sh - Install the OpenShell development build
3034
3135USAGE:
3236 curl -fsSL https://raw.githubusercontent.com/NVIDIA/OpenShell/main/install-dev.sh -o install-dev.sh
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.
4550EOF
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+
145170get_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+
262316main () {
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