| 1 |
(**************************************************************************) |
| 2 |
(* *) |
| 3 |
(* Copyright 2012-2019 OCamlPro *) |
| 4 |
(* Copyright 2012 INRIA *) |
| 5 |
(* *) |
| 6 |
(* All rights reserved. This file is distributed under the terms of the *) |
| 7 |
(* GNU Lesser General Public License version 2.1, with the special *) |
| 8 |
(* exception on linking described in the file LICENSE. *) |
| 9 |
(* *) |
| 10 |
(**************************************************************************) |
| 11 |
|
| 12 |
(** The package type, and package name type (name+version, values often called |
| 13 |
"nv" in the code) *) |
| 14 |
|
| 15 |
(** {2 Package name and versions} *) |
| 16 |
|
| 17 |
(** Versions *) |
| 18 |
module Version: sig |
| 19 |
|
| 20 |
type t |
| 21 |
|
| 22 |
module Set : OpamStd.SET with type elt = t |
| 23 |
module Map : OpamStd.MAP with type key = t |
| 24 |
|
| 25 |
(** Compare two versions using the Debian version scheme *) |
| 26 |
val compare: t -> t -> int |
| 27 |
|
| 28 |
(** Are two package versions equal? *) |
| 29 |
val equal: t -> t -> bool |
| 30 |
|
| 31 |
(** Default version used when no version is given *) |
| 32 |
val default : t |
| 33 |
|
| 34 |
val to_string : t -> string |
| 35 |
val of_string : string -> t |
| 36 |
end |
| 37 |
|
| 38 |
(** Names *) |
| 39 |
module Name: sig |
| 40 |
include OpamStd.ABSTRACT |
| 41 |
|
| 42 |
(** Compare two package names *) |
| 43 |
val compare: t -> t -> int |
| 44 |
|
| 45 |
(** Are two package names equal? *) |
| 46 |
val equal: t -> t -> bool |
| 47 |
end |
| 48 |
|
| 49 |
type t = private { |
| 50 |
name: Name.t; |
| 51 |
version: Version.t; |
| 52 |
} |
| 53 |
|
| 54 |
(** Package (name x version) pairs *) |
| 55 |
include OpamStd.ABSTRACT with type t := t |
| 56 |
|
| 57 |
(** Return the package name *) |
| 58 |
val name: t -> Name.t |
| 59 |
|
| 60 |
(** Return None if [nv] is not a valid package name *) |
| 61 |
val of_string_opt: string -> t option |
| 62 |
|
| 63 |
(** Return the version name *) |
| 64 |
val version: t -> Version.t |
| 65 |
|
| 66 |
(** Create a new pair (name x version) *) |
| 67 |
val create: Name.t -> Version.t -> t |
| 68 |
|
| 69 |
(** To fit in the GenericPackage type, for generic display functions *) |
| 70 |
val name_to_string: t -> string |
| 71 |
val version_to_string: t -> string |
| 72 |
|
| 73 |
(** Guess the package name from a filename. This function extracts |
| 74 |
[name] and [version] from {i /path/to/$name.$version/opam}, or |
| 75 |
{i /path/to/$name.$version.opam} *) |
| 76 |
val of_filename: OpamFilename.t -> t option |
| 77 |
|
| 78 |
(** Guess the package name from a directory name. This function extracts {i |
| 79 |
$name} and {i $version} from {i /path/to/$name.$version/} *) |
| 80 |
val of_dirname: OpamFilename.Dir.t -> t option |
| 81 |
|
| 82 |
(** Guess the package name from an archive file. This function extract |
| 83 |
{i $name} and {i $version} from {i |
| 84 |
/path/to/$name.$version+opam.tar.gz} *) |
| 85 |
val of_archive: OpamFilename.t -> t option |
| 86 |
|
| 87 |
(** Convert a set of pairs to a map [name -> versions] *) |
| 88 |
val to_map: Set.t -> Version.Set.t Name.Map.t |
| 89 |
|
| 90 |
(** The converse of [to_map] *) |
| 91 |
val of_map: Version.Set.t Name.Map.t -> Set.t |
| 92 |
|
| 93 |
(** Returns the keys in a package map as a package set *) |
| 94 |
val keys: 'a Map.t -> Set.t |
| 95 |
|
| 96 |
(** Extract the versions from a collection of packages *) |
| 97 |
val versions_of_packages: Set.t -> Version.Set.t |
| 98 |
|
| 99 |
(** Return the list of versions for a given package *) |
| 100 |
val versions_of_name: Set.t -> Name.t -> Version.Set.t |
| 101 |
|
| 102 |
(** Extract the naes from a collection of packages *) |
| 103 |
val names_of_packages: Set.t -> Name.Set.t |
| 104 |
|
| 105 |
(** Returns true if the set contains a package with the given name *) |
| 106 |
val has_name: Set.t -> Name.t -> bool |
| 107 |
|
| 108 |
(** Return all the packages with the given name *) |
| 109 |
val packages_of_name: Set.t -> Name.t -> Set.t |
| 110 |
val packages_of_name_map: 'a Map.t -> Name.t -> 'a Map.t |
| 111 |
|
| 112 |
(** Return a package with the given name *) |
| 113 |
val package_of_name: Set.t -> Name.t -> t |
| 114 |
|
| 115 |
(** Return a package with the given name, if any *) |
| 116 |
val package_of_name_opt: Set.t -> Name.t -> t option |
| 117 |
|
| 118 |
(** Return all the packages with one of the given names *) |
| 119 |
val packages_of_names: Set.t -> Name.Set.t -> Set.t |
| 120 |
|
| 121 |
(** Removes all packages with the given name from a set of packages *) |
| 122 |
val filter_name_out: Set.t -> Name.t -> Set.t |
| 123 |
|
| 124 |
(** Return the maximal available version of a package name from a set. |
| 125 |
Raises [Not_found] if no such package available. *) |
| 126 |
val max_version: Set.t -> Name.t -> t |
| 127 |
|
| 128 |
(** Compare two packages *) |
| 129 |
val compare: t -> t -> int |
| 130 |
|
| 131 |
(** Are two packages equal? *) |
| 132 |
val equal: t -> t -> bool |
| 133 |
|
| 134 |
(** Hash a package *) |
| 135 |
val hash: t -> int |
| 136 |
|
| 137 |
(** Return all the package descriptions in a given directory *) |
| 138 |
val list: OpamFilename.Dir.t -> Set.t |
| 139 |
|
| 140 |
(** Return all the package descriptions in the current directory (and |
| 141 |
their eventual prefixes). *) |
| 142 |
val prefixes: OpamFilename.Dir.t -> string option Map.t |
| 143 |
|
| 144 |
(** {2 Errors} *) |