Make koch friendlier to offline environments (#24713)

(cherry picked from commit d94e535145)
This commit is contained in:
Ryan McConnell
2025-02-25 11:10:30 -05:00
committed by narimiran
parent fc587256c3
commit 3a9c88239b
2 changed files with 10 additions and 6 deletions

View File

@@ -171,7 +171,7 @@ proc bundleAtlasExe(latest: bool, args: string) =
cloneDependency(distDir, "https://github.com/nim-lang/atlas.git",
commit = commit, allowBundled = true)
cloneDependency(distDir / "atlas" / distDir, "https://github.com/nim-lang/sat.git",
commit = SatStableCommit, allowBundled = true)
commit = SatStableCommit, allowBundled = true)
# installer.ini expects it under $nim/bin
nimCompile("dist/atlas/src/atlas.nim",
options = "-d:release --noNimblePath -d:nimAtlasBootstrap " & args)

View File

@@ -4,10 +4,12 @@ import std/private/gitutils
when defined(nimPreviewSlimSystem):
import std/assertions
proc exec(cmd: string) =
proc tryexec(cmd: string): int =
echo "deps.cmd: " & cmd
let status = execShellCmd(cmd)
doAssert status == 0, cmd
execShellCmd(cmd)
proc exec(cmd: string) =
doAssert tryexec(cmd) == 0, cmd
proc execRetry(cmd: string) =
let ok = retryCall(call = block:
@@ -34,8 +36,10 @@ proc cloneDependency*(destDirBase: string, url: string, commit = commitHead,
let oldDir = getCurrentDir()
setCurrentDir(destDir)
try:
execRetry "git fetch -q"
exec fmt"git checkout -q {commit}"
let checkoutCmd = fmt"git checkout -q {commit}"
if tryexec(checkoutCmd) != 0:
execRetry "git fetch -q"
exec checkoutCmd
finally:
setCurrentDir(oldDir)
elif allowBundled: