Skip to content

Commit f553153

Browse files
author
openclaw-installer-sync[bot]
committed
chore: sync installers from openclaw a917c99e92c8
1 parent a56c7d7 commit f553153

3 files changed

Lines changed: 69 additions & 23 deletions

File tree

public/install-cli.sh

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ MIN_NODE_22_VERSION="22.22.3"
7676
MIN_NODE_24_VERSION="24.15.0"
7777
MIN_NODE_25_VERSION="25.9.0"
7878
SUPPORTED_NODE_VERSION_LABEL="Node 22.22.3+, Node 24.15.0+, or Node 25.9.0+"
79+
NODE_RELEASE_VERSION_CORE=""
7980
APK_NODE_BIN_DIR="/usr/bin"
8081
NPM_LOGLEVEL="${OPENCLAW_NPM_LOGLEVEL:-error}"
8182
INSTALL_METHOD="${OPENCLAW_INSTALL_METHOD:-npm}"
@@ -508,10 +509,10 @@ linked_node_is_usable() {
508509

509510
current_version="$("$(node_bin)" -v 2>/dev/null || echo "")"
510511
required_version="$(required_node_version)"
511-
if ! node_version_is_supported "$current_version"; then
512+
if ! node_release_version_is_supported "$current_version"; then
512513
return 1
513514
fi
514-
if ! semver_at_least "$current_version" "$required_version"; then
515+
if ! semver_at_least "$NODE_RELEASE_VERSION_CORE" "$required_version"; then
515516
return 1
516517
fi
517518
candidate_bin="$(node_dir)/bin"
@@ -590,6 +591,32 @@ semver_at_least() {
590591
((version_patch >= required_patch))
591592
}
592593

594+
node_release_version_is_supported() {
595+
local version="$1"
596+
local major minor patch
597+
598+
NODE_RELEASE_VERSION_CORE=""
599+
while [[ "$version" == [[:space:]]* ]]; do version="${version#?}"; done
600+
while [[ "$version" == *[[:space:]] ]]; do version="${version%?}"; done
601+
if [[ ! "$version" =~ ^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
602+
return 1
603+
fi
604+
major="${BASH_REMATCH[1]}"
605+
minor="${BASH_REMATCH[2]}"
606+
patch="${BASH_REMATCH[3]}"
607+
for part in "$major" "$minor" "$patch"; do
608+
if ((${#part} > 16)) || ((${#part} == 16 && 10#$part > 9007199254740991)); then
609+
return 1
610+
fi
611+
done
612+
613+
NODE_RELEASE_VERSION_CORE="${major}.${minor}.${patch}"
614+
node_version_is_supported "$NODE_RELEASE_VERSION_CORE"
615+
}
616+
617+
# Download labels are plain numeric Node distribution versions. Installed
618+
# runtimes use node_release_version_is_supported, which accepts canonical
619+
# release labels with a leading v or build metadata.
593620
node_version_is_supported() {
594621
local version="${1#v}"
595622
local major minor patch

public/install.ps1

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,32 @@ Write-Host "[OK] Windows detected" -ForegroundColor Green
247247
function Test-NodeVersionSupported {
248248
param([string]$Version)
249249

250-
$versionMatch = [regex]::Match($Version, '^v?(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)')
250+
if ([string]::IsNullOrWhiteSpace($Version)) {
251+
return $false
252+
}
253+
# This standalone installer runs before OpenClaw exists on disk. Mirror the
254+
# release grammar in node-version.mjs; parity cases guard this boundary.
255+
$versionMatch = [regex]::Match(
256+
$Version,
257+
'^\s*v?(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?\s*$'
258+
)
251259
if (-not $versionMatch.Success) {
252260
return $false
253261
}
254-
$major = [int]$versionMatch.Groups["major"].Value
255-
$minor = [int]$versionMatch.Groups["minor"].Value
256-
$patch = [int]$versionMatch.Groups["patch"].Value
262+
$major = 0L
263+
$minor = 0L
264+
$patch = 0L
265+
$maxSafeInteger = 9007199254740991L
266+
if (
267+
-not [long]::TryParse($versionMatch.Groups["major"].Value, [ref]$major) -or
268+
-not [long]::TryParse($versionMatch.Groups["minor"].Value, [ref]$minor) -or
269+
-not [long]::TryParse($versionMatch.Groups["patch"].Value, [ref]$patch) -or
270+
$major -gt $maxSafeInteger -or
271+
$minor -gt $maxSafeInteger -or
272+
$patch -gt $maxSafeInteger
273+
) {
274+
return $false
275+
}
257276
if ($major -eq 22) {
258277
return ($minor -gt 22 -or ($minor -eq 22 -and $patch -ge 3))
259278
}

public/install.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,25 +1570,25 @@ parse_node_version_components_for_binary() {
15701570
fi
15711571
local version major minor patch
15721572
version="$("$node_bin" -v 2>/dev/null || true)"
1573-
major="${version#v}"
1574-
major="${major%%.*}"
1575-
minor="${version#v}"
1576-
minor="${minor#*.}"
1577-
minor="${minor%%.*}"
1578-
patch="${version#v}"
1579-
patch="${patch#*.}"
1580-
patch="${patch#*.}"
1581-
patch="${patch%%.*}"
1582-
1583-
if [[ ! "$major" =~ ^[0-9]+$ ]]; then
1584-
return 1
1585-
fi
1586-
if [[ ! "$minor" =~ ^[0-9]+$ ]]; then
1587-
return 1
1588-
fi
1589-
if [[ ! "$patch" =~ ^[0-9]+$ ]]; then
1573+
version="${version#"${version%%[![:space:]]*}"}"
1574+
version="${version%"${version##*[![:space:]]}"}"
1575+
1576+
# This standalone installer runs before OpenClaw exists on disk. Mirror the
1577+
# release grammar in node-version.mjs; parity cases guard this boundary.
1578+
if [[ ! "$version" =~ ^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
15901579
return 1
15911580
fi
1581+
major="${BASH_REMATCH[1]}"
1582+
minor="${BASH_REMATCH[2]}"
1583+
patch="${BASH_REMATCH[3]}"
1584+
1585+
local component
1586+
for component in "$major" "$minor" "$patch"; do
1587+
if ((${#component} > 16)) ||
1588+
((${#component} == 16 && 10#$component > 9007199254740991)); then
1589+
return 1
1590+
fi
1591+
done
15921592
echo "${major} ${minor} ${patch}"
15931593
return 0
15941594
}

0 commit comments

Comments
 (0)