FIX Support opam 2.0
3 files changed, 40 insertions(+), 56 deletions(-)

M README.org
M pins.txt => hll.pins
M src/hll/hll.ml
M README.org +22 -20
@@ 6,25 6,25 @@ only option required is ~--opam-dir~.
 ** Variables
 The following variables can be set in ~hll.conf~.
 
-| Name                    | Required | Type        | Description                                                     |
-|-------------------------+----------+-------------+-----------------------------------------------------------------|
-| desc                    | yes      | string      | Description of the package                                      |
-| maintainer              | yes      | string      | The maintainer of the package                                   |
-| authors                 | yes      | string list | List of authors of the repo                                     |
-| homepage                | yes      | string      | Homepage of the repo                                            |
-| bug_reports             | no       | string      | Where bugs should be reported                                   |
-| dev_repo                | no       | string      | URL to where the source of the repo lives                       |
-| url_template            | yes      | string      | URL template to fetch the package                               |
-| url_pattern             | yes      | string      | Pattern to replace in the url template with the tag             |
-| url_protocol            | yes      | string      | Valid options are "git" and "http"                              |
-| available               | no       | string      | Adds an available section to the opam, surrounding [] are added |
-| build_deps              | no       | string list | List of deps needed to build the repo                           |
-| opam_extra_lines        | no       | string list | Add extra lines to the end of the opam                          |
-| deps_blacklist          | no       | string list | List of deps that should not be in the opam package             |
-| deps_map                | no       | table       | Table of package names and the pds deps that compose them       |
-| pds.major_version       | yes/no   | int         | The major version of pds the build depends on.                  |
-| pds.version             | yes/no   | string      | The opam string filter describing the version                   |
-| selector_map.<selector> | no       | string      | Map a selector in pds to a pin                                  |
+| Name                    | Required | Type        | Description                                                       |
+|-------------------------+----------+-------------+-------------------------------------------------------------------|
+| desc                    | yes      | string      | Description of the package                                        |
+| maintainer              | yes      | string      | The maintainer of the package                                     |
+| authors                 | yes      | string list | List of authors of the repo                                       |
+| homepage                | yes      | string      | Homepage of the repo                                              |
+| bug_reports             | no       | string      | Where bugs should be reported                                     |
+| dev_repo                | no       | string      | URL to where the source of the repo lives                         |
+| url_template            | yes      | string      | URL template to fetch the package                                 |
+| url_pattern             | yes      | string      | Pattern to replace in the url template with the tag               |
+| url_protocol            | yes      | string      | Valid options are "git" and "http"                                |
+| available               | no       | string      | Adds an available section to the opam, surrounding [] are added   |
+| build_deps              | no       | string list | List of deps needed by the repo, filers can be set with pins file |
+| opam_extra_lines        | no       | string list | Add extra lines to the end of the opam                            |
+| deps_blacklist          | no       | string list | List of deps that should not be in the opam package               |
+| deps_map                | no       | table       | Table of package names and the pds deps that compose them         |
+| pds.major_version       | yes/no   | int         | The major version of pds the build depends on.                    |
+| pds.version             | yes/no   | string      | The opam string filter describing the version                     |
+| selector_map.<selector> | no       | string      | Map a selector in pds to a pin                                    |
 
 Either the ~pds.major_version~ or ~pds.version~ are required but they are
 mutually exclusive.  This variable selects the ~pds~ version to use to build the

          
@@ 113,4 113,6 @@ set, is always right.
   dependencies, which is almost never what one wants.
 ** 2.10
 - Support selectors.
-
+** 3.11
+- Support opam 2.0 file format.
+- Change meaning of build_deps

          
M pins.txt => hll.pins +0 -3
@@ 1,4 1,1 @@ 
-cmdliner = "0.9.8"
-containers = "0.19"
-process = "0.2.0"
 toml >= "4"

          
M src/hll/hll.ml +18 -33
@@ 18,7 18,7 @@ module Cmdline = struct
       C.Arg.(value & opt (some string) None & info ["tag"] ~docv:"TAG" ~doc)
     in
     let pins_file =
-      let doc = "Path to file containing pins" in
+      let doc = "Path to file containing pins (default hll.pins)" in
       C.Arg.(value & opt (some file) None & info ["pins"] ~docv:"FILE" ~doc)
     in
     let hll_conf =

          
@@ 103,22 103,13 @@ module Generate = struct
            ; pds_version : Pds_version.t
            }
 
-  module Result = struct
-    type t = { opam_content : string
-             ; desc_content : string
-             ; url_content : string
-             }
-  end
-
-  let desc_file t = t.desc ^ "\n"
-
-  let url_file t =
+  let url_section t =
     let url =
       CCString.replace ~which:`Left ~sub:t.pattern ~by:t.tag t.url_template
     in
     match t.url_protocol with
       | Git ->
-        Printf.sprintf "git: \"%s\"\n" url
+        Printf.sprintf "\tsrc: \"%s\"\n" url
       | Http ->
         let lines = P.read_stdout "curl" [| "-L"; url |] in
         (*

          
@@ 128,7 119,7 @@ module Generate = struct
          *)
         let data = String.concat "\n" lines in
         let hex = Digest.string data |> Digest.to_hex in
-        Printf.sprintf "archive: \"%s\"\nchecksum: \"%s\"\n" url hex
+        Printf.sprintf "\tsrc: \"%s\"\n\tchecksum: \"%s\"" url hex
 
   let format_external_deps deps pins =
     List.map

          
@@ 178,7 169,7 @@ module Generate = struct
       test_deps
       pins
 
-  let opam_file t =
+  let generate_pkg_content t =
     let pins =
       t.pins
       |> maybe_add_pds_pin t.pds_version

          
@@ 217,14 208,11 @@ module Generate = struct
     let external_deps = format_external_deps output_deps pins in
     concat_nl
       (List.concat
-         [ [ "opam-version: \"1.2\""
+         [ [ "opam-version: \"2.0\""
            ; Printf.sprintf "maintainer: \"%s\"" t.maintainer
            ; "build: ["
            ; "\t[make \"-j%{jobs}%\"]"
-           ; "]"
-           ; ""
-           ; "build-test: ["
-           ; "\t[make \"-j%{jobs}%\" \"test\"]"
+           ; "\t[make \"-j%{jobs}%\" \"test\"] {with-test}"
            ; "]"
            ; ""
            ; "install: ["

          
@@ 243,20 231,22 @@ module Generate = struct
            ; "\t" ^ concat_nltab (format_authors (String_set.elements t.authors))
            ; "]"
            ; ""
+           ; "description: \"\"\""
+           ; t.desc
+           ; "\"\"\""
+           ; ""
            ; Printf.sprintf "homepage: \"%s\"" t.homepage
+           ; ""
+           ; "url {"
+           ; url_section t
+           ; "}"
            ]
          ; str_if_not_empty "bug-reports" t.bug_reports
          ; str_if_not_empty "dev-repo" t.dev_repo
          ; list_if_not_empty "available" t.available
          ; t.opam_extra_lines
          ; [""]
-      ])
-
-  let generate_pkg_content t =
-    Result.({ opam_content = opam_file t
-            ; desc_content = desc_file t
-            ; url_content = url_file t
-            })
+         ])
 end
 
 module Generate_io = struct

          
@@ 623,13 613,7 @@ module Generate_io = struct
     let base_pkg_dir = Filename.concat pkg_dir name in
     let base_dir = Filename.concat base_pkg_dir (Printf.sprintf "%s.%s" name tag) in
     mkdir_p base_dir;
-    List.iter
-      ~f:(fun (fname, content) ->
-          CCIO.with_out fname (CCFun.flip CCIO.write_line content))
-      ([ (Filename.concat base_dir "opam", contents.Generate.Result.opam_content)
-       ; (Filename.concat base_dir "url", contents.Generate.Result.url_content)
-       ; (Filename.concat base_dir "descr", contents.Generate.Result.desc_content)
-       ])
+    CCIO.with_out (Filename.concat base_dir "opam") (CCFun.flip CCIO.write_line contents)
 end
 
 let error_if_failed = function

          
@@ 647,6 631,7 @@ let maybe_load_tag = function
 
 let maybe_load_pins = function
   | Some file -> Generate_io.Pins.read file
+  | None when Sys.file_exists "hll.pins" -> Generate_io.Pins.read "hll.pins"
   | None -> Generate_io.Pins.empty
 
 (* TODO Clean up all the duplication *)