Skip to content

Commit bef7411

Browse files
committed
feat(install): add OPENSHELL_INSTALL_METHOD options
As @drew suggested, add `deb`, `rpm`, `snap`, and `homebrew` as installation methods which the user can specify via `OPENSHELL_INSTALL_METHOD` rather than falling back to detecting the package manager automatically. `homebrew` is not yet supported on Linux, and it is the only supported option on MacOS. Also adds a TODO to implement `install_linux_homebrew` in the future. Signed-off-by: Oliver Calder <oliver.calder@canonical.com> fix(install): remove OPENSHELL_INSTALL_METHOD variable The contract of `install.sh` is to choose the best installation method for the host system. Adding the `OPENSHELL_INSTALL_METHOD` variable breaks that contract, so it is best to remove it. Signed-off-by: Oliver Calder <oliver.calder@canonical.com>
1 parent 4bd8a05 commit bef7411

3 files changed

Lines changed: 76 additions & 19 deletions

File tree

‎docs/about/installation.mdx‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ brew services restart openshell
5656

5757
On distributions that ship with `snapd`, the install script uses the Snap path
5858
described below, unless one of the following is true:
59-
- a native (non-snap) Docker package is present (the `openshell` snap requires the `docker` snap, for now)
59+
6060
- `snapd` is not present
61-
- `OPENSHELL_INSTALL_METHOD=classic` is set in the environment
61+
- a native (non-snap) Docker package is present (the `openshell` snap requires the `docker` snap, until snapd 2.77 is released to the `latest/stable` channel)
6262

6363
On Fedora and RHEL, the install script uses RPM packages. The RPM installs the `openshell` CLI, the `openshell-gateway` daemon, and a systemd user service.
6464

65-
On Debian and Ubuntu, the install script uses a Debian package. The Debian package installs the `openshell` CLI, the `openshell-gateway` daemon, VM sandbox support, and a systemd user service.
65+
On Debian and Ubuntu (where the snap is not applicable), the install script uses a Debian package. The Debian package installs the `openshell` CLI, the `openshell-gateway` daemon, VM sandbox support, and a systemd user service.
6666

6767
Linux packages require glibc 2.28 or newer. The installer checks libc before downloading packages and exits with an error on older glibc versions, Alpine, musl-based distributions, or unknown libc environments.
6868

@@ -188,9 +188,6 @@ Use the `openshell` `.deb` or `.rpm` file when `snapd` is unavailable or when
188188
you already run Docker from a non-snap source. The installer falls back to
189189
these methods on hosts with native Docker.
190190

191-
Set `OPENSHELL_INSTALL_METHOD=classic` to force the classic package on hosts
192-
that also have `snapd` available.
193-
194191
## Kubernetes
195192

196193
Kubernetes deployments use the OpenShell Helm chart. For step-by-step installation, refer to [Kubernetes Setup](/kubernetes/setup). For chart values and packaging details, refer to the [Helm chart README](https://github.com/NVIDIA/OpenShell/blob/main/deploy/helm/openshell/README.md).

‎install.sh‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -477,23 +477,14 @@ detect_platform() {
477477
}
478478

479479
linux_package_method() {
480-
case "${OPENSHELL_INSTALL_METHOD:-}" in
481-
classic)
482-
;;
483-
*)
484-
if has_snapd && ! has_native_docker; then
485-
echo "snap"
486-
return 0
487-
fi
488-
;;
489-
esac
490-
491-
if has_cmd dpkg; then
480+
if has_snapd && ! has_native_docker; then
481+
echo "snap"
482+
elif has_cmd dpkg; then
492483
echo "deb"
493484
elif has_cmd rpm; then
494485
echo "rpm"
495486
else
496-
error "Linux installs require either dpkg or rpm"
487+
error "Linux installs require either snapd, dpkg, or rpm"
497488
fi
498489
}
499490

@@ -974,6 +965,7 @@ install_linux_rpm() {
974965
}
975966

976967
install_linux_snap() {
968+
require_cmd snap
977969
set_linux_target_runtime_dir
978970

979971
# Docker snap must be installed before openshell so that the

‎tasks/scripts/test-install-sh.sh‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,72 @@ assert_glibc_preflight_fails \
100100
"OpenShell Linux packages require glibc >= 2.28; detected musl or unsupported libc." \
101101
setup_ldd_musl
102102

103+
# Package format is detected based on the host environment. Shim the has_*
104+
# helpers so the auto-detect path is deterministic regardless of the host
105+
# running the tests.
106+
assert_package_format_detection() {
107+
local name=$1
108+
local snapd=$2
109+
local native_docker=$3
110+
local dpkg=$4
111+
local rpm=$5
112+
local expected=$6
113+
114+
local result
115+
if ! result="$(
116+
has_snapd() { [ "$snapd" = "1" ]; }
117+
has_native_docker() { [ "$native_docker" = "1" ]; }
118+
has_cmd() {
119+
case "$1" in
120+
dpkg) [ "$dpkg" = "1" ] ;;
121+
rpm) [ "$rpm" = "1" ] ;;
122+
*) return 1 ;;
123+
esac
124+
}
125+
linux_package_method
126+
)" 2>"$err"; then
127+
echo "FAIL: ${name}: call failed" >&2
128+
cat "$err" >&2 || true
129+
exit 1
130+
fi
131+
132+
if [ "$result" != "$expected" ]; then
133+
echo "FAIL: ${name}: expected '${expected}', got '${result}'" >&2
134+
exit 1
135+
fi
136+
}
137+
138+
assert_package_format_detection \
139+
"prefers snap when snapd and no native docker" \
140+
1 0 1 1 "snap"
141+
142+
assert_package_format_detection \
143+
"skips snap when native docker present" \
144+
1 1 1 0 "deb"
145+
146+
assert_package_format_detection \
147+
"skips snap when snapd absent" \
148+
0 0 1 0 "deb"
149+
150+
assert_package_format_detection \
151+
"falls back to rpm when no dpkg" \
152+
0 0 0 1 "rpm"
153+
154+
# Host with no snapd, no dpkg, no rpm must error.
155+
if (
156+
has_snapd() { return 1; }
157+
has_native_docker() { return 1; }
158+
has_cmd() { return 1; }
159+
linux_package_method
160+
) >"$out" 2>"$err"; then
161+
echo "FAIL: host with no package managers should error" >&2
162+
exit 1
163+
fi
164+
165+
if ! grep -Fq "Linux installs require either snapd, dpkg, or rpm" "$err"; then
166+
echo "FAIL: missing no-package-manager error" >&2
167+
cat "$err" >&2 || true
168+
exit 1
169+
fi
170+
103171
echo "install.sh libc preflight tests passed"

0 commit comments

Comments
 (0)