From f52034c54554edf4d694f182cbf42936274470e1 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 26 Sep 2023 17:39:05 +0200 Subject: [PATCH] v1.11.1.1411 --- CHANGELOG.md | 5 +++++ deps.bat | 12 +++++++++--- deps.clj | 12 +++++++++--- resources/DEPS_CLJ_VERSION | 2 +- src/borkdude/deps.clj | 12 +++++++++--- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d712097..2658631 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ DEPS_CLJ_TOOLS_VERSION=1.11.1.1165 bb clojure [deps.clj](https://github.com/borkdude/deps.clj): a faithful port of the clojure CLI bash script to Clojure +## 1.11.1.1411 + +- Catch up with CLI `1.11.1.1411` +- [#113](https://github.com/borkdude/deps.clj/issues/113): Fix bug in SHA comparison of downloaded tools jar with leading zeroes + ## 1.11.1.1403 - Verify downloaded zip file with .sha256 file diff --git a/deps.bat b/deps.bat index 4b99d2d..d6358ef 100644 --- a/deps.bat +++ b/deps.bat @@ -24,7 +24,7 @@ ;; see https://github.com/clojure/brew-install/blob/1.11.1/CHANGELOG.md (def ^:private version (delay (or (System/getenv "DEPS_CLJ_TOOLS_VERSION") - "1.11.1.1403"))) + "1.11.1.1413"))) (def ^:private cache-version "4") @@ -537,6 +537,9 @@ public class ClojureToolsDownloader { Should return `true` if the download was successful, or false if not." nil) +(defn- left-pad-zeroes [s n] + (str (str/join (repeat (- n (count s)) 0)) s)) + (defn clojure-tools-install! "Installs clojure tools archive by downloading it in `:out-dir`, if not already there, and extracting in-place. @@ -582,12 +585,15 @@ public class ClojureToolsDownloader { (*exit-fn* {:exit ct-error-exit-code :message (str "Expected sha256 file to be downloaded to: " sha256-file)})))) (when (.exists sha256-file) - (let [sha (str/trim (slurp sha256-file)) + (let [sha (-> (slurp sha256-file) + str/trim + (left-pad-zeroes 64)) bytes (Files/readAllBytes (.toPath zip-file)) hash (-> (java.security.MessageDigest/getInstance "SHA-256") (.digest bytes)) hash (-> (new BigInteger 1 hash) - (.toString 16))] + (.toString 16)) + hash (left-pad-zeroes hash 64)] (if-not (= sha hash) (*exit-fn* {:exit ct-error-exit-code :message (str "Error: sha256 of zip and expected sha256 do not match: " diff --git a/deps.clj b/deps.clj index 5140431..5801eed 100755 --- a/deps.clj +++ b/deps.clj @@ -19,7 +19,7 @@ ;; see https://github.com/clojure/brew-install/blob/1.11.1/CHANGELOG.md (def ^:private version (delay (or (System/getenv "DEPS_CLJ_TOOLS_VERSION") - "1.11.1.1403"))) + "1.11.1.1413"))) (def ^:private cache-version "4") @@ -532,6 +532,9 @@ public class ClojureToolsDownloader { Should return `true` if the download was successful, or false if not." nil) +(defn- left-pad-zeroes [s n] + (str (str/join (repeat (- n (count s)) 0)) s)) + (defn clojure-tools-install! "Installs clojure tools archive by downloading it in `:out-dir`, if not already there, and extracting in-place. @@ -577,12 +580,15 @@ public class ClojureToolsDownloader { (*exit-fn* {:exit ct-error-exit-code :message (str "Expected sha256 file to be downloaded to: " sha256-file)})))) (when (.exists sha256-file) - (let [sha (str/trim (slurp sha256-file)) + (let [sha (-> (slurp sha256-file) + str/trim + (left-pad-zeroes 64)) bytes (Files/readAllBytes (.toPath zip-file)) hash (-> (java.security.MessageDigest/getInstance "SHA-256") (.digest bytes)) hash (-> (new BigInteger 1 hash) - (.toString 16))] + (.toString 16)) + hash (left-pad-zeroes hash 64)] (if-not (= sha hash) (*exit-fn* {:exit ct-error-exit-code :message (str "Error: sha256 of zip and expected sha256 do not match: " diff --git a/resources/DEPS_CLJ_VERSION b/resources/DEPS_CLJ_VERSION index 5bbb167..c17f569 100644 --- a/resources/DEPS_CLJ_VERSION +++ b/resources/DEPS_CLJ_VERSION @@ -1 +1 @@ -1.11.1.1404-SNAPSHOT \ No newline at end of file +1.11.1.1411 \ No newline at end of file diff --git a/src/borkdude/deps.clj b/src/borkdude/deps.clj index 2040e90..8164fb0 100755 --- a/src/borkdude/deps.clj +++ b/src/borkdude/deps.clj @@ -16,7 +16,7 @@ ;; see https://github.com/clojure/brew-install/blob/1.11.1/CHANGELOG.md (def ^:private version (delay (or (System/getenv "DEPS_CLJ_TOOLS_VERSION") - "1.11.1.1403"))) + "1.11.1.1413"))) (def ^:private cache-version "4") @@ -529,6 +529,9 @@ public class ClojureToolsDownloader { Should return `true` if the download was successful, or false if not." nil) +(defn- left-pad-zeroes [s n] + (str (str/join (repeat (- n (count s)) 0)) s)) + (defn clojure-tools-install! "Installs clojure tools archive by downloading it in `:out-dir`, if not already there, and extracting in-place. @@ -574,12 +577,15 @@ public class ClojureToolsDownloader { (*exit-fn* {:exit ct-error-exit-code :message (str "Expected sha256 file to be downloaded to: " sha256-file)})))) (when (.exists sha256-file) - (let [sha (str/trim (slurp sha256-file)) + (let [sha (-> (slurp sha256-file) + str/trim + (left-pad-zeroes 64)) bytes (Files/readAllBytes (.toPath zip-file)) hash (-> (java.security.MessageDigest/getInstance "SHA-256") (.digest bytes)) hash (-> (new BigInteger 1 hash) - (.toString 16))] + (.toString 16)) + hash (left-pad-zeroes hash 64)] (if-not (= sha hash) (*exit-fn* {:exit ct-error-exit-code :message (str "Error: sha256 of zip and expected sha256 do not match: "