Up

module Cudf

: sig

CUDF library

CUDF documents
#
type package = {
# package
: Cudf_types.pkgname;
# version
: Cudf_types.version;
# depends
: Cudf_types.vpkgformula;
# conflicts
: Cudf_types.vpkglist;
# provides
: Cudf_types.veqpkglist;
# installed
: bool;
# was_installed
: bool;
# keep
: Cudf_types.enum_keep;
# pkg_extra
: Cudf_types.typed_value Cudf_types.stanza;
}

Representation of a parsed package description item.

With this representation, optional properties have already been expanded to their default values (if they have one). It is not possible to know whether they were present or not in the CUDF syntax.

#
val (=%) : package -> package -> bool

package equality up to <name, version> i.e. 2 packages are equal iff they have the same name and version

#
val (<%) : package -> package -> int

Package comparison up to <name, version>. Same rules of package equality, but providing a suitable replacement for Pervasives.compare; useful for sorting.

#
val (>%) : package -> package -> int

Same as Cudf.(<%), but sort with greater versions first.

#
type request = {
# request_id
: string;
# install
: Cudf_types.vpkglist;
# remove
: Cudf_types.vpkglist;
# upgrade
: Cudf_types.vpkglist;
# req_extra
: Cudf_types.typed_value Cudf_types.stanza;
}
#
type preamble = {
# preamble_id
: string;(*text following the "preamble: " postmark*)
# property
: Cudf_types.typedecl;(*extra property declarations*)
# univ_checksum
: string;(*universe checksum*)
# status_checksum
: string;(*status checksum*)
# req_checksum
: string;(*request checksum*)
}
#
val default_preamble : preamble

implement preamble defaults

#
val default_package : package

implement package defaults

#
val default_request : request

implement request defaults

Syntactic CUDF representation
#
type cudf_doc = preamble option * package list * request

a CUDF document with its information items

#
type cudf_item = [
| `Preamble of preamble
| `Package of package
| `Request of request
]

a single information item

Semantic CUDF representation
#
exception Constraint_violation of string

violation of a constraint imposed by CUDF specification

msg explanation of which constraint has been violated
#
type universe

package universe (including package status, i.e., installed packages)

#
type cudf = preamble * universe * request
#
type solution = preamble * universe

CUDF-based encoding of solutions, see CUDF 2.0, appendix B

A universe encoding a solution matters only for its installed packages, which are considered to be the resulting package status

#
val load_universe : package list -> universe

Raises Constraint_violation when a global CUDF constraint is violated in the given package list
#
val add_package : universe -> package -> unit

add a package to an existing universe. The universe is modified in place.

Raises Constraint_violation if a package with the same name and version is alreayd in the given universe
#
val remove_package : universe -> Cudf_types.pkgname * Cudf_types.version -> unit

remove a package from an existing universe. The universe is modified in place

CUDF manipulation
#
val lookup_package : universe -> Cudf_types.pkgname * Cudf_types.version -> package

Lookup a specific package via a <name, version> key

Raises Not_found if the requested package cannot be found
#
val mem_package : universe -> Cudf_types.pkgname * Cudf_types.version -> bool

Check existence of a specific package in the universe via a <name, version> key

#
val mem_installed : ?include_features:bool -> ?ignore:(package -> bool) -> universe -> Cudf_types.vpkg -> bool

check wheather a given package constraint is satisfied in a given package status (i.e., the universe subset of installed packages)

include_features allow constraint to be satisfied by features (i.e., Provides). Default: true
ignore make the lookup skip over all packages matching the given package predicate. Default: do not ignore any package
#
val who_provides : ?installed:bool -> universe -> Cudf_types.vpkg -> (package * Cudf_types.version option) list

Ask who provides a given feature (predicate).

installed : consider only installed packages (default)
Returns a list of packages providing the requested feature. Each package is paired with an optional version; if it is None, the given package provides all possible version of the feature; it if is Some v, the given package only provides version v of the feature.
#
val lookup_packages : ?filter:Cudf_types.constr -> universe -> Cudf_types.pkgname -> package list

lookup all available versions of a given package name

filter filter the found packages according to the given version constraint. Default: None (i.e., no filtering)
#
val get_installed : universe -> Cudf_types.pkgname -> package list

lookup all installed versions of a given package name. Shorthand for lookup_packages composed with filtering on installed=true

#
val uid_by_package : universe -> package -> int

return a unique integer identifier for the given package in the universe

Raises Not_found if the given package cannot be found in the universe
#
val package_by_uid : universe -> int -> package

return the package corresponding to the given unique identifier

Raises Not_found if no package in the universe corresponds to the given unique identifier
#
val iter_packages : (package -> unit) -> universe -> unit

iter over all packages in the universe

#
val fold_packages : ('a -> package -> 'a) -> 'a -> universe -> 'a

fold over all packages in the universe

#
val iteri_packages : (int -> package -> unit) -> universe -> unit

iter on all packages in the universe, passing to the iteration function both the package and its unique identifier

#
val iter_packages_by_name : (Cudf_types.pkgname -> package list -> unit) -> universe -> unit

iter on all packages grouped by name. Each package name is associated to a list of packages with the same name and different versions

#
val fold_packages_by_name : ('a -> Cudf_types.pkgname -> package list -> 'a) -> 'a -> universe -> 'a

fold on all packages grouped by name. Each package name is associated to a list of packages with the same name and different versions

#
val package_names : universe -> Cudf_types.pkgname list

return the list of all unique package names

#
val get_packages : ?filter:(package -> bool) -> universe -> package list

conversion from universe to plain package list

filter only return packages matching a given predicate. Default is to return all packages
#
val universe_size : universe -> int

total numer of available packages (no matter whether they are installed or not)

#
val installed_size : universe -> int

total number of installed packages occurring in the universe

#
val status : universe -> universe

Projection on packages having "installed: true".

Inefficient (involves Hashtbl.t cloning), use with care.

Low-level stanza manipulation
#
val lookup_package_property : package -> string -> string

low-level property lookup: given a package, lookup on it a property by name, returning its (pretty-printed, see [root:Cudf_types]) value as a string

pkg package to be inspected
property property name to be lookup (case-sensitive)
Raises Not_found if the given property name is not associated to the given package (note that "being associated with" does not necessarily mean that the property appears in the stanza, due to default values)
#
val lookup_request_property : request -> string -> string

Same as Cudf.lookup_package_property, but acting on request information items.

To lookup the request identifier as a string (which strictly speaking is not a property) you should lookup "request"

#
val lookup_preamble_property : preamble -> string -> string

Same as Cudf.lookup_package_property, but acting on preamble information items.

To lookup the preamble identifier as a string (which strictly speaking is not a property) you should lookup "preamble"

#
val lookup_typed_package_property : package -> string -> Cudf_types.typed_value

Same as Cudf.lookup_package_property, but return a typed value.

#
val lookup_typed_request_property : request -> string -> Cudf_types.typed_value

Same as Cudf.lookup_request_property, but return a typed value.

#
val lookup_typed_preamble_property : preamble -> string -> Cudf_types.typed_value

Same as Cudf.lookup_preamble_property, but return a typed value.

#
val lookup_package_typedecl : ?extra:Cudf_types.typedecl -> string -> Cudf_types.typedecl1

lookup the type declaration of a given property (either core or extra)

extras if given, list of extra package properties to consider when looking for the type declaration. When not given, which is the default, the lookup is performed only among core package properties
Note: lookup_typedecl name is not the same as List.assoc preamble.property name; only the former takes into account core package properties. See also [root:Cudf_conf].package_typedecl.
Raises Not_found if no declaration could be found for the given property
#
val version_matches : Cudf_types.version -> Cudf_types.constr -> bool

Check whether a version matches a version constraint, e.g. version_matches 1 (Some(`Eq, 2)) = false

#
val (|=) : Cudf_types.version -> Cudf_types.constr -> bool
end