Get os name & arch at runtime instead of compile
...so we can override them to download pods for other OS / arch platforms
This commit is contained in:
parent
8c70709927
commit
917b854803
1 changed files with 12 additions and 10 deletions
|
|
@ -15,36 +15,38 @@
|
|||
"x86_64"
|
||||
arch))
|
||||
|
||||
(def os {:os/name (or (System/getenv "OS_NAME") (System/getProperty "os.name"))
|
||||
:os/arch (let [arch (or (System/getenv "OS_ARCH")
|
||||
(System/getProperty "os.arch"))]
|
||||
(normalize-arch arch))})
|
||||
(def os
|
||||
(delay
|
||||
{:os/name (or (System/getenv "OS_NAME") (System/getProperty "os.name"))
|
||||
:os/arch (let [arch (or (System/getenv "OS_ARCH")
|
||||
(System/getProperty "os.arch"))]
|
||||
(normalize-arch arch))}))
|
||||
|
||||
(defn warn [& strs]
|
||||
(binding [*out* *err*]
|
||||
(apply println strs)))
|
||||
|
||||
(defn match-artifacts
|
||||
([package] (match-artifacts package (:os/arch os)))
|
||||
([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))
|
||||
(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)))
|
||||
(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)))))
|
||||
(:os/name @os)
|
||||
(:os/arch @os)))))
|
||||
res))))
|
||||
|
||||
(defn unzip [{:keys [^java.io.File zip-file
|
||||
|
|
|
|||
Loading…
Reference in a new issue