Compare commits
73 commits
Author | SHA1 | Date | |
---|---|---|---|
ccf1871604 | |||
df53182114 | |||
bbd09258d0 | |||
16dd833477 | |||
ddb0f610e4 | |||
80f5511133 | |||
6447339f64 | |||
2c606dbeb4 | |||
c5e091a294 | |||
c57b070d87 | |||
2edc311a33 | |||
a9c249ea86 | |||
ec45a6a77a | |||
62d62420b7 | |||
da4533c2d3 | |||
6a0ae2bcab | |||
c376a4b70e | |||
4481923ade | |||
7e09f08767 | |||
6dab71a9ac | |||
e51550aedc | |||
982a35a5b1 | |||
97f68a85e9 | |||
921ee6b684 | |||
68d2ec8e98 | |||
ccc8e562b1 | |||
96368097e9 | |||
1f9e3e6e23 | |||
1e75be6900 | |||
c3d5c74075 | |||
be87d19797 | |||
37008e81f3 | |||
8ba4cfae00 | |||
9c50538877 | |||
a47193f147 | |||
1e35bfefbd | |||
a9b8f18192 | |||
2312092e42 | |||
4bec3bfbd8 | |||
f48cc19fc4 | |||
7689397ac3 | |||
e59f02a16f | |||
456340562d | |||
f9620e9011 | |||
53af2665fa | |||
f40083692a | |||
eb95821b2e | |||
9bb86b3507 | |||
826cc85b71 | |||
9bfde48f43 | |||
9a2576c423 | |||
8af9f04dd0 | |||
5accfcfc08 | |||
625081abff | |||
1016c54ee7 | |||
5938a60289 | |||
7a71e095da | |||
1241753a8c | |||
26643fbcde | |||
30266f4e09 | |||
068c640dac | |||
719b4ea45d | |||
ceb4674ec2 | |||
d36a0714e7 | |||
9ada5c4a94 | |||
58656926e3 | |||
534292ec3f | |||
02f9c2f9c7 | |||
a99f7f65a3 | |||
6490801ce1 | |||
1b1414c5ca | |||
8fc8f1c62d | |||
c2ffbdb891 |
6 changed files with 1217 additions and 978 deletions
67
mirage/archive_checksum.ml
Normal file
67
mirage/archive_checksum.ml
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
module Hash = struct
|
||||||
|
type t = (* OpamHash.kind = *) [ `MD5 | `SHA256 | `SHA512 ]
|
||||||
|
|
||||||
|
(* Make the compiler check that (t :> Digestif.hash') *)
|
||||||
|
let _ = fun (h :t) -> (h :> Digestif.hash')
|
||||||
|
|
||||||
|
let compare h h' =
|
||||||
|
match h, h' with
|
||||||
|
| `SHA512, `SHA512 -> 0
|
||||||
|
| `SHA512, _ -> 1
|
||||||
|
| _, `SHA512 -> -1
|
||||||
|
| `SHA256, `SHA256 -> 0
|
||||||
|
| `SHA256, _ -> 1
|
||||||
|
| _, `SHA256 -> -1
|
||||||
|
| `MD5, `MD5 -> 0
|
||||||
|
|
||||||
|
let to_string = function
|
||||||
|
| `MD5 -> "md5"
|
||||||
|
| `SHA256 -> "sha256"
|
||||||
|
| `SHA512 -> "sha512"
|
||||||
|
|
||||||
|
let of_string = function
|
||||||
|
| "md5" -> Ok `MD5
|
||||||
|
| "sha256" -> Ok `SHA256
|
||||||
|
| "sha512" -> Ok `SHA512
|
||||||
|
| h -> Error (`Msg ("unknown hash algorithm: " ^ h))
|
||||||
|
end
|
||||||
|
|
||||||
|
module HM = Map.Make(Hash)
|
||||||
|
|
||||||
|
type 'a digests = {
|
||||||
|
md5 : Digestif.MD5.ctx;
|
||||||
|
sha256 : Digestif.SHA256.ctx;
|
||||||
|
sha512 : Digestif.SHA512.ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
let empty_digests =
|
||||||
|
{
|
||||||
|
md5 = Digestif.MD5.empty;
|
||||||
|
sha256 = Digestif.SHA256.empty;
|
||||||
|
sha512 = Digestif.SHA512.empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
let update_digests { md5; sha256; sha512 } data =
|
||||||
|
{
|
||||||
|
md5 = Digestif.MD5.feed_string md5 data;
|
||||||
|
sha256 = Digestif.SHA256.feed_string sha256 data;
|
||||||
|
sha512 = Digestif.SHA512.feed_string sha512 data;
|
||||||
|
}
|
||||||
|
|
||||||
|
let init_write csums =
|
||||||
|
let hash, csum = HM.max_binding csums in
|
||||||
|
(hash, csum), empty_digests
|
||||||
|
|
||||||
|
let digests_to_hm digests =
|
||||||
|
HM.empty
|
||||||
|
|> HM.add `MD5
|
||||||
|
Digestif.MD5.(to_raw_string (get digests.md5))
|
||||||
|
|> HM.add `SHA256
|
||||||
|
Digestif.SHA256.(to_raw_string (get digests.sha256))
|
||||||
|
|> HM.add `SHA512
|
||||||
|
Digestif.SHA512.(to_raw_string (get digests.sha512))
|
||||||
|
|
||||||
|
let get digests = function
|
||||||
|
| `MD5 -> Digestif.MD5.(to_raw_string (get digests.md5))
|
||||||
|
| `SHA256 -> Digestif.SHA256.(to_raw_string (get digests.sha256))
|
||||||
|
| `SHA512 -> Digestif.SHA512.(to_raw_string (get digests.sha512))
|
195
mirage/bad.ml
195
mirage/bad.ml
|
@ -1,195 +0,0 @@
|
||||||
let archives =
|
|
||||||
let too_big =
|
|
||||||
[ "https://github.com/Opsian/opsian-ocaml/releases/download/0.1/0.1.tar.gz" ]
|
|
||||||
|
|
||||||
and hash_mismatch = [
|
|
||||||
"http://cdn.skylable.com/source/libres3-1.3.tar.gz" ;
|
|
||||||
"http://cdn.skylable.com/source/libres3-0.3.tar.gz" ;
|
|
||||||
"http://cdn.skylable.com/source/libres3-1.2.tar.gz" ;
|
|
||||||
"http://cdn.skylable.com/source/libres3-0.9.tar.gz" ;
|
|
||||||
"http://cdn.skylable.com/source/libres3-0.2.tar.gz" ;
|
|
||||||
"http://cdn.skylable.com/source/libres3-1.0.tar.gz" ;
|
|
||||||
"http://cdn.skylable.com/source/libres3-1.1.tar.gz" ;
|
|
||||||
"http://cdn.skylable.com/source/libres3-0.1.tar.gz" ;
|
|
||||||
"https://github.com/lemaetech/http-cookie/releases/download/v3.0.0/http-cookie-v3.0.0.tbz" ;
|
|
||||||
"http://oqamldebug.forge.ocamlcore.org/oqamldebug-0.9.4.tar.gz" ;
|
|
||||||
"http://oqamldebug.forge.ocamlcore.org/oqamldebug-0.9.2.tar.gz" ;
|
|
||||||
"http://oqamldebug.forge.ocamlcore.org/oqamldebug-0.9.3.tar.gz" ;
|
|
||||||
"http://oqamldebug.forge.ocamlcore.org/oqamldebug-0.9.5.tar.gz" ;
|
|
||||||
"http://oqamldebug.forge.ocamlcore.org/oqamldebug-0.9.1.tar.gz" ;
|
|
||||||
"https://github.com/OCamlPro/ezjs_fetch/archive/0.1.tar.gz" ;
|
|
||||||
"http://github.com/OCamlPro/typerex-build/archive/1.99.13-beta.tar.gz" ;
|
|
||||||
"https://github.com/mirage/dyntype/tarball/dyntype-0.8.5" ;
|
|
||||||
"https://github.com/mirage/dyntype/tarball/dyntype-0.8.3" ;
|
|
||||||
"https://github.com/mirage/dyntype/tarball/dyntype-0.8.2" ;
|
|
||||||
"https://github.com/mirage/dyntype/tarball/dyntype-0.8.4" ;
|
|
||||||
"https://github.com/mirage/mirage-http-unix/archive/v1.0.0.tar.gz" ;
|
|
||||||
"http://github.com/OCamlPro/typerex-build/archive/1.99.15-beta.tar.gz" ;
|
|
||||||
"http://github.com/OCamlPro/typerex-build/archive/1.99.14-beta.tar.gz" ;
|
|
||||||
"https://github.com/paulpatault/ocamlog/archive/v0.1.tar.gz" ;
|
|
||||||
"https://github.com/pveber/OCaml-R/archive/pre-nyc-refactoring.tar.gz" ;
|
|
||||||
"https://github.com/paulpatault/ocamlog/archive/v0.2.tar.gz" ;
|
|
||||||
"http://github.com/OCamlPro/typerex-build/archive/1.99.16-beta.tar.gz" ;
|
|
||||||
"https://github.com/FStarLang/kremlin/archive/v0.9.6.0.zip" ;
|
|
||||||
"https://gitlab.com/dailambda/plebeia/-/archive/2.0.2/plebeia-2.0.2.tar.gz" ;
|
|
||||||
"https://github.com/mirleft/ocaml-tls/archive/0.5.0.tar.gz" ;
|
|
||||||
"https://github.com/eth-sri/ELINA/archive/1.3.tar.gz" ;
|
|
||||||
"https://gitlab.com/trustworthy-refactoring/refactorer/-/archive/0.1/refactorer-0.1.zip" ;
|
|
||||||
"https://github.com/completium/archetype-lang/archive/1.3.3.tar.gz" ;
|
|
||||||
"https://github.com/chetmurthy/pa_ppx/archive/0.01.tar.gz" ;
|
|
||||||
"https://github.com/chambart/ocaml-1/archive/lto.tar.gz" ;
|
|
||||||
"https://github.com/Kappa-Dev/KaSim/archive/v3.5-250915.tar.gz" ;
|
|
||||||
"https://github.com/bsansouci/bsb-native/archive/1.9.4.tar.gz";
|
|
||||||
"https://github.com/sanette/oplot/archive/0.7.tar.gz";
|
|
||||||
"https://github.com/ulrikstrid/ocaml-cookie/releases/download/0.1.8/session-cookie-lwt-0.1.8.tbz";
|
|
||||||
]
|
|
||||||
|
|
||||||
and bad_request = [
|
|
||||||
"http://cgit.freedesktop.org/cairo-ocaml/snapshot/cairo-ocaml-1.2.0.tar.gz"
|
|
||||||
]
|
|
||||||
|
|
||||||
and not_found = [
|
|
||||||
"http://pw374.github.io/distrib/frag/frag-0.1.0.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/glical/glical-0.0.3.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/glical/glical-0.0.4.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/glical/glical-0.0.1.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/glical/glical-0.0.2.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/glical/glical-0.0.5.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/glical/glical-0.0.7.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/mpp/mpp-0.1.1.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/mpp/mpp-0.1.0.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/mpp/mpp-0.1.2.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/mpp/mpp-0.1.7.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/mpp/mpp-0.1.3.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/mpp/mpp-0.1.8.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/mpp/mpp-0.1.4.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/mpp/mpp-0.1.5.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/mpp/mpp-0.2.0.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/mpp/mpp-0.2.1.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/mpp/mpp-0.3.0.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.3.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.4.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.5.4.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.5.5.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.5.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.6.0.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.6.2.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.6.3.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.6.4.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.6.5.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.7.0.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.7.1.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.7.2.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.7.4.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.7.3.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.7.5.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.8.2.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.8.0.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.8.1.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.9.0.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.9.1.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.9.7.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.0.0.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.0.1.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.1.0.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.1.1.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.1.2.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.2.0.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.2.1.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.2.2.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.2.4.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.2.5.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.2.6.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.2.3.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.3.0.tar.gz" ;
|
|
||||||
"http://zoggy.github.com/ocamldot/ocamldot-1.0.tar.gz" ;
|
|
||||||
"http://zoggy.github.io/stog/stog-0.4.tar.gz" ;
|
|
||||||
"http://zoggy.github.io/genet/genet-0.6.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.6.1.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.9.4.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.9.6.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.9.5.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-0.9.3.tar.gz" ;
|
|
||||||
"http://pw374.github.io/distrib/omd/omd-1.1.3.tar.gz" ;
|
|
||||||
"http://coccinelle.lip6.fr/distrib/coccinelle-1.0.0-rc22.tgz" ;
|
|
||||||
"http://coccinelle.lip6.fr/distrib/coccinelle-1.0.0-rc21.tgz" ;
|
|
||||||
"http://coccinelle.lip6.fr/distrib/coccinelle-1.0.0.tgz" ;
|
|
||||||
"http://proverif.inria.fr/proverif1.96pl1.tar.gz" ;
|
|
||||||
"http://proverif.inria.fr/proverif1.97.tar.gz" ;
|
|
||||||
"http://proverif.inria.fr/proverif1.98.tar.gz" ;
|
|
||||||
"http://proverif.inria.fr/proverif1.97pl3.tar.gz" ;
|
|
||||||
"http://proverif.inria.fr/proverif1.98pl1.tar.gz" ;
|
|
||||||
"http://proverif.inria.fr/proverif1.97pl1.tar.gz" ;
|
|
||||||
"https://github.com/jrochel/eliom/archive/6.4.0.tar.gz" ;
|
|
||||||
"https://github.com/drjdn/ocaml_lua_parser/archive/1.0.1.tar.gz" ;
|
|
||||||
"https://github.com/sagotch/To.ml/archive/v1.0.0.tar.gz" ;
|
|
||||||
"https://zoggy.github.io/ocaml-rdf/ocaml-rdf-0.9.0.tar.gz" ;
|
|
||||||
"https://github.com/sagotch/To.ml/archive/v2.1.0.tar.gz" ;
|
|
||||||
"https://github.com/sagotch/To.ml/archive/v2.0.0.tar.gz" ;
|
|
||||||
"https://zoggy.github.io/ocaml-taglog/taglog-0.1.0.tar.gz" ;
|
|
||||||
"https://zoggy.github.io/ocaml-taglog/taglog-0.2.0.tar.gz" ;
|
|
||||||
"https://zoggy.github.io/ocf/ocf-0.3.0.tar.gz" ;
|
|
||||||
"https://zoggy.github.io/ojs-base/ojs-base-0.1.0.tar.gz" ;
|
|
||||||
"https://zoggy.github.io/stog/plugins/stog-writing-0.8.0.tar.gz" ;
|
|
||||||
"https://zoggy.github.io/stog/stog-0.13.0.tar.gz" ;
|
|
||||||
"https://zoggy.github.io/ocaml-taglog/taglog-0.3.0.tar.gz" ;
|
|
||||||
"https://zoggy.github.io/ocf/ocf-0.1.0.tar.gz" ;
|
|
||||||
"https://opam.ocaml.org/cache/md5/24/24b163eb77e6832747dccd6cc8a5d57c" ;
|
|
||||||
]
|
|
||||||
|
|
||||||
and forbidden = [
|
|
||||||
"https://gforge.inria.fr/frs/download.php/33440/heptagon-1.00.06.tar.gz" ;
|
|
||||||
"https://gforge.inria.fr/frs/download.php/file/33677/dose3-3.2.2.tar.gz" ;
|
|
||||||
"https://gforge.inria.fr/frs/download.php/file/34920/javalib-2.3.1.tar.bz2" ;
|
|
||||||
"https://gforge.inria.fr/frs/download.php/file/36092/javalib-2.3.2.tar.bz2" ;
|
|
||||||
"https://gforge.inria.fr/frs/download.php/file/36093/sawja-1.5.2.tar.bz2" ;
|
|
||||||
"https://gforge.inria.fr/frs/download.php/file/37154/javalib-2.3.4.tar.bz2" ;
|
|
||||||
"https://gforge.inria.fr/frs/download.php/file/37403/sawja-1.5.3.tar.bz2" ;
|
|
||||||
"https://gforge.inria.fr/frs/download.php/file/36307/javalib-2.3.3.tar.bz2" ;
|
|
||||||
"https://gforge.inria.fr/frs/download.php/file/37655/javalib-2.3.5.tar.bz2" ;
|
|
||||||
"https://gforge.inria.fr/frs/download.php/file/37656/sawja-1.5.4.tar.bz2" ;
|
|
||||||
"https://gforge.inria.fr/frs/download.php/file/34921/sawja-1.5.1.tar.bz2" ;
|
|
||||||
]
|
|
||||||
|
|
||||||
and three_o_o = [
|
|
||||||
"https://github.com/Gbury/dolmen/archive/v0.4.tar.gz" ;
|
|
||||||
"https://github.com/Stevendeo/Pilat/archive/1.3.tar.gz" ;
|
|
||||||
"https://github.com/OCamlPro/ocp-indent/archive/1.5.tar.gz" ;
|
|
||||||
"https://github.com/backtracking/combine/archive/release-0.6.zip" ;
|
|
||||||
"https://github.com/cakeplus/pa_comprehension/archive/0.4.tar.gz" ;
|
|
||||||
"https://github.com/cakeplus/mparser/archive/1.0.tar.gz" ;
|
|
||||||
"https://github.com/chenyukang/rubytt/archive/v0.1.tar.gz" ;
|
|
||||||
"https://github.com/cakeplus/pa_where/archive/0.4.tar.gz" ;
|
|
||||||
"https://github.com/metaocaml/ber-metaocaml/archive/ber-n102.tar.gz" ;
|
|
||||||
"https://github.com/cakeplus/pa_solution/archive/0.5.tar.gz" ;
|
|
||||||
"https://github.com/cakeplus/mparser/archive/1.2.1.tar.gz" ;
|
|
||||||
"https://github.com/cakeplus/pa_solution/archive/0.7.tar.gz" ;
|
|
||||||
"https://github.com/cakeplus/pa_solution/archive/0.6.tar.gz" ;
|
|
||||||
"https://github.com/mirage/mirage-tcpip/archive/v2.8.1.tar.gz" ;
|
|
||||||
"https://github.com/modlfo/pla/archive/v1.4.tar.gz" ;
|
|
||||||
"https://github.com/murmour/pa_qualified/archive/0.5.tar.gz" ;
|
|
||||||
"https://github.com/ocaml-ppx/ocamlformat/archive/v0.2.tar.gz" ;
|
|
||||||
"https://github.com/murmour/pa_qualified/archive/0.6.tar.gz" ;
|
|
||||||
"https://github.com/ocaml-ppx/ocamlformat/archive/support.0.2.tar.gz" ;
|
|
||||||
"https://github.com/ocaml/oloop/archive/0.1.2.tar.gz" ;
|
|
||||||
"https://github.com/cakeplus/mparser/archive/1.0.1.tar.gz" ;
|
|
||||||
"https://github.com/cakeplus/mparser/archive/1.1.tar.gz" ;
|
|
||||||
"https://github.com/savonet/ocaml-ffmpeg/archive/v1.0.0-rc1.tar.gz" ;
|
|
||||||
"https://github.com/ocaml/opam2web/archive/2.0.tar.gz" ;
|
|
||||||
"https://github.com/savonet/ocaml-ffmpeg/archive/v1.0.0.tar.gz" ;
|
|
||||||
]
|
|
||||||
|
|
||||||
and five_o_three = [ "https://gitlab.com/gasche/build_path_prefix_map/repository/0.2/archive.tar.gz" ]
|
|
||||||
|
|
||||||
and is_ftp = [ "ftp://ftp.netbsd.org/pub/pkgsrc/distfiles/wyrd-1.4.6.tar.gz" ]
|
|
||||||
|
|
||||||
and connect_fails = [
|
|
||||||
"http://godi.0ok.org/godi-backup/shcaml-0.1.3.tar.gz" ;
|
|
||||||
"http://www.first.in-berlin.de/software/tools/apalogretrieve/apalogretrieve-0-9-6_4.tgz" ;
|
|
||||||
"https://cavale.enseeiht.fr/osdp/osdp-0.5.4.tgz" ;
|
|
||||||
"https://cavale.enseeiht.fr/osdp/osdp-0.6.0.tgz" ;
|
|
||||||
"https://cavale.enseeiht.fr/osdp/osdp-1.0.0.tgz" ;
|
|
||||||
]
|
|
||||||
in
|
|
||||||
|
|
||||||
too_big @ hash_mismatch @ bad_request @ not_found @ forbidden @ three_o_o @ five_o_three @ is_ftp @ connect_fails
|
|
107
mirage/config.ml
107
mirage/config.ml
|
@ -1,109 +1,40 @@
|
||||||
|
(* mirage >= 4.8.0 & < 4.9.0 *)
|
||||||
open Mirage
|
open Mirage
|
||||||
|
|
||||||
let check =
|
|
||||||
let doc =
|
|
||||||
Key.Arg.info ~doc:"Only check the cache" ["check"]
|
|
||||||
in
|
|
||||||
Key.(create "check" Arg.(flag doc))
|
|
||||||
|
|
||||||
let verify_sha256 =
|
|
||||||
let doc =
|
|
||||||
Key.Arg.info ~doc:"Verify the SHA256 checksums of the cache contents, and \
|
|
||||||
re-build the other checksum caches."
|
|
||||||
["verify-sha256"]
|
|
||||||
in
|
|
||||||
Key.(create "verify-sha256" Arg.(flag doc))
|
|
||||||
|
|
||||||
let remote =
|
|
||||||
let doc =
|
|
||||||
Key.Arg.info
|
|
||||||
~doc:"Remote repository url, use suffix #foo to specify a branch 'foo': \
|
|
||||||
https://github.com/ocaml/opam-repository.git"
|
|
||||||
["remote"]
|
|
||||||
in
|
|
||||||
Key.(create "remote" Arg.(opt string "https://github.com/ocaml/opam-repository.git#master" doc))
|
|
||||||
|
|
||||||
let parallel_downloads =
|
|
||||||
let doc =
|
|
||||||
Key.Arg.info
|
|
||||||
~doc:"Amount of parallel HTTP downloads"
|
|
||||||
["parallel-downloads"]
|
|
||||||
in
|
|
||||||
Key.(create "parallel-downloads" Arg.(opt int 20 doc))
|
|
||||||
|
|
||||||
let hook_url =
|
|
||||||
let doc =
|
|
||||||
Key.Arg.info
|
|
||||||
~doc:"URL to conduct an update of the git repository" ["hook-url"]
|
|
||||||
in
|
|
||||||
Key.(create "hook-url" Arg.(opt string "update" doc))
|
|
||||||
|
|
||||||
let port =
|
|
||||||
let doc = Key.Arg.info ~doc:"HTTP listen port." ["port"] in
|
|
||||||
Key.(create "port" Arg.(opt int 80 doc))
|
|
||||||
|
|
||||||
let tls_authenticator =
|
|
||||||
(* this will not look the same in the help printout *)
|
|
||||||
let doc = "TLS host authenticator. See git_http in lib/mirage/mirage.mli for a description of the format."
|
|
||||||
in
|
|
||||||
let doc = Key.Arg.info ~doc ["tls-authenticator"] in
|
|
||||||
Key.(create "tls-authenticator" Arg.(opt (some string) None doc))
|
|
||||||
|
|
||||||
let sectors_cache =
|
|
||||||
let doc = "Number of sectors reserved for each checksum cache (md5, sha512)." in
|
|
||||||
let doc = Key.Arg.info ~doc ["sectors-cache"] in
|
|
||||||
Key.(create "sectors-cache" Arg.(opt int64 Int64.(mul 4L 2048L) doc))
|
|
||||||
|
|
||||||
let sectors_git =
|
|
||||||
let doc = "Number of sectors reserved for git dump." in
|
|
||||||
let doc = Key.Arg.info ~doc ["sectors-git"] in
|
|
||||||
Key.(create "sectors-git" Arg.(opt int64 Int64.(mul 40L (mul 2L 1024L)) doc))
|
|
||||||
|
|
||||||
let ignore_local_git =
|
|
||||||
let doc = "Ignore restoring locally saved git repository." in
|
|
||||||
let doc = Key.Arg.info ~doc ["ignore-local-git"] in
|
|
||||||
Key.(create "ignore-local-git" Arg.(flag doc))
|
|
||||||
|
|
||||||
let mirror =
|
let mirror =
|
||||||
foreign "Unikernel.Make"
|
main "Unikernel.Make"
|
||||||
~keys:[ Key.v check ; Key.v verify_sha256 ; Key.v remote ;
|
|
||||||
Key.v parallel_downloads ; Key.v hook_url ; Key.v tls_authenticator ;
|
|
||||||
Key.v port ; Key.v sectors_cache ; Key.v sectors_git ;
|
|
||||||
Key.v ignore_local_git ;
|
|
||||||
]
|
|
||||||
~packages:[
|
~packages:[
|
||||||
package ~min:"0.3.0" ~sublibs:[ "mirage" ] "paf" ;
|
package ~min:"0.3.0" ~sublibs:[ "mirage" ] "paf" ;
|
||||||
package "h2" ;
|
package "h2" ;
|
||||||
package "hex" ;
|
package "ohex" ;
|
||||||
package "httpaf" ;
|
package "httpaf" ;
|
||||||
package "git-kv" ;
|
package ~min:"0.1.1" "git-kv" ;
|
||||||
package ~min:"3.10.0" "git-paf" ;
|
package ~min:"3.10.0" "git-paf" ;
|
||||||
package "opam-file-format" ;
|
package "opam-file-format" ;
|
||||||
package ~min:"2.2.0" ~sublibs:[ "gz" ] "tar" ;
|
package ~min:"3.0.0" ~sublibs:[ "gz" ] "tar" ;
|
||||||
package ~min:"2.2.0" "tar-mirage" ;
|
package ~min:"3.0.0" "tar-mirage" ;
|
||||||
package ~max:"0.2.0" "mirage-block-partition" ;
|
package ~max:"0.2.0" "mirage-block-partition" ;
|
||||||
|
package ~min:"0.0.8" "http-mirage-client" ;
|
||||||
|
package "gpt" ;
|
||||||
|
package "gptar" ;
|
||||||
package "oneffs" ;
|
package "oneffs" ;
|
||||||
|
package "digestif" ;
|
||||||
|
package "swapfs" ;
|
||||||
]
|
]
|
||||||
(block @-> time @-> pclock @-> stackv4v6 @-> git_client @-> alpn_client @-> job)
|
(block @-> time @-> pclock @-> stackv4v6 @-> git_client @-> alpn_client @-> job)
|
||||||
|
|
||||||
let stack = generic_stackv4v6 default_network
|
let stack = generic_stackv4v6 default_network
|
||||||
|
let he = generic_happy_eyeballs stack
|
||||||
let dns = generic_dns_client stack
|
let dns = generic_dns_client stack he
|
||||||
|
|
||||||
let tcp = tcpv4v6_of_stackv4v6 stack
|
let tcp = tcpv4v6_of_stackv4v6 stack
|
||||||
|
let block = block_of_file "tar"
|
||||||
|
|
||||||
let git_client, alpn_client =
|
let git_client, alpn_client =
|
||||||
let happy_eyeballs = generic_happy_eyeballs stack dns in
|
let git = mimic_happy_eyeballs stack he dns in
|
||||||
let git = mimic_happy_eyeballs stack dns happy_eyeballs in
|
merge_git_clients (git_ssh tcp git)
|
||||||
merge_git_clients (git_tcp tcp git)
|
(merge_git_clients (git_tcp tcp git)
|
||||||
(git_http ~authenticator:tls_authenticator tcp git),
|
(git_http tcp git)),
|
||||||
paf_client ~pclock:default_posix_clock tcp (mimic_happy_eyeballs stack dns happy_eyeballs)
|
paf_client tcp (mimic_happy_eyeballs stack he dns)
|
||||||
|
|
||||||
let program_block_size =
|
|
||||||
let doc = Key.Arg.info [ "program-block-size" ] in
|
|
||||||
Key.(create "program_block_size" Arg.(opt int 16 doc))
|
|
||||||
|
|
||||||
let block = block_of_file "tar"
|
|
||||||
|
|
||||||
let () = register "mirror"
|
let () = register "mirror"
|
||||||
[ mirror $ block $ default_time $ default_posix_clock $ stack $ git_client $ alpn_client ]
|
[ mirror $ block $ default_time $ default_posix_clock $ stack $ git_client $ alpn_client ]
|
||||||
|
|
144
mirage/opam_file.ml
Normal file
144
mirage/opam_file.ml
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
module HM = Archive_checksum.HM
|
||||||
|
|
||||||
|
let hash_to_string = Archive_checksum.Hash.to_string
|
||||||
|
|
||||||
|
let hex_of_string s =
|
||||||
|
match Ohex.decode s with
|
||||||
|
| d -> Ok d
|
||||||
|
| exception Invalid_argument err -> Error (`Msg err)
|
||||||
|
|
||||||
|
let decode_digest filename str =
|
||||||
|
let hex h s =
|
||||||
|
match hex_of_string s with
|
||||||
|
| Ok d -> Ok (h, d)
|
||||||
|
| Error _ as e -> e
|
||||||
|
in
|
||||||
|
match String.split_on_char '=' str with
|
||||||
|
| [ data ] -> hex `MD5 data
|
||||||
|
| [ "md5" ; data ] -> hex `MD5 data
|
||||||
|
| [ "sha256" ; data ] -> hex `SHA256 data
|
||||||
|
| [ "sha512" ; data ] -> hex `SHA512 data
|
||||||
|
| [ hash ; _ ] -> Error (`Msg ("unknown hash " ^ hash))
|
||||||
|
| _ -> Error (`Msg ("unexpected hash format " ^ str))
|
||||||
|
|
||||||
|
let extract_url_checksum filename items =
|
||||||
|
let open OpamParserTypes.FullPos in
|
||||||
|
let url =
|
||||||
|
List.find_opt
|
||||||
|
(function { pelem = Variable ({ pelem = "src" ; _ }, _); _ } -> true | _ -> false)
|
||||||
|
items
|
||||||
|
and archive =
|
||||||
|
List.find_opt
|
||||||
|
(function { pelem = Variable ({ pelem = "archive" ; _ }, _); _ } -> true | _ -> false)
|
||||||
|
items
|
||||||
|
and checksum =
|
||||||
|
List.find_opt
|
||||||
|
(function { pelem = Variable ({ pelem = "checksum" ; _ }, _); _ } -> true | _ -> false)
|
||||||
|
items
|
||||||
|
and mirrors =
|
||||||
|
List.find_opt
|
||||||
|
(function { pelem = Variable ({ pelem = "mirrors" ; _ }, _); _ } -> true | _ -> false)
|
||||||
|
items
|
||||||
|
in
|
||||||
|
let url =
|
||||||
|
match url, archive with
|
||||||
|
| Some { pelem = Variable (_, { pelem = String url ; _ }) ; _ }, None -> Ok url
|
||||||
|
| None, Some { pelem = Variable (_, { pelem = String url ; _ }); _ } -> Ok url
|
||||||
|
| _ -> Error (`Msg "neither 'src' nor 'archive' present")
|
||||||
|
and mirrors = match mirrors with
|
||||||
|
| None -> []
|
||||||
|
| Some { pelem = Variable (_, { pelem = String url ; _ }) ; _ } -> [ url ]
|
||||||
|
| Some { pelem = Variable (_, { pelem = List { pelem = urls ; _ } ; _ }) } ->
|
||||||
|
List.fold_left (fun acc -> function
|
||||||
|
| { pelem = String url ; _ } -> url :: acc
|
||||||
|
| v ->
|
||||||
|
Logs.err (fun m -> m "bad mirror data (expected a string in the list): %s"
|
||||||
|
(OpamPrinter.FullPos.value v));
|
||||||
|
acc)
|
||||||
|
[] urls
|
||||||
|
| Some v ->
|
||||||
|
Logs.err (fun m -> m "bad mirror data (expected string or string list): %s"
|
||||||
|
(OpamPrinter.FullPos.items [ v ]));
|
||||||
|
[]
|
||||||
|
in
|
||||||
|
let csum, csum_errs =
|
||||||
|
match checksum with
|
||||||
|
| Some { pelem = Variable (_, { pelem = List { pelem = csums ; _ } ; _ }); _ } ->
|
||||||
|
let csums, errs =
|
||||||
|
List.fold_left (fun (csums, errs) ->
|
||||||
|
function
|
||||||
|
| { pelem = String csum ; _ } ->
|
||||||
|
begin match decode_digest filename csum with
|
||||||
|
| Error e -> csums, e :: errs
|
||||||
|
| Ok (h, v) ->
|
||||||
|
HM.update h (function
|
||||||
|
| None -> Some v
|
||||||
|
| Some v' when String.equal v v' -> None
|
||||||
|
| Some v' ->
|
||||||
|
Logs.warn (fun m -> m "for %s, hash %s, multiple keys are present: %s %s"
|
||||||
|
(Result.value ~default:"NONE" url) (hash_to_string h) (Ohex.encode v) (Ohex.encode v'));
|
||||||
|
None)
|
||||||
|
csums, errs
|
||||||
|
end
|
||||||
|
| v ->
|
||||||
|
csums, `Msg (Fmt.str "bad checksum data: %s" (OpamPrinter.FullPos.value v)) :: errs)
|
||||||
|
(HM.empty, []) csums
|
||||||
|
in
|
||||||
|
if HM.is_empty csums then
|
||||||
|
match errs with
|
||||||
|
| hd :: tl -> Error hd, tl
|
||||||
|
| [] -> Error (`Msg "empty checksums"), []
|
||||||
|
else
|
||||||
|
Ok csums, errs
|
||||||
|
| Some { pelem = Variable (_, { pelem = String csum ; _ }) ; _ } ->
|
||||||
|
begin match decode_digest filename csum with
|
||||||
|
| Error _ as e -> e, []
|
||||||
|
| Ok (h, v) -> Ok (HM.singleton h v), []
|
||||||
|
end
|
||||||
|
| _ -> Error (`Msg "couldn't find or decode 'checksum'"), []
|
||||||
|
in
|
||||||
|
(match url, csum with
|
||||||
|
| Ok url, Ok csum -> Ok (url, csum, mirrors)
|
||||||
|
| Error _ as e, _
|
||||||
|
| _, (Error _ as e) -> e), csum_errs
|
||||||
|
|
||||||
|
let extract_checksums_and_urls filename opam =
|
||||||
|
let open OpamParserTypes.FullPos in
|
||||||
|
List.fold_left (fun (csum_urls, errs) ->
|
||||||
|
function
|
||||||
|
| { pelem = Section ({ section_kind = { pelem = "url" ; _ } ; section_items = { pelem = items ; _ } ; _ }) ; _} ->
|
||||||
|
begin match extract_url_checksum filename items with
|
||||||
|
| Error `Msg msg, errs' -> csum_urls, `Msg ("url: " ^ msg) :: errs' @ errs
|
||||||
|
| Ok url, errs' -> url :: csum_urls, errs' @ errs
|
||||||
|
end
|
||||||
|
| { pelem = Section ({ section_kind = { pelem = "extra-source" ; _ } ; section_name = Some { pelem ; _ } ; section_items = { pelem = items ; _ }; _ }) ; _} ->
|
||||||
|
begin
|
||||||
|
match extract_url_checksum filename items with
|
||||||
|
| Error `Msg msg, errs' -> csum_urls, `Msg ("extra-source " ^ pelem ^ " " ^ msg) :: errs' @ errs
|
||||||
|
| Ok url, errs' -> url :: csum_urls, errs' @ errs
|
||||||
|
end
|
||||||
|
| _ -> csum_urls, errs)
|
||||||
|
([], []) opam.file_contents
|
||||||
|
|
||||||
|
let extract_urls filename str =
|
||||||
|
(* in an opam file, there may be:
|
||||||
|
url { src: <string> checksum: [ STRING ] } <- list of hash
|
||||||
|
url { src: <string> checksum: STRING } <- single hash
|
||||||
|
url { archive: <string> checksum: STRING } <- MD5
|
||||||
|
extra-source NAME { src: URL checksum: [ STRING ] } (OR checksum: STRING) <- multiple occurences possible
|
||||||
|
*)
|
||||||
|
let open OpamParserTypes.FullPos in
|
||||||
|
let opamfile = OpamParser.FullPos.string str filename in
|
||||||
|
let unavailable =
|
||||||
|
List.exists
|
||||||
|
(function
|
||||||
|
| { pelem = Variable ({ pelem = "available" ; _ },
|
||||||
|
{ pelem = (Bool false | List { pelem = [{ pelem = Bool false; _ }] ; _ }); _ })
|
||||||
|
; _ } -> true
|
||||||
|
| _ -> false)
|
||||||
|
opamfile.file_contents
|
||||||
|
in
|
||||||
|
if unavailable then
|
||||||
|
[], []
|
||||||
|
else
|
||||||
|
extract_checksums_and_urls filename opamfile
|
222
mirage/partitions.ml
Normal file
222
mirage/partitions.ml
Normal file
|
@ -0,0 +1,222 @@
|
||||||
|
open Lwt.Syntax
|
||||||
|
|
||||||
|
module Make(BLOCK : Mirage_block.S) = struct
|
||||||
|
module Part = Mirage_block_partition.Make(BLOCK)
|
||||||
|
|
||||||
|
include Part
|
||||||
|
|
||||||
|
type partitions = {
|
||||||
|
tar : Part.t ;
|
||||||
|
swap : Part.t ;
|
||||||
|
git_dump : Part.t ;
|
||||||
|
md5s : Part.t ;
|
||||||
|
sha512s : Part.t ;
|
||||||
|
}
|
||||||
|
|
||||||
|
(* I just made these ones up... *)
|
||||||
|
let swap_guid = Uuidm.of_string "76515dc1-953f-4c59-8b41-90011bdddfcd" |> Option.get
|
||||||
|
let tar_guid = Uuidm.of_string "53cd6812-46cc-474e-a141-30b3aed85f53" |> Option.get
|
||||||
|
let cache_guid = Uuidm.of_string "22ab9cf5-6e51-45c2-998a-862e23aab264" |> Option.get
|
||||||
|
let git_guid = Uuidm.of_string "30faa50a-4c9d-47ff-a1a5-ecfb3401c027" |> Option.get
|
||||||
|
|
||||||
|
(* GPT uses a 72 byte utf16be encoded string for partition names *)
|
||||||
|
let utf16be_of_ascii s =
|
||||||
|
String.init 72
|
||||||
|
(fun i ->
|
||||||
|
if i mod 2 = 0 && i / 2 < String.length s then
|
||||||
|
s.[i/2]
|
||||||
|
else
|
||||||
|
'\000')
|
||||||
|
|
||||||
|
let read_partition_table info block =
|
||||||
|
let b = Cstruct.create info.Mirage_block.sector_size in
|
||||||
|
(* We will ignore the protective MBR at lba [0L] *)
|
||||||
|
let* r = BLOCK.read block 1L [b] in
|
||||||
|
match r with
|
||||||
|
| Error e ->
|
||||||
|
Format.kasprintf failwith "Reading partition table: %a"
|
||||||
|
BLOCK.pp_error e
|
||||||
|
| Ok () ->
|
||||||
|
match Gpt.unmarshal b ~sector_size:info.Mirage_block.sector_size with
|
||||||
|
| Error e ->
|
||||||
|
Format.kasprintf failwith "Reading partition table: %s" e
|
||||||
|
| Ok (`Read_partition_table (lba, sectors), k) ->
|
||||||
|
let b = Cstruct.create (sectors * info.Mirage_block.sector_size) in
|
||||||
|
let* r = BLOCK.read block lba [b] in
|
||||||
|
match r with
|
||||||
|
| Error e ->
|
||||||
|
Format.kasprintf failwith "Reading partition table: %a"
|
||||||
|
BLOCK.pp_error e
|
||||||
|
| Ok () ->
|
||||||
|
match k b with
|
||||||
|
| Error e ->
|
||||||
|
Format.kasprintf failwith "Reading partition table: %s" e
|
||||||
|
| Ok gpt -> Lwt.return gpt
|
||||||
|
|
||||||
|
let connect block =
|
||||||
|
let* info = BLOCK.get_info block in
|
||||||
|
let* gpt = read_partition_table info block in
|
||||||
|
let tar, swap, git_dump, md5s, sha512s =
|
||||||
|
match
|
||||||
|
List.fold_left
|
||||||
|
(fun (tar, swap, git_dump, md5s, sha512s) p ->
|
||||||
|
if String.equal p.Gpt.Partition.name
|
||||||
|
(utf16be_of_ascii "tar")
|
||||||
|
then
|
||||||
|
(Some p, swap, git_dump, md5s, sha512s)
|
||||||
|
else if String.equal p.name
|
||||||
|
(utf16be_of_ascii "git_dump")
|
||||||
|
then
|
||||||
|
(tar, swap, Some p, md5s, sha512s)
|
||||||
|
else if String.equal p.name
|
||||||
|
(utf16be_of_ascii "md5s")
|
||||||
|
then
|
||||||
|
(tar, swap, git_dump, Some p, sha512s)
|
||||||
|
else if String.equal p.name
|
||||||
|
(utf16be_of_ascii "sha512s")
|
||||||
|
then
|
||||||
|
(tar, swap, git_dump, md5s, Some p)
|
||||||
|
else if String.equal p.name
|
||||||
|
(utf16be_of_ascii "swap")
|
||||||
|
then
|
||||||
|
(tar, Some p, git_dump, md5s, sha512s)
|
||||||
|
else
|
||||||
|
Format.kasprintf failwith "Unknown partition %S" p.name)
|
||||||
|
(None, None, None, None, None)
|
||||||
|
gpt.partitions
|
||||||
|
with
|
||||||
|
| (Some tar, Some swap, Some git_dump, Some md5s, Some sha512s) ->
|
||||||
|
(tar, swap, git_dump, md5s, sha512s)
|
||||||
|
| _ ->
|
||||||
|
failwith "not all partitions found :("
|
||||||
|
in
|
||||||
|
let+ (_empty, p) = Part.connect 0L block in
|
||||||
|
let get_part part =
|
||||||
|
let len = Int64.(succ (sub part.Gpt.Partition.ending_lba part.starting_lba)) in
|
||||||
|
let (_before, after) = Part.subpartition part.starting_lba p in
|
||||||
|
let (part, _after) = Part.subpartition len after in
|
||||||
|
part
|
||||||
|
in
|
||||||
|
let tar = get_part tar and swap = get_part swap and git_dump = get_part git_dump
|
||||||
|
and md5s = get_part md5s and sha512s = get_part sha512s in
|
||||||
|
{ tar ; swap; git_dump ; md5s ; sha512s }
|
||||||
|
|
||||||
|
let format block ~cache_size ~git_size ~swap_size =
|
||||||
|
let* { size_sectors; sector_size; _ } = BLOCK.get_info block in
|
||||||
|
let ( let*? ) = Lwt_result.bind in
|
||||||
|
(* ocaml-gpt uses a fixed size partition entries table. Create an empty GPT
|
||||||
|
to figure out the first usable LBA *)
|
||||||
|
let empty =
|
||||||
|
Gpt.make ~sector_size ~disk_sectors:size_sectors []
|
||||||
|
|> Result.get_ok
|
||||||
|
in
|
||||||
|
let mb_in_sectors mb =
|
||||||
|
(* 1 megabyte is 2^20 bytes (1024 * 1024) *)
|
||||||
|
let mb_in_bytes = Int64.(shift_left (of_int mb) 20) in
|
||||||
|
let ss = Int64.of_int sector_size in
|
||||||
|
Int64.(div (add mb_in_bytes (sub ss 1L)) ss)
|
||||||
|
in
|
||||||
|
let sectors_cache = mb_in_sectors cache_size
|
||||||
|
and sectors_git = mb_in_sectors git_size
|
||||||
|
and sectors_swap = mb_in_sectors swap_size
|
||||||
|
in
|
||||||
|
let*? () =
|
||||||
|
if size_sectors <
|
||||||
|
(* protective MBR + GPT header + GPT table *)
|
||||||
|
let ( + ) = Int64.add in
|
||||||
|
empty.first_usable_lba +
|
||||||
|
min 1L (Int64.of_int (2 * Tar.Header.length / sector_size)) + sectors_cache + sectors_cache + sectors_git
|
||||||
|
+ 1L (* backup GPT header *) then
|
||||||
|
Lwt.return_error (`Msg "too small disk")
|
||||||
|
else Lwt_result.return ()
|
||||||
|
in
|
||||||
|
(* Current implementation of [Gpt.Partition.make] only returns [Ok _] or
|
||||||
|
raises [Invalid_argument _] :/ *)
|
||||||
|
let attributes = 1L in
|
||||||
|
let sha512s =
|
||||||
|
Gpt.Partition.make
|
||||||
|
~name:(utf16be_of_ascii "sha512s")
|
||||||
|
~type_guid:cache_guid
|
||||||
|
~attributes
|
||||||
|
Int64.(succ (sub empty.last_usable_lba sectors_cache))
|
||||||
|
empty.last_usable_lba
|
||||||
|
|> Result.get_ok
|
||||||
|
in
|
||||||
|
let md5s =
|
||||||
|
Gpt.Partition.make
|
||||||
|
~name:(utf16be_of_ascii "md5s")
|
||||||
|
~type_guid:cache_guid
|
||||||
|
~attributes
|
||||||
|
(Int64.sub sha512s.starting_lba sectors_cache)
|
||||||
|
(Int64.pred sha512s.starting_lba)
|
||||||
|
|> Result.get_ok
|
||||||
|
in
|
||||||
|
let git_dump =
|
||||||
|
Gpt.Partition.make
|
||||||
|
~name:(utf16be_of_ascii "git_dump")
|
||||||
|
~type_guid:git_guid
|
||||||
|
~attributes
|
||||||
|
(Int64.sub md5s.starting_lba sectors_git)
|
||||||
|
(Int64.pred md5s.starting_lba)
|
||||||
|
|> Result.get_ok
|
||||||
|
in
|
||||||
|
let swap =
|
||||||
|
Gpt.Partition.make
|
||||||
|
~name:(utf16be_of_ascii "swap")
|
||||||
|
~type_guid:swap_guid
|
||||||
|
~attributes
|
||||||
|
(Int64.sub git_dump.starting_lba sectors_swap)
|
||||||
|
(Int64.pred git_dump.starting_lba)
|
||||||
|
|> Result.get_ok
|
||||||
|
in
|
||||||
|
let tar =
|
||||||
|
Gpt.Partition.make
|
||||||
|
~name:(utf16be_of_ascii "tar")
|
||||||
|
~type_guid:tar_guid
|
||||||
|
~attributes
|
||||||
|
empty.first_usable_lba
|
||||||
|
(Int64.pred swap.starting_lba)
|
||||||
|
|> Result.get_ok
|
||||||
|
in
|
||||||
|
let gpt =
|
||||||
|
let partitions =
|
||||||
|
[ tar; swap; git_dump; md5s; sha512s ]
|
||||||
|
in
|
||||||
|
Gpt.make ~sector_size ~disk_sectors:size_sectors partitions
|
||||||
|
|> Result.get_ok
|
||||||
|
in
|
||||||
|
let buf =
|
||||||
|
Cstruct.create (sector_size * (Int64.to_int gpt.first_usable_lba + 2 * Tar.Header.length))
|
||||||
|
in
|
||||||
|
Gptar.marshal_header ~sector_size buf gpt;
|
||||||
|
Gpt.marshal_partition_table ~sector_size
|
||||||
|
(Cstruct.shift buf (sector_size * Int64.to_int gpt.partition_entry_lba))
|
||||||
|
gpt;
|
||||||
|
let write block sector_start buffers =
|
||||||
|
BLOCK.write block sector_start buffers
|
||||||
|
|> Lwt_result.map_error (fun e -> `Block e)
|
||||||
|
in
|
||||||
|
let*? () =
|
||||||
|
write block 0L [ buf ]
|
||||||
|
in
|
||||||
|
(* Format the file systems by writing zeroes *)
|
||||||
|
(* For tar we need to zero (at least) the first 2*512 bytes so we round up
|
||||||
|
to the nearest sector alignment *)
|
||||||
|
let zeroes =
|
||||||
|
let sectors =
|
||||||
|
(2 * Tar.Header.length + sector_size - 1) / sector_size * sector_size
|
||||||
|
in
|
||||||
|
Cstruct.create sectors in
|
||||||
|
let*? () =
|
||||||
|
write block tar.starting_lba [ zeroes ]
|
||||||
|
in
|
||||||
|
(* For the OneFFS filesystems we just need to zero out the first sector *)
|
||||||
|
let zero_sector = Cstruct.create sector_size in
|
||||||
|
let*? () =
|
||||||
|
write block git_dump.starting_lba [ zero_sector ]
|
||||||
|
in
|
||||||
|
let*? () =
|
||||||
|
write block md5s.starting_lba [ zero_sector ]
|
||||||
|
in
|
||||||
|
write block sha512s.starting_lba [ zero_sector ]
|
||||||
|
end
|
1324
mirage/unikernel.ml
1324
mirage/unikernel.ml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue