Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Configure the Go proxy before Linux toolchain verification

Daniel67f7871bd393
diff --git a/docs/RELEASE-VERIFICATION.zh-CN.md b/docs/RELEASE-VERIFICATION.zh-CN.md
index 5b2d910cfb..d527492a6e 100644
--- a/docs/RELEASE-VERIFICATION.zh-CN.md
+++ b/docs/RELEASE-VERIFICATION.zh-CN.md
@@ -132,7 +132,7 @@ python -X utf8 scripts/build-release.py --appx --execute
各平台安装包按 Windows、Linux、Android、鸿蒙的顺序构建。选择 Windows 时,先准备 Windows 资源,再同时编译 AMD64、ARM64 和同时选中的 Android 内核,默认最多三个任务并行。AMD64 内核完成并验证后立即开始打包,无需等待 Android;ARM64 内核就绪且 AMD64 打包完成后,再打包 ARM64。Windows 安装包及签名始终串行,Android 编译可在其间继续运行,Android 阶段复用本次已编译的 AAR。可传入 `--kernel-jobs 2` 限制为两个任务,或用 `--kernel-jobs 1` 恢复这部分串行编译。
-Linux 前端仅构建一次,AMD64、ARM64 内核并行编译,各自使用独立输出目录;Electron 安装包仍串行生成。同时选择 Linux 和鸿蒙时,Linux 安装包生成期间并行编译鸿蒙 ARM64 内核,Linux 阶段等待该编译完成,鸿蒙阶段验证并复用本次内核和头文件后打包。仅选择鸿蒙时仍在鸿蒙阶段编译内核。编译失败会阻止后续阶段;中断时回收后台编译进程。
+Linux 在首次调用 Go 前配置下载镜像,并在前端构建前检查所需工具链;工具链下载仍保留校验,网络或校验失败时提前退出。Linux 前端仅构建一次,AMD64、ARM64 内核并行编译,各自使用独立输出目录;Electron 安装包仍串行生成。同时选择 Linux 和鸿蒙时,Linux 安装包生成期间并行编译鸿蒙 ARM64 内核,Linux 阶段等待该编译完成,鸿蒙阶段验证并复用本次内核和头文件后打包。仅选择鸿蒙时仍在鸿蒙阶段编译内核。编译失败会阻止后续阶段;中断时回收后台编译进程。
并行编译日志分别保存在本次临时构建目录的 `kernel-logs/` 中,主日志记录任务启动、结束和失败。编译、打包失败或按 Ctrl+C 时,停止队列并回收仍在运行的编译进程;未开始的任务不再执行。Windows 资源准备阶段仅记录资源生成,各架构安装包阶段可与剩余内核编译重叠。
diff --git a/scripts/linux-build.sh b/scripts/linux-build.sh
index 62ff98f299..ae04fab05f 100755
--- a/scripts/linux-build.sh
+++ b/scripts/linux-build.sh
@@ -51,6 +51,14 @@ while [[ $# -gt 0 ]]; do
esac
done
+export GO111MODULE=on
+export GOPROXY=https://mirrors.aliyun.com/goproxy/,https://goproxy.cn,direct
+# Toolchain selection can download and authenticate a toolchain even for
+# `go version`. Configure its proxy before the first Go invocation, and fail
+# before spending time building frontend resources. Keep checksum validation.
+echo 'Checking Go toolchain'
+(cd "$PROJECT_ROOT/kernel"; go version)
+
echo 'Checking OCR worker toolchains (glibc)'
# Each compiler runs in its own process group so failures and interrupts also
# stop its compiler/linker children before packaging can start.
@@ -118,9 +126,6 @@ pnpm run build
echo
echo 'Building Kernel'
cd "$PROJECT_ROOT/kernel"
-go version
-export GO111MODULE=on
-export GOPROXY=https://mirrors.aliyun.com/goproxy/,https://goproxy.cn,direct
export CGO_ENABLED=1
export GOOS=linux
diff --git a/scripts/test_linux_release.py b/scripts/test_linux_release.py
index 6acf6e4e8c..f0b9222efe 100644
--- a/scripts/test_linux_release.py
+++ b/scripts/test_linux_release.py
@@ -24,7 +24,12 @@ class LinuxReleaseTests(unittest.TestCase):
path.write_text('#!/bin/bash\nset -e\n' + text)
path.chmod(0o755)
executable(root / 'bin/go', '''
-[[ "$1" == version ]] && exit 0
+if [[ "$1" == version ]]; then
+ [[ "$GOPROXY" == https://mirrors.aliyun.com/goproxy/,https://goproxy.cn,direct ]] || exit 7
+ [[ "$GOSUMDB" != off ]] || exit 8
+ echo toolchain-ready >> "$EVENTS"
+ exit 0
+fi
echo "$GOARCH-start" >> "$EVENTS"
sleep 0.3
if [[ "$FAIL_ARCH" == "$GOARCH" ]]; then exit 9; fi
@@ -53,6 +58,7 @@ echo harmony-end >> "$EVENTS"
def test_kernels_overlap_and_harmony_overlaps_packaging(self):
result, events = self.run_build()
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
+ self.assertEqual(events[0], 'toolchain-ready')
self.assertLess(max(events.index('amd64-start'), events.index('arm64-start')),
min(events.index('amd64-end'), events.index('arm64-end')))
self.assertLess(events.index('harmony-start'), events.index('package-end'))