Add fallback for Apple M1

This commit is contained in:
Michiel Borkent 2022-03-23 17:28:06 +01:00
parent 842ff34739
commit 8e8a4f854b

View file

@ -23,22 +23,28 @@
(binding [*out* *err*] (binding [*out* *err*]
(apply println strs))) (apply println strs)))
(defn match-artifacts [package] (defn match-artifacts
(let [artifacts (:pod/artifacts package) ([package] (match-artifacts package (:os/arch os)))
res (filter (fn [{os-name :os/name ([package arch]
os-arch :os/arch}] (let [artifacts (:pod/artifacts package)
(let [os-arch (normalize-arch os-arch)] res (filter (fn [{os-name :os/name
(and (re-matches (re-pattern os-name) (:os/name os)) os-arch :os/arch}]
(re-matches (re-pattern os-arch) (let [os-arch (normalize-arch os-arch)]
(:os/arch os))))) (and (re-matches (re-pattern os-name) (:os/name os))
artifacts)] (re-matches (re-pattern os-arch)
(when (empty? res) arch))))
(throw (IllegalArgumentException. (format "No executable found for pod %s (%s) and OS %s/%s" artifacts)]
(:pod/name package) (if (empty? res)
(:pod/version package) (if (and (= "Mac OS X" (:os/name os))
(:os/name os) (= "aarch64" (:os/arch os)))
(:os/arch os))))) ;; Rosetta2 fallback on Apple M1 machines
res)) (match-artifacts package "x86_64")
(throw (IllegalArgumentException. (format "No executable found for pod %s (%s) and OS %s/%s"
(:pod/name package)
(:pod/version package)
(:os/name os)
(:os/arch os)))))
res))))
(defn unzip [{:keys [^java.io.File zip-file (defn unzip [{:keys [^java.io.File zip-file
^java.io.File destination-dir ^java.io.File destination-dir