Skip to content
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

Windows-specific tree_hash issue #2

Merged
merged 3 commits into from
Feb 8, 2024
Merged
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
17 changes: 16 additions & 1 deletion src/code_stripping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function _generate_stripped_bundle(;
run(`$gitcmd init`)
run(`$gitcmd config user.name "PackageBundler"`)
run(`$gitcmd config user.email ""`)
run(`$gitcmd config core.autocrlf false`)
end

# Ensure that the versions are sorted first before committing,
Expand All @@ -69,7 +70,21 @@ function _generate_stripped_bundle(;
run(Cmd([gitcmd, "commit", "-m", msg]))
run(Cmd([gitcmd, "tag", "-a", "v$version", "-m", msg]))

pkg_info["git-tree-sha1"] = bytes2hex(Pkg.GitTools.tree_hash(temp_dir))
# Interestingly, using `tree_hash` failed on Windows with a
# `git object <commit> could not be found` error when attempting to
# clone the stripped packages. It would appear that the tree hash
# doesn't match what it should be on that platform, whereas it works
# correctly on macOS and Linux, both locally and on GitHub runners.
#
# ```
# sha = bytes2hex(Pkg.GitTools.tree_hash(temp_dir))
# ```
#
# To get around this we use the `rev-parse` and `^{tree}` to get the
# "real" tree hash.
rev = readchomp(`$gitcmd rev-parse HEAD`)
sha = readchomp(Cmd([gitcmd, "rev-parse", "$rev^{tree}"]))
pkg_info["git-tree-sha1"] = sha
end
run(`$gitcmd log`)
end
Expand Down
6 changes: 3 additions & 3 deletions src/openssl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function keypair(dir::AbstractString = pwd())

@info "Generating key pair for signing stripped packages." dir
dir = abspath(dir)
openssl = OpenSSL_jll.openssl
openssl = OpenSSL_jll.openssl()
cmd = Cmd(["genrsa", "-out", private, "4096"])
run(`$openssl $cmd`)
cmd = Cmd(["rsa", "-in", private, "-pubout"])
Expand All @@ -27,7 +27,7 @@ function keypair(dir::AbstractString = pwd())
end

function _sign_file(file, private_key)
openssl = OpenSSL_jll.openssl
openssl = OpenSSL_jll.openssl()
cmd = Cmd([
"dgst",
"-sign",
Expand All @@ -44,7 +44,7 @@ function _sign_file(file, private_key)
end

function _verify_file(file, public_key)
openssl = OpenSSL_jll.openssl
openssl = OpenSSL_jll.openssl()
cmd = Cmd([
"dgst",
"-verify",
Expand Down
Loading