Module OpamSystem

module OpamSystem: sig .. end
Low-level untyped system operations

exception Process_error of OpamProcess.result
Exception raised when subprocess fails
val process_error : OpamProcess.result -> 'a
raise Process_error
exception Internal_error of string
Exception raised when a computation in the current process fails.
val internal_error : ('a, unit, string, 'b) Pervasives.format4 -> 'a
Raise Internal_error
val with_tmp_dir : (string -> 'a) -> 'a
with_tmp_dir fn executes fn in a tempory directory
val copy : string -> string -> unit
copy src dst copies src to dst. Remove dst before the copy if it is a link.
val link : string -> string -> unit
link src dst links src to dst. Remove dst if it is a file, not a directory.
val real_path : string -> string
real_path p returns the real path associated to p: .. are expanded and relative paths become absolute.
val string_of_channel : Pervasives.in_channel -> string
Return the contents of a channel.
val read : string -> string
read filename returns the contents of filename
val write : string -> string -> unit
write filename contents write contents to filename
val remove : string -> unit
remove filename removes filename. Works whether filename is a file or a directory
val remove_file : string -> unit
remove_file filename removes filename. Works only for normal files (or also at least for symlinks)
val remove_dir : string -> unit
remove_dir filename removes filename. Works only for directory (not for symlinks or other files).
val chdir : string -> unit
Change the current working directory
val in_dir : string -> (unit -> 'a) -> 'a
in_dir dir fn evaluates fn in the directory dir
val files_with_links : string -> string list
files_with_links dir returns the files in the directory dir. Links simulating directory are ignored, others links are returned.
val rec_files : string -> string list
rec_files dir returns the list of all files in dir, recursively. Links behaving like directory are crossed.
val files : string -> string list
Return the list of files in the current directory.
val rec_dirs : string -> string list
rec_dirs dir return the list list of all directories recursively (going through symbolink links).
val dirs : string -> string list
Return the list of directories in the current directory.
val ocaml_version : string option Lazy.t
Return the version of the current OCaml compiler. If no OCaml compiler is present in the path, then it returns None.
val system_ocamlc_where : string option Lazy.t
Return the path where the system ocamlc library is installed
val system_ocamlc_version : string option Lazy.t
Return the version of the system compiler
val directories_with_links : string -> string list
directories_with_links dir returns the directories in the directory dir. Links pointing to directory are also returned.
type command = string list 
a command is a list of words
val command_exists : ?env:string array -> string -> bool
Test wether a command exists in the environment.
val command : ?verbose:bool ->
?env:string array ->
?name:string ->
?metadata:(string * string) list -> command -> unit
command cmd executes the command cmd in the correct OPAM environment.
val commands : ?verbose:bool ->
?env:string array ->
?name:string ->
?metadata:(string * string) list ->
?keep_going:bool -> command list -> unit
commands cmds executes the commands cmds in the correct OPAM environment. It stops whenever one command fails unless keep_going is set to true. In this case, the first error is re-raised at the end.
val read_command_output : ?verbose:bool ->
?env:string array ->
?metadata:(string * string) list -> command -> string list
read_command_output cmd executes the command cmd in the correct OPAM environment and return the lines from stdout if the command exists normally. If the command does not exist or if the command exited with a non-empty exit-code, throw an error.
val is_tar_archive : string -> bool
Test whether the file is an archive, by looking as its extension
val extract : string -> string -> unit
extract filename dirname extracts the archive filename into dirname. dirname should not exists and filename should contain only one top-level directory.
val extract_in : string -> string -> unit
extract_in filename dirname extracts the archive filename into dirname. dirname should already exists.
val mkdir : string -> unit
Create a directory. Do not fail if the directory already exist.

File locking function


val flock : string -> unit
flock () takes the global file lock. If the lock is already taken, sleep for 1s and then retry. Abort after 5 tentatives.
val funlock : string -> unit
funlock () unlocks the global file lock. Work only if the current processus is the same as the one who took the lock at the first place.

Misc


val download : overwrite:bool -> filename:string -> dst:string -> string
download compiler sources
val patch : string -> unit
Apply a patch file in the current directory.
val temp_file : ?dir:string -> string -> string
Create a tempory file in ~/.opam/logs/<name>XXX
val print_stats : unit -> unit
Print stats