FIX Map dep_maps with pins

The pins are based on the values in deps, however deps_maps allows for
transforming dependency names into package names.  This means pins do
not work properly because the names they refer to will not show up in
the opam package.  This adds the pins based on the actual dependency
name to the list of pins if an existing pin does not exist.

This does not handle if a deps_map values has different pins in it.
Only the first one is taken and added to pins and pins cannot be
combined.  This might be an issue but unclear what it looks like int
real code.
2 files changed, 20 insertions(+), 2 deletions(-)

M hll.conf
M src/hll/hll.ml
M hll.conf +1 -1
@@ 7,7 7,7 @@ homepage = "https://bitbucket.org/mimiro
 bug_reports = "https://bitbucket.org/mimirops/hll/issues"
 dev_repo = "git@bitbucket.org:mimirops/hll.git"
 
-url_template = "https://bitbucket.org/mimirops/hll/get/{tag}.tar.gz"
+url_template = "http://acsl-pkgs.s3.amazonaws.com/hll-{tag}.tar.gz"
 url_pattern = "{tag}"
 url_protocol = "http"
 

          
M src/hll/hll.ml +19 -1
@@ 22,7 22,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 (default hll.pins)" in
+      let doc = "Path to file containing pins" in
       C.Arg.(value & opt (some file) None & info ["pins"] ~docv:"FILE" ~doc)
     in
     let hll_conf =

          
@@ 174,9 174,27 @@ module Generate = struct
       test_deps
       pins
 
+  let map_pins_to_dep_map deps_map pins =
+    ListLabels.fold_left
+      ~f:(fun pins (k, v) ->
+          let k = TomlTypes.Table.Key.to_string k in
+          let xs = TomlLenses.(get v (array |-- strings)) in
+          match (String_map.get k pins, xs) with
+            | (Some _, _)
+            | (_, Some [])
+            | (_, None) ->
+              pins
+            | (None, Some (x::_)) when String_map.mem x pins ->
+              String_map.add k (String_map.find x pins) pins
+            | (None, _) ->
+              pins)
+      ~init:pins
+      (TomlTypes.Table.bindings deps_map)
+
   let generate_pkg_content t =
     let pins =
       t.pins
+      |> map_pins_to_dep_map t.deps_map
       |> maybe_add_pds_pin t.pds_version
       |> maybe_add_test_pins t.test_deps
     in