























@@ -53,9 +53,9 @@ import {
53535454// Older published baselines predate this warning, but still need update coverage.
5555const BAD_PLUGIN_DIAGNOSTIC_MIN_VERSION = "2026.5.7";
56-// Restored Ubuntu snapshots may immediately run unattended-upgrades. Let that
57-// legitimate maintenance finish instead of racing or disabling the OS service.
58-const APT_LOCK_TIMEOUT_SECONDS = 900;
56+// Restored Ubuntu snapshots may immediately run package maintenance for hours.
57+// Reuse an existing downloader before touching apt, then bound the fallback.
58+const APT_LOCK_RETRY_SECONDS = 900;
5959const BOOTSTRAP_TIMEOUT_SECONDS = 1200;
60606161function parseOpenClawPackageVersion(value: string): string | null {
@@ -445,27 +445,44 @@ printf 'preflight.npmRoot=%s\n' "$(npm root -g 2>/dev/null || true)"`);
445445this.guestExec(["hwclock", "--systohc"], { check: false });
446446this.guestExec(["timedatectl", "set-ntp", "true"], { check: false });
447447this.guestExec(["systemctl", "restart", "systemd-timesyncd"], { check: false });
448-this.guestExec([
449-"apt-get",
450-"-o",
451-"Acquire::Check-Date=false",
452-"-o",
453-`DPkg::Lock::Timeout=${APT_LOCK_TIMEOUT_SECONDS}`,
454-"update",
455-]);
456-this.guestExec([
457-"apt-get",
458-"-o",
459-`DPkg::Lock::Timeout=${APT_LOCK_TIMEOUT_SECONDS}`,
460-"install",
461-"-y",
462-"curl",
463-"ca-certificates",
464-]);
448+this.guest.bash(`
449+set -e
450+if command -v curl >/dev/null 2>&1 || command -v wget >/dev/null 2>&1; then
451+ exit 0
452+fi
453+deadline=$((SECONDS + ${APT_LOCK_RETRY_SECONDS}))
454+run_apt_with_lock_retry() {
455+ local output status
456+ while true; do
457+ if output="$("$@" 2>&1)"; then
458+ status=0
459+ else
460+ status=$?
461+ fi
462+ printf '%s\n' "$output"
463+ if [ "$status" -eq 0 ]; then
464+ return 0
465+ fi
466+ case "$output" in
467+ *"Could not get lock"*|*"Unable to acquire the dpkg frontend lock"*|*"Unable to lock directory"*)
468+ if [ "$SECONDS" -ge "$deadline" ]; then
469+ printf 'Timed out waiting for Ubuntu package maintenance locks\n' >&2
470+ return "$status"
471+ fi
472+ sleep 5
473+ ;;
474+ *)
475+ return "$status"
476+ ;;
477+ esac
478+ done
479+}
480+run_apt_with_lock_retry apt-get -o Acquire::Check-Date=false -o DPkg::Lock::Timeout=30 update
481+run_apt_with_lock_retry apt-get -o DPkg::Lock::Timeout=30 install -y curl ca-certificates`);
465482}
466483467484private installLatestRelease(): void {
468-this.guestExec(["curl", "-fsSL", this.options.installUrl, "-o", "/tmp/openclaw-install.sh"]);
485+this.downloadGuestFile(this.options.installUrl, "/tmp/openclaw-install.sh");
469486if (this.options.installVersion) {
470487this.guestExec([
471488"/usr/bin/env",
@@ -488,12 +505,22 @@ printf 'preflight.npmRoot=%s\n' "$(npm root -g 2>/dev/null || true)"`);
488505this.guestExec(["openclaw", "--version"]);
489506}
490507508+private downloadGuestFile(url: string, outputPath: string): void {
509+this.guest.bash(`
510+set -e
511+if command -v curl >/dev/null 2>&1; then
512+ curl -fsSL ${shellQuote(url)} -o ${shellQuote(outputPath)}
513+else
514+ wget -q -O ${shellQuote(outputPath)} ${shellQuote(url)}
515+fi`);
516+}
517+491518private installMainTgz(tempName: string): void {
492519if (!this.artifact || !this.server) {
493520die("package artifact/server missing");
494521}
495522const tgzUrl = this.server.urlFor(this.artifact.path);
496-this.guestExec(["curl", "-fsSL", tgzUrl, "-o", `/tmp/${tempName}`]);
523+this.downloadGuestFile(tgzUrl, `/tmp/${tempName}`);
497524this.guestExec(["npm", "install", "-g", `/tmp/${tempName}`, "--no-fund", "--no-audit"]);
498525this.guestExec(["openclaw", "--version"]);
499526}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。