Skip to content

Fallback to using GitHub releases of libsodium if the download site is unavailable #3494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions project/deps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ def buildCsVersion = Deps.Versions.coursierCli
def buildCsM1Version = Deps.Versions.coursierM1Cli

// Native library used to encrypt GitHub secrets
def libsodiumVersion = "1.0.18"
def libsodiumVersion = "1.0.20"
// Using the libsodium static library from this Alpine version (in the static launcher)
def alpineVersion = "3.15"
def alpineVersion = "3.21"

object Docker {
def customMuslBuilderImageName = "scala-cli-base-musl"
Expand Down
29 changes: 23 additions & 6 deletions project/settings.sc
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,29 @@ trait CliLaunchers extends SbtModule { self =>
os.copy.over(libPath, destDir / s"${prefix}sodiumjni.$ext")
}
private def copyLibsodiumStaticTo(cs: String, destDir: os.Path): Unit = {
val dirRes = os.proc(
cs,
"get",
"--archive",
"https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip"
).call()
val dirRes = {
val stable = os.proc(
cs,
"get",
"--archive",
s"https://download.libsodium.org/libsodium/releases/libsodium-$libsodiumVersion-stable-msvc.zip"
).call(check = false)
if (stable.exitCode == 0) stable
else {
System.err.println(
s"Failed to download stable libsodium $libsodiumVersion from https://download.libsodium.org/libsodium/releases"
)
System.err.println(
"falling back to https://github.com/jedisct1/libsodium/releases *-RELEASE"
)
os.proc( // fallback to GitHuB *-RELEASE version
cs,
"get",
"--archive",
s"https://github.com/jedisct1/libsodium/releases/download/$libsodiumVersion-RELEASE/libsodium-$libsodiumVersion-msvc.zip"
).call()
}
}
val dir = os.Path(dirRes.out.trim(), os.pwd)
os.copy.over(
dir / "libsodium" / "x64" / "Release" / "v143" / "static" / "libsodium.lib",
Expand Down
Loading