[RFC] No opam , version constraints for packages of unikernels#82
[RFC] No opam , version constraints for packages of unikernels#82hannesm wants to merge 4 commits intomirage:masterfrom
Conversation
|
opam output for mirage-console: |
|
Woah, awesome! |
|
That's awesome, thanks for having a look at this. I am not totally convinced by the |
|
glad that you point out the weak bits:
|
|
this has been updated, and I think it is more or less good now... I don't know much about the pp in Functoria_app (and what it should print now, see comment), and also don't have a clue whether we need better errors (and in which way) instead of invalid_arg if the version number is not a list of numbers etc... I addressed @samoht concerns: (changed to feedback welcome! |
|
I really like generating random names for the opam files (when it is not provided by the user). I find it quite nice in docker. And I really want to have my |
|
instead of random, why not deterministic (hash over all the provided configuration keys?) |
|
I updated the mirage bits mirage/mirage#691, and mirage/mirage-skeleton#198 will not compile (unless using all these branches and rewriting the CI scripts slightly) |
eaa7a74 to
07d974a
Compare
|
is better now, still questions are open: what should |
|
@Drup I'm interested in your opinion here (and maybe you have answers to the 2 questions I raised in my previous comment). |
Drup
left a comment
There was a problem hiding this comment.
I like that work a lot, well done. I reviewed the changes and made various comments.
I'm not extremely convinced by the usage of a String.Map for packages, but the implementation make sense, you probably want to add a quick comment in the ml file as to why it's done that way (to make merging of packages easy).
As for your question about invalid_arg ... I think it's ok. It's really the right thing to raise here, and no need to sugar coat it with fancy cmdliner error handling.
| additional sublibraries (e.g. [~sublibs:["mirage"] "foo"] will result in the | ||
| findlib names [ ["foo"; "foo.mirage"] ]. In case the findlib name is | ||
| disjoint (or empty), use [~ocamlfind]. Version constraints are given as | ||
| [min] (inclusive) and [max] (exclusive). *) |
There was a problem hiding this comment.
Please specify that using ocamlfind with sublib is an error.
lib/functoria.mli
Outdated
| @@ -120,8 +150,6 @@ val foreign: | |||
| {ul | |||
| {- If [packages] is set, then the given OPAM packages are | |||
There was a problem hiding this comment.
"given packages", not only OPAM packages anymore.
app/functoria_command_line.mli
Outdated
| no_opam: bool; | ||
| no_depext: bool; | ||
| no_opam_version: bool | ||
| result: 'a |
There was a problem hiding this comment.
Are we removing this record ? Keeping it make adding some argument back convenient, but ...
lib/functoria.ml
Outdated
| let name = match name with None -> t.name | Some x -> x in | ||
| Fmt.pf ppf "opam-version: \"1.2\"@." ; | ||
| Fmt.pf ppf "name: \"%s\"@." name ; | ||
| Fmt.pf ppf "depends: [ @[<2>%a@]@ ]@." |
lib/functoria.ml
Outdated
| | None -> String.Map.add n p m | ||
| | Some p' -> match Package.merge p.opam p p' with | ||
| | Some p -> String.Map.add n p m | ||
| | None -> invalid_arg "bad constraints") |
There was a problem hiding this comment.
We should provide a better error message (and in particular, which opam package triggers the conflict).
lib/functoria.ml
Outdated
| let package_names t = | ||
| List.map fst | ||
| (List.filter (fun (_, p) -> p.build = false) | ||
| (String.Map.bindings t.packages)) |
There was a problem hiding this comment.
I feel like you should move that stuff to the Package module, and keep only Info.package.
There was a problem hiding this comment.
no. The Info record keeps track of a compilation unit, which contain a map of packages. The package module does only care about a single package.
There was a problem hiding this comment.
Meh, Package is the module that deals with packages. You want something from package list to the list of ocamlfind libraries (resp. opam packages), I feel like it would belong there.
| @[<v 2>packages = %a@]@ ;@ @[<v 2>libraries = %a@]@ }" | ||
| module_name (Info.name i) | ||
| pp_packages (Info.packages i) | ||
| pp_packages (Info.package_names i) |
There was a problem hiding this comment.
pp_dump_info is used to expose the content of Info to the underlying unikernel, in order to do things like an unikernel that lists the packages and the version it uses. It dumps an ml files with placeholder like %{functoria:version}% and then call opam config subst to substitute them.
That probably won't really work well anymore, so we need to move opam config subst to the "make depend" target.
Since you have a bit more information now, we could enrich the datastructure in functoria-runtime with packages and dump that.
- contains opam name, ocamlfind names, version constraints, flag whether build-only dependency - users provide lists of packages - is combined into a single map (including merging of version numbers if possible) Also provide, based on this, to print an opam file (well, the good parts - name and dependencies)
- get rid of type 'a result - add vertical box in depends output - move logic of libraries and package_names to Package module - improve error messages
|
this is now pretty-printing a bit prettier (comment on the pr with magic open boxes etc. if you'd like to improve): thing left is the info stuff drup explained above... this will need more thinking and integration into the build phase (but i guess it is ok to have it partially broken for some time)... |
|
I'm pretty happy with the last batch of changes. We just need to fix |
|
superseeded by #84 |
I played around a bit... so instead of having
~packages:string list ~libraries:string list, why not have aPackage.ttype and use that (package : ?ocamlfind:[ `Prefix of string list | `Full of string list ] -> ?min:string -> ?max:string -> string -> t)turns out, it is possible... but there are layering violations in mirage (expecting that during configure phase packages are already installed). the goal here is to just generate an
opamfile frommirage configure, and let someone else install dependencies before invokingmakesee mirage/mirage#691
feedback welcome @samoht @Drup @yomimono @avsm