Created
November 23, 2018 12:40
-
-
Save mseri/b0d28a9c56303ac17580da9b494a68ce to your computer and use it in GitHub Desktop.
Upgrade all opam files in the folder to opam2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* requires opam-format and opam-state *) | |
let opam_files = | |
Sys.readdir "." | |
|> Array.to_list | |
|> List.filter (fun l -> match String.split_on_char '.' l with | _ :: ["opam"] -> true | _ -> false) | |
;; | |
let make_opam_file fname = | |
fname |> OpamFilename.of_string |> OpamFile.make | |
;; | |
let real_opam_files = | |
opam_files | |
|> List.map (make_opam_file) | |
|> List.map (OpamFile.OPAM.read) | |
;; | |
let upgraded_real_opam_files = | |
real_opam_files | |
|> List.map OpamFormatUpgrade.opam_file_from_1_2_to_2_0 | |
;; | |
let () = | |
upgraded_real_opam_files | |
|> List.combine opam_files | |
|> List.iter (fun (fname, content) -> | |
let opamfile = make_opam_file fname in | |
OpamFile.OPAM.write opamfile content | |
) | |
;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment