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
([package] (match-artifacts package (:os/arch os)))
([package arch]
(let [artifacts (:pod/artifacts package) (let [artifacts (:pod/artifacts package)
res (filter (fn [{os-name :os/name res (filter (fn [{os-name :os/name
os-arch :os/arch}] os-arch :os/arch}]
(let [os-arch (normalize-arch os-arch)] (let [os-arch (normalize-arch os-arch)]
(and (re-matches (re-pattern os-name) (:os/name os)) (and (re-matches (re-pattern os-name) (:os/name os))
(re-matches (re-pattern os-arch) (re-matches (re-pattern os-arch)
(:os/arch os))))) arch))))
artifacts)] artifacts)]
(when (empty? res) (if (empty? res)
(if (and (= "Mac OS X" (:os/name os))
(= "aarch64" (:os/arch os)))
;; Rosetta2 fallback on Apple M1 machines
(match-artifacts package "x86_64")
(throw (IllegalArgumentException. (format "No executable found for pod %s (%s) and OS %s/%s" (throw (IllegalArgumentException. (format "No executable found for pod %s (%s) and OS %s/%s"
(:pod/name package) (:pod/name package)
(:pod/version package) (:pod/version package)
(:os/name os) (:os/name os)
(:os/arch os))))) (:os/arch os)))))
res)) 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