Skip to content

Commit

Permalink
Merge pull request #1731 from OCamlPro/convert_1_1
Browse files Browse the repository at this point in the history
Add an admin-script for 1.2 -> 1.1 opam file conversion
  • Loading branch information
AltGr committed Sep 17, 2014
2 parents 0eb1f4d + e459c2d commit c3f7ab1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions admin-scripts/to_1_1.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env opam-admin.top

#directory "+../opam-lib";;

(* Converts OPAM 1.2 packages for compat with OPAM 1.1
* merge 'install' with 'build'
* remove the new fields: install, flags and dev-repo
* remove dependency flags ('build', 'test', 'doc')
* set file version
*)

let to_1_1 _ opam =
let module OF = OpamFile.OPAM in
if
OpamVersion.compare (OF.opam_version opam) (OpamVersion.of_string "1.2")
< 0
then opam
else
let opam = OF.with_build opam (OF.build opam @ OF.install opam) in
let opam = OF.with_install opam [] in
let opam = OF.with_flags opam [] in
let opam = OF.with_dev_repo opam None in
let opam = OF.with_opam_version opam (OpamVersion.of_string "1.1") in
let remove_ext =
OpamFormula.map (fun (n, (_,formula)) ->
OpamFormula.Atom (n, ([], formula)))
in
let opam = OF.with_depends opam (remove_ext (OF.depends opam)) in
let opam = OF.with_depopts opam (remove_ext (OF.depopts opam)) in
opam
;;

Opam_admin_top.iter_packages ~opam:to_1_1 ()
1 change: 1 addition & 0 deletions src/core/opamFile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,7 @@ module X = struct
let flags t = t.flags
let dev_repo t = t.dev_repo

let with_opam_version t opam_version = { t with opam_version }
let with_name t name = { t with name = Some name }
let with_name_opt t name = { t with name }
let with_version t version = { t with version = Some version }
Expand Down
3 changes: 3 additions & 0 deletions src/core/opamFile.mli
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ module OPAM: sig
(** The package flags that are present for this package. *)
val flags: t -> package_flag list

(** Sets the opam version *)
val with_opam_version: t -> opam_version -> t

(** The package source repository address *)
val dev_repo: t -> pin_option option

Expand Down

0 comments on commit c3f7ab1

Please sign in to comment.