Add fallback for Apple M1 (#46)

This commit is contained in:
Michiel Borkent 2022-03-23 19:32:47 +01:00 committed by GitHub
parent 842ff34739
commit e075b13bfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,22 +23,28 @@
(binding [*out* *err*]
(apply println strs)))
(defn match-artifacts [package]
(let [artifacts (:pod/artifacts package)
res (filter (fn [{os-name :os/name
os-arch :os/arch}]
(let [os-arch (normalize-arch os-arch)]
(and (re-matches (re-pattern os-name) (:os/name os))
(re-matches (re-pattern os-arch)
(:os/arch os)))))
artifacts)]
(when (empty? res)
(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 match-artifacts
([package] (match-artifacts package (:os/arch os)))
([package arch]
(let [artifacts (:pod/artifacts package)
res (filter (fn [{os-name :os/name
os-arch :os/arch}]
(let [os-arch (normalize-arch os-arch)]
(and (re-matches (re-pattern os-name) (:os/name os))
(re-matches (re-pattern os-arch)
arch))))
artifacts)]
(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"
(:pod/name package)
(:pod/version package)
(:os/name os)
(:os/arch os)))))
res))))
(defn unzip [{:keys [^java.io.File zip-file
^java.io.File destination-dir