From 5ba1105b1e49cc9acb19552dea70ebcc53cd4eaa Mon Sep 17 00:00:00 2001 From: MichaelHatherly Date: Thu, 8 Feb 2024 14:37:18 +0000 Subject: [PATCH 1/3] Set `core.autocrlf false` to try and fix #1 --- src/code_stripping.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/code_stripping.jl b/src/code_stripping.jl index fa1e91e..0791620 100644 --- a/src/code_stripping.jl +++ b/src/code_stripping.jl @@ -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, From 85fd041af2cc33604c5ad156de9b42b341815196 Mon Sep 17 00:00:00 2001 From: MichaelHatherly Date: Thu, 8 Feb 2024 15:47:41 +0000 Subject: [PATCH 2/3] Fix `openssl` issue Interpolation a `Function` results in interpolating the literal name without error unless the user does not have `openssl` on their `PATH`. Call the function instead. --- src/openssl.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openssl.jl b/src/openssl.jl index bad1084..244b1d2 100644 --- a/src/openssl.jl +++ b/src/openssl.jl @@ -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"]) @@ -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", @@ -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", From 9f9ae4a95fa5445cad645cbf78647cafcad1097b Mon Sep 17 00:00:00 2001 From: MichaelHatherly Date: Thu, 8 Feb 2024 17:01:47 +0000 Subject: [PATCH 3/3] Fix Windows-specific tree hash inconsistency `GitTools.tree_hash` was giving what appears to be an incorrect result on Windows. Use `git` directly to get the right hash instead. --- src/code_stripping.jl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/code_stripping.jl b/src/code_stripping.jl index 0791620..42b42b6 100644 --- a/src/code_stripping.jl +++ b/src/code_stripping.jl @@ -70,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 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