package opam-state

  1. Overview
  2. Docs

Loading and querying a switch state

Loads the switch state and calls the given function on it, releasing the lock afterwards.

The repository state is automatically loaded if not provided.

The switch is selected, if not set, using OpamStateConfig.get_switch -- which can fail if no switch is configured.

Additionally, in case of a write lock, a backup is saved and a message is printed on restoring if f raised an exception and there were changes.

Creates a virtual state with all package available and nothing installed. Useful for querying and simulating actions when no switch is yet configured, or querying packages directly from the repos

Load the switch's state file, without constructing the package maps: much faster than loading the full switch state

Raw function to compute the availability of all packages, in opams, given the switch configuration and the set of pinned packages. (The result is precomputed in global_state.available_packages once the state is loaded)

Releases any locks on the given switch_state

Calls the provided function, ensuring a temporary write lock on the given switch state

Helpers to access state data

Returns the repositories configured in the current switch or, if none, the globally set default. highest priority first.

Return the OPAM file for the given package.

  • raises Not_found

    when appropriate

Return the OPAM file, including URL and descr, for the given package, if any

Return the URL file for the given package

Returns the primary URL from the URL file of the given package

Return the Descr file for the given package (or an empty descr if none)

Return the Descr file for the given package

Returns the full paths of overlay files under the files/ directory

Return the installed package's local configuration

val is_name_installed : 'a OpamStateTypes.switch_state -> OpamTypes.name -> bool

Check whether a package name is installed

val find_installed_package_by_name : 'a OpamStateTypes.switch_state -> OpamTypes.name -> OpamTypes.package

Return the installed package with the right name

  • raises Not_found

    when appropriate

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

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

val is_dev_package : 'a OpamStateTypes.switch_state -> OpamTypes.package -> bool

"dev packages" are any package with an upstream that isn't the usual HTTP, and without an archive checksum. These need to be updated from upstream independently when installed. It's generally only the case of source-pinned packages, but no rule enforces it in opam itself.

val is_pinned : 'a OpamStateTypes.switch_state -> OpamTypes.name -> bool

Checks if the given package name is pinned

val is_version_pinned : 'a OpamStateTypes.switch_state -> OpamTypes.name -> bool

Checks if the given package is version-pinned, i.e. pinned without overlay metadata, and relying on the repo's data

The set of all "dev packages" (see is_dev_package for a definition)

Returns the local source mirror for the given package (OpamPath.Switch.sources or OpamPath.Switch.pinned_package, depending on wether it's pinned).

conflicts_with st subset pkgs returns all packages declared in conflict with at least one element of subset within pkgs, through forward or backward conflict definition or common conflict-class. Packages in subset (all their versions) are excluded from the result.

val universe : 'a OpamStateTypes.switch_state -> ?test:bool -> ?doc:bool -> requested:OpamTypes.name_set -> OpamTypes.user_action -> OpamTypes.universe

Put the package data in a form suitable for the solver, pre-computing some maps and sets. Packages in the requested set are the ones that will get affected by the global build_test and build_doc flags. test and doc, if unspecified, are taken from OpamStateConfig.r

val dump_pef_state : 'a OpamStateTypes.switch_state -> Pervasives.out_channel -> unit

Dumps the current switch state in PEF format, for interaction with Dose tools

Updating

Sets the given opam file for the given package, updating the other related fields along the way

Removes the metadata associated to the given package, also updating the packages and available sets.

Like update_package_metadata, but also ensures the package is pinned to the given version. Also marks it for reinstall if changed.

Updates the selected repositories in the given switch (does not load the full switch state, but takes a transient write lock on the switch, so make sure not to hold other locks to avoid deadlocks). Sets the switch repositories in any case, even if unchanged from the defaults.

User interaction and reporting

val is_switch_globally_set : 'a OpamStateTypes.switch_state -> bool

Returns true if the switch of the state is the one set in $OPAMROOT/config, false otherwise. This doesn't imply that the switch is current w.r.t. either the process or the shell, for that you need to check OpamStateConfig.(!r.switch_from)

val not_found_message : 'a OpamStateTypes.switch_state -> OpamTypes.atom -> string

Returns a message about a package or version that couldn't be found

val unavailable_reason : 'a OpamStateTypes.switch_state -> (OpamTypes.name * OpamFormula.version_formula) -> string

Returns a printable explanation why a package is not currently available (pinned to an incompatible version, unmet available: constraints...).

OCaml

Innovation. Community. Security.