package opam-lib

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

OPAM client state

module Types : sig ... end

Client state

type state = Types.t
module Cache : sig ... end

Caching of repository loading (marshall of all parsed opam files)

val load_state : ?save_cache:bool -> string -> OpamTypes.switch -> state

Load the client state. The string argument is to identify to call site.

val dump_state : state -> Pervasives.out_channel -> unit
val with_switch : OpamTypes.switch -> state -> state

Adjust the switch, compiler and switch_config in a partial state

val load_env_state : string -> OpamTypes.switch -> state

Load state associated to env variables. All other fields are left empty.

Create a universe from the current state

Environment

val get_full_env : force_path:bool -> ?opam:OpamFile.OPAM.t -> state -> OpamTypes.env

Get the current environment with OPAM specific additions. If force_path, the PATH is modified to ensure opam dirs are leading.

val get_opam_env : force_path:bool -> state -> OpamTypes.env

Get only environment modified by OPAM. If force_path, the PATH is modified to ensure opam dirs are leading.

val add_to_env : state -> ?opam:OpamFile.OPAM.t -> OpamTypes.env -> ?variables:OpamTypes.variable_contents option OpamVariable.Map.t -> (string * string * string) list -> OpamTypes.env

Update an environment.

val up_to_date_env : state -> bool

Check if the shell environment is in sync with the current OPAM switch

val eval_string : state -> string

The shell command to run by the user to set his OPAM environement (eval `opam config env`)

val print_env_warning_at_init : state -> OpamTypes.user_config -> unit

Print a warning if the environment is not set-up properly on init.

val print_env_warning_at_switch : state -> unit

Print a warning if the environment is not set-up properly on switch.

Initialisation

val update_setup_interactive : state -> OpamTypes.shell -> OpamTypes.filename -> bool

Update the global and user configuration by asking some questions.

val display_setup : state -> OpamTypes.shell -> OpamTypes.filename -> unit

Display the global and user configuration for OPAM.

val update_setup : state -> OpamTypes.user_config option -> OpamTypes.global_config option -> unit

Update the user configuration.

Filters

val global_variable_names : (string * string) list

Lists of available variables and their description

val package_variable_names : (string * string) list

Check for user-defined variable overwrite.

The main Filter.env value to be used to resolve variables in filters

Helpers

Return the OPAM file for the given package

val opam_opt : state -> OpamTypes.package -> OpamFile.OPAM.t option

Return the OPAM file for the given package

val url : state -> OpamTypes.package -> OpamFile.URL.t option

Return the URL file for the given package

Return the Descr file for the given package

val descr_opt : state -> OpamTypes.package -> OpamFile.Descr.t option

Return the Descr file for the given package

val files : state -> OpamTypes.package -> OpamTypes.dirname option

Return the files/ directory overlay for the given package

val compiler_comp : state -> OpamTypes.compiler -> OpamFile.Comp.t

Return the compiler description

Repositories

val string_of_repositories : OpamFile.Repo_config.t OpamTypes.repository_name_map -> string

Pretty print a map of repositories

val package_index : state -> (OpamTypes.repository_name * string option) OpamTypes.package_map

Builds a map which says in which repository the latest metadata for a given package are. The function respect the bustom priorities given by the order of priorities.

val compiler_index : state -> (OpamTypes.repository_name * string option) OpamTypes.compiler_map

Build a map which says in which repository the latest metadata for a given compiler is.

val sorted_repositories : state -> OpamTypes.repository list

Sort repositories by priority.

val mem_repository : state -> OpamTypes.repository_name -> bool

Check whether a repository exists.

Find a given repostiory. Exit the program if no such repository name exists.

val find_repository_opt : state -> OpamTypes.repository_name -> OpamTypes.repository option

Find a given repostiory.

val redirect : state -> OpamTypes.repository -> (OpamTypes.repository * OpamTypes.filter option) option

Check the redirections.

Compilers

val install_global_config : OpamTypes.dirname -> OpamTypes.switch -> OpamFile.Dot_config.t

(Re-)install the configuration for a given root and switch

val install_compiler : state -> quiet:bool -> OpamTypes.switch -> OpamTypes.compiler -> unit

Install the given compiler

val update_switch_config : state -> OpamTypes.switch -> state

Write the right compiler switch in ~/.opam/config

val is_compiler_installed : state -> OpamTypes.compiler -> bool

Is a compiler installed ?

val is_switch_installed : state -> OpamTypes.switch -> bool

Is a switch installed ?

Global compiler state

val compiler_repository_state : state -> OpamTypes.checksums OpamTypes.compiler_map

Repository state

val repository_and_prefix_of_compiler : state -> OpamTypes.compiler -> (OpamTypes.repository * string option) option

Return the active repository for a given compiler

Packages

val is_name_installed : state -> OpamTypes.name -> bool

Check whether a package name is installed

val is_package_installed : state -> OpamTypes.package -> bool

Return whether a package is installed

val find_installed_package_by_name : state -> OpamTypes.name -> OpamTypes.package

Return the installed package with the right name

val find_packages_by_name : state -> OpamTypes.name -> OpamTypes.package_set

Return all the packages with the given name

val packages_of_atoms : state -> OpamTypes.atom list -> OpamTypes.package_set

Return all packages satisfying one of the given atoms from a state

val get_package : state -> OpamTypes.name -> OpamTypes.package

Gets the current version of package name: pinned version, installed version, max available version or max existing version, tried in this order. Raises Not_found only if there is no package by this name.

Return a map from package names to package installed version

val static_base_packages : OpamTypes.name list

A few historical package names used as base for compilers (base-xxx)

val base_packages : state -> OpamTypes.package_set

Return the installed base packages of the current compiler

val base_package_names : state -> OpamTypes.name_set

Return the names of packages marked as "base" in the current compiler description

val all_installed : state -> OpamTypes.package_set

Return all the collection of installed packages, for all the available packages

val installed_versions : state -> OpamTypes.name -> OpamTypes.switch list OpamTypes.package_map

Return a map containing the switch where a given package is installed.

val installed_timestamp : state -> OpamTypes.name -> float

Returns a timestamp when the given package was last installed

val unknown_package : state -> OpamTypes.atom -> string

Returns a message about an atom that doesn't exist

val unavailable_reason : state -> OpamTypes.atom -> string

Returns an explanation why a package is not currently available

val download_archive : state -> OpamTypes.package -> OpamTypes.filename option OpamProcess.job

Download the OPAM-package archive ($name.$version+opam.tar.gz)

Download the upstream archive, add the eventual additional files and return the directory.

Global package state.

val package_partial_state : state -> OpamTypes.package -> archive:bool -> bool * OpamTypes.checksums

Global & partial package state.

val package_repository_state : state -> OpamTypes.checksums OpamTypes.package_map

Repository state

val package_repository_partial_state : state -> OpamTypes.package -> archive:bool -> bool * OpamTypes.checksums

Repository & partial package state.

val repository_of_package : state -> OpamTypes.package -> OpamTypes.repository option

Get the active repository for a given package

val repository_and_prefix_of_package : state -> OpamTypes.package -> (OpamTypes.repository * string option) option

Get the active repository for a given package

val add_to_reinstall : state -> all:bool -> OpamTypes.package_set -> unit

Add the given packages to the set of package to reinstall. If all is set, this is done for ALL the switches (useful when a package change upstream for instance). If not, only the reinstall state of the current switch is changed.

val copy_files : state -> OpamTypes.package -> OpamTypes.dirname -> unit

Return the files for a given package

val install_metadata : state -> OpamTypes.package -> unit

Copy the repository metadata into the global state.

val remove_metadata : state -> OpamTypes.package_set -> unit

Remove some metadata from the global state if they are not used anymore.

Development packages

val dev_packages : state -> OpamTypes.package_set

Get all the development packages. This include the one locally pinned (for the current switch) and the global dev packages.

val update_dev_packages : state -> OpamTypes.package_set -> OpamTypes.package_set

update_dev_packages t checks for upstream changes for packages first in the switch cache and then in the global cache. Return the packages whose contents have changed upstream. Side-effect: update the reinstall files.

val update_dev_package : state -> OpamTypes.package -> bool OpamProcess.job

Updates a dev or pinned package from its upstream; returns true if changed, false otherwise

val update_pinned_packages : state -> OpamTypes.name_set -> OpamTypes.package_set

A subset of update_dev_packages that only takes packages names and only works on pinned packages. Also updates reinstall files

val update_pinned_package : state -> ?fixed_version:OpamTypes.version -> OpamTypes.name -> bool OpamProcess.job

Updates a dev pinned package from its upstream; returns true if changed, false otherwise

val is_dev_package : state -> OpamTypes.package -> bool

Check whether a package is a development package

val find_opam_file_in_source : OpamTypes.name -> OpamTypes.dirname -> OpamTypes.filename option

Looks up an 'opam' file for the given named package in a source directory

Configuration files

val global_config : state -> OpamFile.Dot_config.t

Return the global .config file for the current switch

Return the .config file for the given package

Locks

val check : OpamTypes.lock -> unit

Apply a function while taking the right locks

Pinned packages

val is_pinned : state -> OpamTypes.name -> bool

Is the package name pinned ?

val is_locally_pinned : state -> OpamTypes.name -> bool

Is the package locally pinned ? (ie. not a version pinning)

Returns the versionned pinned package.

  • raises Not_found

    if not pinned

val pinned_opt : state -> OpamTypes.name -> OpamTypes.package option

Returns the versionned pinned package, or None if not pinned

val pinned_packages : state -> OpamTypes.package_set

The set of pinned packages in the state (warning: costly)

val url_of_locally_pinned_package : state -> OpamTypes.name -> OpamFile.URL.t

Return the URL file associated with a locally pinned package.

Overlays

val add_pinned_overlay : ?template:bool -> ?version:OpamTypes.version -> state -> OpamTypes.name -> unit

Add overlay files for a pinned package. If no definition is found use a minimal OPAM file unless template is set to true.

val remove_overlay : state -> OpamTypes.name -> unit

Remove all overlay files

System compilers

val create_system_compiler_description : OpamTypes.dirname -> unit

Create $opam/compilers/system.com. Takes the global root as argument.

val jobs : state -> int

Jobs

val dl_jobs : state -> int

Download Jobs

/ *

val switch_reinstall_hook : (OpamTypes.switch -> unit) Pervasives.ref

Switch reinstall hook.

val fix_descriptions_hook : (?save_cache:bool -> ?verbose:bool -> state -> unit) Pervasives.ref

Update hook