From 1eaacd14d4c6611f555293603d0e3802637acd18 Mon Sep 17 00:00:00 2001 From: Anil Madhavapeddy Date: Mon, 3 Nov 2014 18:24:42 +0000 Subject: [PATCH 1/4] update to cohttp 0.12.0 api --- CHANGES | 3 +++ _oasis | 6 +++--- src/cohttp_unbuffered_io.ml | 1 + src/impl.ml | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index c64140e..225c081 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +0.7.6 (2014-11-04) +* Upgrade to cohttp 0.12.0 API + 0.7.5 (2014-06-03) * Upgrade to cohttp 0.10 * Fix incorrect handling of tar file prefixes diff --git a/_oasis b/_oasis index d9b601a..1e7a46c 100644 --- a/_oasis +++ b/_oasis @@ -1,6 +1,6 @@ OASISFormat: 0.3 Name: vhd-tool -Version: 0.7.5 +Version: 0.7.6 Synopsis: .vhd file manipulation Authors: Jonathan Ludlam and David Scott License: LGPL-2.1 with OCaml linking exception @@ -16,7 +16,7 @@ Executable "vhd-tool" MainIs: main.ml Custom: true Install: false - BuildDepends: lwt, lwt.unix, vhd-format, vhd-format.lwt, cmdliner, nbd, nbd.lwt, uri, cohttp (>= 0.10.0), cohttp.lwt, tar, sha, sha.sha1, io-page.unix, re.str + BuildDepends: lwt, lwt.unix, vhd-format, vhd-format.lwt, cmdliner, nbd, nbd.lwt, uri, cohttp (>= 0.12.0), cohttp.lwt, tar, sha, sha.sha1, io-page.unix, re.str Executable "sparse_dd" Build$: flag(xenserver) @@ -25,4 +25,4 @@ Executable "sparse_dd" MainIs: sparse_dd.ml Custom: true Install: false - BuildDepends: lwt, lwt.unix, vhd-format, vhd-format.lwt, cmdliner, nbd, nbd.lwt, uri, cohttp (>= 0.10.0), cohttp.lwt, xenstore, xenstore.client, xenstore.unix, xenstore_transport, xenstore_transport.unix, threads, tapctl, xcp, sha, sha.sha1, tar, io-page.unix, re.str + BuildDepends: lwt, lwt.unix, vhd-format, vhd-format.lwt, cmdliner, nbd, nbd.lwt, uri, cohttp (>= 0.12.0), cohttp.lwt, xenstore, xenstore.client, xenstore.unix, xenstore_transport, xenstore_transport.unix, threads, tapctl, xcp, sha, sha.sha1, tar, io-page.unix, re.str diff --git a/src/cohttp_unbuffered_io.ml b/src/cohttp_unbuffered_io.ml index 0bb16be..303ae22 100644 --- a/src/cohttp_unbuffered_io.ml +++ b/src/cohttp_unbuffered_io.ml @@ -40,6 +40,7 @@ let make_input c = { header_buffer; header_buffer_idx; c } type oc = Channels.t +type conn = Channels.t let really_read_into c buf ofs len = let tmp = Cstruct.create len in diff --git a/src/impl.ml b/src/impl.ml index 43197c8..b91f912 100644 --- a/src/impl.ml +++ b/src/impl.ml @@ -689,7 +689,7 @@ let write_stream common s destination source_protocol destination_protocol preze | Some x -> begin match Re_str.bounded_split_delim (Re_str.regexp_string ":") x 2 with | [ user; pass ] -> - let b = Cohttp.Auth.(to_string (Basic (user, pass))) in + let b = Cohttp.Auth.string_of_resp (`Basic (user, pass)) in Header.add headers "authorization" b | _ -> Printf.fprintf stderr "I don't know how to handle authentication for this URI.\n Try scheme://user:password@host/path\n"; From b6d42563cf26d10ffdea0791ce0973b0b9a6780b Mon Sep 17 00:00:00 2001 From: Anil Madhavapeddy Date: Mon, 3 Nov 2014 18:24:51 +0000 Subject: [PATCH 2/4] regen oasis --- _tags | 49 +++++++------ myocamlbuild.ml | 88 ++++++++++++---------- setup.ml | 191 ++++++++++++++++++++++++++++-------------------- 3 files changed, 189 insertions(+), 139 deletions(-) diff --git a/_tags b/_tags index 9f2b1e6..1bc8b45 100644 --- a/_tags +++ b/_tags @@ -1,8 +1,9 @@ # OASIS_START -# DO NOT EDIT (digest: f3e306cb3822f9fd188eb6bf627dd3ca) +# DO NOT EDIT (digest: 87e2609bb063ea0c0d4d7f9df6cc22d2) # Ignore VCS directories, you can use the same kind of rule outside # OASIS_START/STOP if you want to exclude directories that contains # useless stuff for the build process +true: annot, bin_annot <**/.svn>: -traverse <**/.svn>: not_hygienic ".bzr": -traverse @@ -54,29 +55,29 @@ : pkg_xenstore.unix : pkg_xenstore_transport : pkg_xenstore_transport.unix -: pkg_cmdliner -: pkg_cohttp -: pkg_cohttp.lwt -: pkg_io-page.unix -: pkg_lwt -: pkg_lwt.unix -: pkg_nbd -: pkg_nbd.lwt -: pkg_re.str -: pkg_sha -: pkg_sha.sha1 -: pkg_tapctl -: pkg_tar -: pkg_threads -: pkg_uri -: pkg_vhd-format -: pkg_vhd-format.lwt -: pkg_xcp -: pkg_xenstore -: pkg_xenstore.client -: pkg_xenstore.unix -: pkg_xenstore_transport -: pkg_xenstore_transport.unix +: pkg_cmdliner +: pkg_cohttp +: pkg_cohttp.lwt +: pkg_io-page.unix +: pkg_lwt +: pkg_lwt.unix +: pkg_nbd +: pkg_nbd.lwt +: pkg_re.str +: pkg_sha +: pkg_sha.sha1 +: pkg_tapctl +: pkg_tar +: pkg_threads +: pkg_uri +: pkg_vhd-format +: pkg_vhd-format.lwt +: pkg_xcp +: pkg_xenstore +: pkg_xenstore.client +: pkg_xenstore.unix +: pkg_xenstore_transport +: pkg_xenstore_transport.unix : custom # OASIS_STOP : syntax_camlp4o, pkg_cstruct.syntax diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 2c4086c..5c380d4 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,5 +1,5 @@ (* OASIS_START *) -(* DO NOT EDIT (digest: 5a9a2168dcb86db37476d58b8c0e25b3) *) +(* DO NOT EDIT (digest: 2b686a81cec9fb16d1640bda36a68fbd) *) module OASISGettext = struct (* # 22 "src/oasis/OASISGettext.ml" *) @@ -249,6 +249,9 @@ module MyOCamlbuildFindlib = struct *) open Ocamlbuild_plugin + type conf = + { no_automatic_syntax: bool; + } (* these functions are not really officially exported *) let run_and_read = @@ -315,7 +318,7 @@ module MyOCamlbuildFindlib = struct (* This lists all supported packages. *) let find_packages () = - List.map before_space (split_nl & run_and_read "ocamlfind list") + List.map before_space (split_nl & run_and_read (exec_from_conf "ocamlfind" ^ " list")) (* Mock to list available syntaxes. *) @@ -338,7 +341,7 @@ module MyOCamlbuildFindlib = struct ] - let dispatch = + let dispatch conf = function | After_options -> (* By using Before_options one let command line options have an higher @@ -357,31 +360,39 @@ module MyOCamlbuildFindlib = struct * -linkpkg *) flag ["ocaml"; "link"; "program"] & A"-linkpkg"; - (* For each ocamlfind package one inject the -package option when - * compiling, computing dependencies, generating documentation and - * linking. *) - List.iter - begin fun pkg -> - let base_args = [A"-package"; A pkg] in - (* TODO: consider how to really choose camlp4o or camlp4r. *) - let syn_args = [A"-syntax"; A "camlp4o"] in - let args = - (* Heuristic to identify syntax extensions: whether they end in - ".syntax"; some might not. - *) - if Filename.check_suffix pkg "syntax" || - List.mem pkg well_known_syntax then - syn_args @ base_args - else - base_args - in - flag ["ocaml"; "compile"; "pkg_"^pkg] & S args; - flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args; - flag ["ocaml"; "doc"; "pkg_"^pkg] & S args; - flag ["ocaml"; "link"; "pkg_"^pkg] & S base_args; - flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args; - end - (find_packages ()); + if not (conf.no_automatic_syntax) then begin + (* For each ocamlfind package one inject the -package option when + * compiling, computing dependencies, generating documentation and + * linking. *) + List.iter + begin fun pkg -> + let base_args = [A"-package"; A pkg] in + (* TODO: consider how to really choose camlp4o or camlp4r. *) + let syn_args = [A"-syntax"; A "camlp4o"] in + let (args, pargs) = + (* Heuristic to identify syntax extensions: whether they end in + ".syntax"; some might not. + *) + if Filename.check_suffix pkg "syntax" || + List.mem pkg well_known_syntax then + (syn_args @ base_args, syn_args) + else + (base_args, []) + in + flag ["ocaml"; "compile"; "pkg_"^pkg] & S args; + flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args; + flag ["ocaml"; "doc"; "pkg_"^pkg] & S args; + flag ["ocaml"; "link"; "pkg_"^pkg] & S base_args; + flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args; + + (* TODO: Check if this is allowed for OCaml < 3.12.1 *) + flag ["ocaml"; "compile"; "package("^pkg^")"] & S pargs; + flag ["ocaml"; "ocamldep"; "package("^pkg^")"] & S pargs; + flag ["ocaml"; "doc"; "package("^pkg^")"] & S pargs; + flag ["ocaml"; "infer_interface"; "package("^pkg^")"] & S pargs; + end + (find_packages ()); + end; (* Like -package but for extensions syntax. Morover -syntax is useless * when linking. *) @@ -546,12 +557,13 @@ module MyOCamlbuildBase = struct (* When ocaml link something that use the C library, then one need that file to be up to date. + This holds both for programs and for libraries. *) - dep ["link"; "ocaml"; "program"; tag_libstubs lib] - [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)]; + dep ["link"; "ocaml"; tag_libstubs lib] + [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)]; - dep ["compile"; "ocaml"; "program"; tag_libstubs lib] - [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)]; + dep ["compile"; "ocaml"; tag_libstubs lib] + [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)]; (* TODO: be more specific about what depends on headers *) (* Depends on .h files *) @@ -580,25 +592,27 @@ module MyOCamlbuildBase = struct () - let dispatch_default t = + let dispatch_default conf t = dispatch_combine [ dispatch t; - MyOCamlbuildFindlib.dispatch; + MyOCamlbuildFindlib.dispatch conf; ] end -# 594 "myocamlbuild.ml" +# 606 "myocamlbuild.ml" open Ocamlbuild_plugin;; let package_default = {MyOCamlbuildBase.lib_ocaml = []; lib_c = []; flags = []; includes = []} ;; -let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;; +let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false} + +let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;; -# 603 "myocamlbuild.ml" +# 617 "myocamlbuild.ml" (* OASIS_STOP *) Ocamlbuild_plugin.dispatch dispatch_default;; diff --git a/setup.ml b/setup.ml index ccace23..72a7c09 100644 --- a/setup.ml +++ b/setup.ml @@ -1,9 +1,9 @@ (* setup.ml generated for the first time by OASIS v0.4.1 *) (* OASIS_START *) -(* DO NOT EDIT (digest: d7888717af93507d2b920945abe7a19d) *) +(* DO NOT EDIT (digest: 2c5236e7682df1e6a576d732359fbfa0) *) (* - Regenerated by OASIS v0.4.4 + Regenerated by OASIS v0.4.5 Visit http://oasis.forge.ocamlcore.org for more information and documentation about functions used in this file. *) @@ -242,11 +242,9 @@ module OASISString = struct let replace_chars f s = - let buf = String.make (String.length s) 'X' in - for i = 0 to String.length s - 1 do - buf.[i] <- f s.[i] - done; - buf + let buf = Buffer.create (String.length s) in + String.iter (fun c -> Buffer.add_char buf (f c)) s; + Buffer.contents buf end @@ -1729,6 +1727,13 @@ module OASISFeatures = struct (fun () -> s_ "Allows the OASIS section comments and digest to be omitted in \ generated files.") + + let no_automatic_syntax = + create "no_automatic_syntax" alpha + (fun () -> + s_ "Disable the automatic inclusion of -syntax camlp4o for packages \ + that matches the internal heuristic (if a dependency ends with \ + a .syntax or is a well known syntax).") end module OASISUnixPath = struct @@ -2099,16 +2104,6 @@ module OASISLibrary = struct lst in - (* The headers that should be compiled along *) - let headers = - if lib.lib_pack then - [] - else - find_modules - lib.lib_modules - "cmi" - in - (* The .cmx that be compiled along *) let cmxs = let should_be_built = @@ -2134,12 +2129,32 @@ module OASISLibrary = struct [] in + (* The headers and annot/cmt files that should be compiled along *) + let headers = + let sufx = + if lib.lib_pack + then [".cmti"; ".cmt"; ".annot"] + else [".cmi"; ".cmti"; ".cmt"; ".annot"] + in + List.map + begin + List.fold_left + begin fun accu s -> + let dot = String.rindex s '.' in + let base = String.sub s 0 dot in + List.map ((^) base) sufx @ accu + end + [] + end + (find_modules lib.lib_modules "cmi") + in + (* Compute what libraries should be built *) let acc_nopath = (* Add the packed header file if required *) let add_pack_header acc = if lib.lib_pack then - [cs.cs_name^".cmi"] :: acc + [cs.cs_name^".cmi"; cs.cs_name^".cmti"; cs.cs_name^".cmt"] :: acc else acc in @@ -2499,13 +2514,13 @@ module OASISFindlib = struct in let library_name_of_findlib_name = - Lazy.lazy_from_fun - (fun () -> - (* Revert findlib_name_of_library_name. *) - MapString.fold - (fun k v mp -> MapString.add v k mp) - fndlb_name_of_lib_name - MapString.empty) + lazy begin + (* Revert findlib_name_of_library_name. *) + MapString.fold + (fun k v mp -> MapString.add v k mp) + fndlb_name_of_lib_name + MapString.empty + end in let library_name_of_findlib_name fndlb_nm = try @@ -2875,7 +2890,7 @@ module OASISFileUtil = struct end -# 2878 "setup.ml" +# 2893 "setup.ml" module BaseEnvLight = struct (* # 22 "src/base/BaseEnvLight.ml" *) @@ -2980,7 +2995,7 @@ module BaseEnvLight = struct end -# 2983 "setup.ml" +# 2998 "setup.ml" module BaseContext = struct (* # 22 "src/base/BaseContext.ml" *) @@ -5391,7 +5406,7 @@ module BaseSetup = struct end -# 5394 "setup.ml" +# 5409 "setup.ml" module InternalConfigurePlugin = struct (* # 22 "src/plugins/internal/InternalConfigurePlugin.ml" *) @@ -5827,6 +5842,17 @@ module InternalInstallPlugin = struct lst in + let make_fnames modul sufx = + List.fold_right + begin fun sufx accu -> + (String.capitalize modul ^ sufx) :: + (String.uncapitalize modul ^ sufx) :: + accu + end + sufx + [] + in + (** Install all libraries *) let install_libs pkg = @@ -5847,27 +5873,29 @@ module InternalInstallPlugin = struct OASISHostPath.of_unix bs.bs_path in List.fold_left - (fun acc modul -> - try - List.find - OASISFileUtil.file_exists_case - (List.map - (Filename.concat path) - [modul^".mli"; - modul^".ml"; - String.uncapitalize modul^".mli"; - String.capitalize modul^".mli"; - String.uncapitalize modul^".ml"; - String.capitalize modul^".ml"]) - :: acc - with Not_found -> - begin - warning - (f_ "Cannot find source header for module %s \ - in library %s") - modul cs.cs_name; - acc - end) + begin fun acc modul -> + begin + try + [List.find + OASISFileUtil.file_exists_case + (List.map + (Filename.concat path) + (make_fnames modul [".mli"; ".ml"]))] + with Not_found -> + warning + (f_ "Cannot find source header for module %s \ + in library %s") + modul cs.cs_name; + [] + end + @ + List.filter + OASISFileUtil.file_exists_case + (List.map + (Filename.concat path) + (make_fnames modul [".annot";".cmti";".cmt"])) + @ acc + end acc lib.lib_modules in @@ -5915,27 +5943,29 @@ module InternalInstallPlugin = struct OASISHostPath.of_unix bs.bs_path in List.fold_left - (fun acc modul -> - try - List.find - OASISFileUtil.file_exists_case - (List.map - (Filename.concat path) - [modul^".mli"; - modul^".ml"; - String.uncapitalize modul^".mli"; - String.capitalize modul^".mli"; - String.uncapitalize modul^".ml"; - String.capitalize modul^".ml"]) - :: acc - with Not_found -> - begin - warning - (f_ "Cannot find source header for module %s \ - in object %s") - modul cs.cs_name; - acc - end) + begin fun acc modul -> + begin + try + [List.find + OASISFileUtil.file_exists_case + (List.map + (Filename.concat path) + (make_fnames modul [".mli"; ".ml"]))] + with Not_found -> + warning + (f_ "Cannot find source header for module %s \ + in object %s") + modul cs.cs_name; + [] + end + @ + List.filter + OASISFileUtil.file_exists_case + (List.map + (Filename.concat path) + (make_fnames modul [".annot";".cmti";".cmt"])) + @ acc + end acc obj.obj_modules in @@ -6240,7 +6270,7 @@ module InternalInstallPlugin = struct end -# 6243 "setup.ml" +# 6273 "setup.ml" module OCamlbuildCommon = struct (* # 22 "src/plugins/ocamlbuild/OCamlbuildCommon.ml" *) @@ -6298,6 +6328,11 @@ module OCamlbuildCommon = struct else []; + if bool_of_string (tests ()) then + ["-tag"; "tests"] + else + []; + if bool_of_string (profile ()) then ["-tag"; "profile"] else @@ -6613,7 +6648,7 @@ module OCamlbuildDocPlugin = struct end -# 6616 "setup.ml" +# 6651 "setup.ml" open OASISTypes;; let setup_t = @@ -6638,7 +6673,7 @@ let setup_t = alpha_features = []; beta_features = []; name = "vhd-tool"; - version = "0.7.5"; + version = "0.7.6"; license = OASISLicense.DEP5License (OASISLicense.DEP5Unit @@ -6724,7 +6759,7 @@ let setup_t = FindlibPackage ("uri", None); FindlibPackage ("cohttp", - Some (OASISVersion.VGreaterEqual "0.10.0")); + Some (OASISVersion.VGreaterEqual "0.12.0")); FindlibPackage ("cohttp.lwt", None); FindlibPackage ("tar", None); FindlibPackage ("sha", None); @@ -6770,7 +6805,7 @@ let setup_t = FindlibPackage ("uri", None); FindlibPackage ("cohttp", - Some (OASISVersion.VGreaterEqual "0.10.0")); + Some (OASISVersion.VGreaterEqual "0.12.0")); FindlibPackage ("cohttp.lwt", None); FindlibPackage ("xenstore", None); FindlibPackage ("xenstore.client", None); @@ -6804,8 +6839,8 @@ let setup_t = plugin_data = [] }; oasis_fn = Some "_oasis"; - oasis_version = "0.4.4"; - oasis_digest = Some "q­\027¼ì\155ÖÇ6\023\152ÅÄ.\142e"; + oasis_version = "0.4.5"; + oasis_digest = Some "®¿\030¹´f\159=a\004rf_êk8"; oasis_exec = None; oasis_setup_args = []; setup_update = false @@ -6813,6 +6848,6 @@ let setup_t = let setup () = BaseSetup.setup setup_t;; -# 6817 "setup.ml" +# 6852 "setup.ml" (* OASIS_STOP *) let () = setup ();; From 5e483989a315008054c52b5b1e88ced3b47361d0 Mon Sep 17 00:00:00 2001 From: David Scott Date: Tue, 4 Nov 2014 22:55:46 +0000 Subject: [PATCH 3/4] Update to Cohttp.0.12.0 API This is the API in [mirage/ocaml-cohttp#196] Signed-off-by: David Scott --- src/impl.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/impl.ml b/src/impl.ml index b91f912..2f94477 100644 --- a/src/impl.ml +++ b/src/impl.ml @@ -689,14 +689,14 @@ let write_stream common s destination source_protocol destination_protocol preze | Some x -> begin match Re_str.bounded_split_delim (Re_str.regexp_string ":") x 2 with | [ user; pass ] -> - let b = Cohttp.Auth.string_of_resp (`Basic (user, pass)) in + let b = Cohttp.Auth.string_of_credential (`Basic (user, pass)) in Header.add headers "authorization" b | _ -> Printf.fprintf stderr "I don't know how to handle authentication for this URI.\n Try scheme://user:password@host/path\n"; exit 1 end in let request = Cohttp.Request.make ~meth:`PUT ~version:`HTTP_1_1 ~headers uri' in - Request.write (fun t _ -> return ()) request c >>= fun () -> + Request.write (fun _ -> return ()) request c >>= fun () -> Response.read (Cohttp_unbuffered_io.make_input c) >>= fun r -> begin match r with | `Invalid x -> fail (Failure (Printf.sprintf "Invalid HTTP response: %s" From 408960d1e04ee95db43d4549e2abcb58b67e7e71 Mon Sep 17 00:00:00 2001 From: David Scott Date: Wed, 5 Nov 2014 11:05:18 +0000 Subject: [PATCH 4/4] Add opam file Signed-off-by: David Scott --- opam | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 opam diff --git a/opam b/opam new file mode 100644 index 0000000..e437325 --- /dev/null +++ b/opam @@ -0,0 +1,27 @@ +opam-version: "1" +maintainer: "dave.scott@eu.citrix.com" +tags: [ + "org:mirage" + "org:xapi-project" +] +build: [ + ["./configure" "--bindir=%{bin}%"] + [make] + [make "install"] +] +remove: [[make "uninstall"]] +depends: [ + "ocamlfind" + "lwt" {>= "2.4.3"} + "cstruct" {>= "1.0.1"} + "vhd-format" {>= "0.7.0"} + "uuidm" + "cmdliner" + "nbd" {>= "1.0.1"} + "ounit" + "uri" + "tar-format" + "sha" + "cohttp" {>="0.12.0"} + "ssl" +]