diff options
Diffstat (limited to 'stdlib/source/program/aedifex')
-rw-r--r-- | stdlib/source/program/aedifex/artifact/extension.lux | 2 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/artifact/type.lux | 2 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/command/deploy.lux | 2 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/dependency/resolution.lux | 31 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/hash.lux | 10 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/local.lux | 58 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/package.lux | 36 |
7 files changed, 89 insertions, 52 deletions
diff --git a/stdlib/source/program/aedifex/artifact/extension.lux b/stdlib/source/program/aedifex/artifact/extension.lux index 412bf699a..78939260a 100644 --- a/stdlib/source/program/aedifex/artifact/extension.lux +++ b/stdlib/source/program/aedifex/artifact/extension.lux @@ -26,6 +26,6 @@ [lux-library] [jvm-library] [pom] - [sha1] + [sha-1] [md5] ) diff --git a/stdlib/source/program/aedifex/artifact/type.lux b/stdlib/source/program/aedifex/artifact/type.lux index 35035ebc4..5e5772ea2 100644 --- a/stdlib/source/program/aedifex/artifact/type.lux +++ b/stdlib/source/program/aedifex/artifact/type.lux @@ -13,6 +13,6 @@ ["tar" lux-library] ["jar" jvm-library] ["pom" pom] - ["sha1" sha1] + ["sha1" sha-1] ["md5" md5] ) diff --git a/stdlib/source/program/aedifex/command/deploy.lux b/stdlib/source/program/aedifex/command/deploy.lux index 25b1a15aa..3041c53f1 100644 --- a/stdlib/source/program/aedifex/command/deploy.lux +++ b/stdlib/source/program/aedifex/command/deploy.lux @@ -70,6 +70,6 @@ pom (promise@wrap (///pom.write profile)) _ (deploy! ///artifact/type.pom (|> pom (:: xml.codec encode) encoding.to-utf8)) _ (deploy! ///artifact/type.lux-library library) - _ (deploy! ///artifact/type.sha1 (///hash.data (///hash.sha1 library))) + _ (deploy! ///artifact/type.sha-1 (///hash.data (///hash.sha-1 library))) _ (deploy! ///artifact/type.md5 (///hash.data (///hash.md5 library)))] (wrap []))))) diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index 46d32a4f7..7e48610e3 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -33,6 +33,7 @@ ["/" profile] ["#." hash] ["#." pom] + ["#." package (#+ Package)] ["#." artifact ["#/." extension]]]]) @@ -85,23 +86,16 @@ ["Type" (%.text type)] ["Hash" (%.text hash)])))] - [sha1-does-not-match] + [sha-1-does-not-match] [md5-does-not-match] ) -(type: #export Package - {#library Binary - #pom XML - #dependencies (List Dependency) - #sha1 Text - #md5 Text}) - (def: (verified-hash dependency library url hash codec exception) (All [h] (-> Dependency Binary URL (-> Binary (///hash.Hash h)) (Codec Text (///hash.Hash h)) (Exception [Dependency Text]) - (IO (Try Text)))) + (IO (Try (///hash.Hash h))))) (do (try.with io.monad) [#let [expected (hash library)] actual (..download url)] @@ -111,7 +105,7 @@ actual (:: codec decode output) _ (exception.assert exception [dependency output] (:: ///hash.equivalence = expected actual))] - (wrap output))))) + (wrap actual))))) (def: #export (resolve repository dependency) (-> Repository Dependency (IO (Try Package))) @@ -119,7 +113,7 @@ prefix (format repository uri.separator (///artifact.uri artifact))] (do (try.with io.monad) [library (..download (format prefix (///artifact/extension.extension type))) - sha1 (..verified-hash dependency library (format prefix ///artifact/extension.sha1) ///hash.sha1 ///hash.sha1-codec ..sha1-does-not-match) + sha-1 (..verified-hash dependency library (format prefix ///artifact/extension.sha-1) ///hash.sha-1 ///hash.sha-1-codec ..sha-1-does-not-match) md5 (..verified-hash dependency library (format prefix ///artifact/extension.md5) ///hash.md5 ///hash.md5-codec ..md5-does-not-match) pom (..download (format prefix ///artifact/extension.pom))] (:: io.monad wrap @@ -127,11 +121,10 @@ [pom (encoding.from-utf8 pom) pom (:: xml.codec decode pom) profile (<xml>.run ///pom.parser pom)] - (wrap {#library library - #pom pom - #dependencies (set.to-list (get@ #/.dependencies profile)) - #sha1 sha1 - #md5 md5})))))) + (wrap {#///package.library library + #///package.pom pom + #///package.sha-1 sha-1 + #///package.md5 md5})))))) (type: #export Resolution (Dictionary Dependency Package)) @@ -179,6 +172,8 @@ #.None (..resolve-any repositories head)) - #let [resolution (dictionary.put head package resolution)] - resolution (resolve-all repositories (get@ #dependencies package) resolution)] + sub-dependencies (:: io.monad wrap (///package.dependencies package)) + resolution (|> resolution + (dictionary.put head package) + (resolve-all repositories (set.to-list sub-dependencies)))] (resolve-all repositories tail resolution)))) diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index 2f63d0edd..e5e4e020f 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -45,7 +45,7 @@ (java/security/MessageDigest::digest [value]) :abstraction))] - [sha1 ..SHA-1 "SHA-1"] + [sha-1 ..SHA-1 "SHA-1"] [md5 ..MD5 "MD5"] ) @@ -64,7 +64,7 @@ Nat <factor>)] - [20 sha1::size] + [20 sha-1::size] [16 md5::size] ) @@ -87,7 +87,7 @@ ["Expected size" (%.nat <size>)] ["Actual size" (%.nat (binary.size data))]))] - [not-a-sha1 ..sha1::size] + [not-a-sha-1 ..sha-1::size] [not-a-md5 ..md5::size] ) @@ -98,7 +98,7 @@ (#try.Success (:abstraction data)) (exception.throw <exception> [data])))] - [as-sha1 SHA-1 ..sha1::size ..not-a-sha1] + [as-sha-1 SHA-1 ..sha-1::size ..not-a-sha-1] [as-md5 MD5 ..md5::size ..not-a-md5] ) @@ -149,7 +149,7 @@ (def: encode (|>> :representation ..encode)) (def: decode (..decode <nat> <constructor>)))] - [sha1-codec SHA-1 ..sha1::size ..as-sha1] + [sha-1-codec SHA-1 ..sha-1::size ..as-sha-1] [md5-codec MD5 ..md5::size ..as-md5] ) diff --git a/stdlib/source/program/aedifex/local.lux b/stdlib/source/program/aedifex/local.lux index 3c06f0222..dc769bcc1 100644 --- a/stdlib/source/program/aedifex/local.lux +++ b/stdlib/source/program/aedifex/local.lux @@ -34,11 +34,12 @@ ["/" profile (#+ Profile)] ["#." pom] ["#." hash] + ["#." package (#+ Package)] ["#." artifact (#+ Artifact) ["#/." type] ["#/." extension]] ["#." dependency (#+ Dependency) - ["#/." resolution (#+ Package Resolution)]]]) + ["#/." resolution (#+ Resolution)]]]) (def: #export (repository system) (All [a] (-> (file.System a) Path)) @@ -67,16 +68,22 @@ directory (: (Promise (Try (Directory Promise))) (file.get-directory promise.monad system directory)) _ (..save! system - (get@ #//dependency/resolution.library package) + (get@ #//package.library package) (format prefix (//artifact/extension.extension type))) _ (..save! system - (encoding.to-utf8 (get@ #//dependency/resolution.sha1 package)) - (format prefix //artifact/extension.sha1)) + (|> package + (get@ #//package.sha-1) + (:: //hash.sha-1-codec encode) + encoding.to-utf8) + (format prefix //artifact/extension.sha-1)) _ (..save! system - (encoding.to-utf8 (get@ #//dependency/resolution.md5 package)) + (|> package + (get@ #//package.md5) + (:: //hash.md5-codec encode) + encoding.to-utf8) (format prefix //artifact/extension.md5)) _ (..save! system - (|> package (get@ #//dependency/resolution.pom) (:: xml.codec encode) encoding.to-utf8) + (|> package (get@ #//package.pom) (:: xml.codec encode) encoding.to-utf8) (format prefix //artifact/extension.pom))] (wrap []))) @@ -102,24 +109,19 @@ (file.make-directories promise.monad system (..path system artifact))) #let [prefix (format directory (:: system separator) (//artifact.identity artifact))] pom (..read! system (format prefix //artifact/extension.pom)) - [pom dependencies] (:: promise.monad wrap - (do try.monad - [pom (encoding.from-utf8 pom) - pom (:: xml.codec decode pom) - profile (<xml>.run //pom.parser pom)] - (wrap [pom (get@ #/.dependencies profile)]))) library (..read! system (format prefix (//artifact/extension.extension type))) - sha1 (..read! system (format prefix //artifact/extension.sha1)) + sha-1 (..read! system (format prefix //artifact/extension.sha-1)) md5 (..read! system (format prefix //artifact/extension.md5))] - (wrap {#//dependency/resolution.library library - #//dependency/resolution.pom pom - #//dependency/resolution.dependencies (set.to-list dependencies) - #//dependency/resolution.sha1 (|> sha1 - (:coerce (//hash.Hash //hash.SHA-1)) - (:: //hash.sha1-codec encode)) - #//dependency/resolution.md5 (|> md5 - (:coerce (//hash.Hash //hash.MD5)) - (:: //hash.md5-codec encode))}))) + (:: promise.monad wrap + (do try.monad + [pom (encoding.from-utf8 pom) + pom (:: xml.codec decode pom) + sha-1 (//hash.as-sha-1 sha-1) + md5 (//hash.as-md5 md5)] + (wrap {#//package.library library + #//package.pom pom + #//package.sha-1 sha-1 + #//package.md5 md5}))))) (def: #export (all-cached system dependencies resolution) (-> (file.System Promise) (List Dependency) Resolution (Promise (Try Resolution))) @@ -138,10 +140,14 @@ (with-expansions [<next> (as-is (all-cached system tail resolution))] (case package (#try.Success package) - (let [resolution (dictionary.put head package resolution)] - (do (try.with promise.monad) - [resolution (all-cached system (get@ #//dependency/resolution.dependencies package) resolution)] - <next>)) + (do (try.with promise.monad) + [sub-dependencies (|> package + //package.dependencies + (:: promise.monad wrap)) + resolution (|> resolution + (dictionary.put head package) + (all-cached system (set.to-list sub-dependencies)))] + <next>) (#try.Failure error) <next>))))) diff --git a/stdlib/source/program/aedifex/package.lux b/stdlib/source/program/aedifex/package.lux new file mode 100644 index 000000000..757f116e6 --- /dev/null +++ b/stdlib/source/program/aedifex/package.lux @@ -0,0 +1,36 @@ +(.module: + [lux #* + [control + ["." try (#+ Try) ("#@." functor)] + [parser + ["<.>" xml]]] + [data + [binary (#+ Binary)] + [format + [xml (#+ XML)]] + [collection + [set (#+ Set)]]]] + ["." // #_ + [dependency (#+ Dependency)] + ["/" profile] + ["#." hash (#+ Hash SHA-1 MD5)] + ["#." pom]]) + +(type: #export Package + {#library Binary + #pom XML + #sha-1 (Hash SHA-1) + #md5 (Hash MD5)}) + +(def: #export (local pom library) + (-> XML Binary Package) + {#library library + #pom pom + #sha-1 (//hash.sha-1 library) + #md5 (//hash.md5 library)}) + +(def: #export dependencies + (-> Package (Try (Set Dependency))) + (|>> (get@ #pom) + (<xml>.run //pom.parser) + (try@map (get@ #/.dependencies)))) |