]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/tools/vcpkg/docs/users/versioning.implementation-details.md
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / tools / vcpkg / docs / users / versioning.implementation-details.md
1 # Versioning: Implementation details
2
3 **The latest version of this documentation is available on [GitHub](https://github.com/Microsoft/vcpkg/tree/master/docs/users/versioning.implementation-details.md).**
4
5 ## Contents
6
7 * [Minimum versioning](#minimum-versioning)
8 * [Constraint resolution](#constraint-resolution)
9 * [Acquiring port versions](#acquiring-port-versions)
10
11
12 ### Minimum versioning
13 Vcpkg uses a minimal selection approach to versioning, inspired by the one [used by Go](https://research.swtch.com/vgo-mvs). But modified in some ways:
14
15 * Always starts from a fresh install, eliminates the need for upgrade/downgrade operations.
16 * Allow unconstrained dependencies by introducing baselines.
17
18 The minimal selection principle, however, stays the same. Given a set of constraints, vcpkg will use the "oldest" possible versions of packages that can satisfy all the constraints.
19
20 Using a minimum version approach has the following advantages:
21 * Is predictable and easy to understand.
22 * User controls when upgrades happen, as in, no upgrades are performed automatically when a new version is released.
23 * Avoids using a SAT solver.
24
25 To give an example, consider the following package graph:
26 ```
27 (A 1.0) -> (B 1.0)
28
29 (A 1.1) -> (B 1.0)
30 -> (C 3.0)
31
32 (A 1.2) -> (B 2.0)
33 -> (C 3.0)
34
35 (C 2.0)
36 ```
37
38 And the following manifest:
39 ```
40 {
41 "name": "example",
42 "version": "1.0.0",
43 "dependencies": [
44 { "name": "A", "version>=": "1.1" },
45 { "name": "C", "version>=": "2.0" }
46 ],
47 "builtin-baseline": "<some git commit with A's baseline at 1.0>"
48 }
49 ```
50
51 After accounting for transitive dependencies we have the following set of constraints:
52 * A >= 1.1
53 * B >= 1.0
54 * C >= 3.0
55 * C >= 2.0
56
57 Since vcpkg has to satisfy all the constraints, the set of installed packages becomes:
58
59 * `A 1.1`, even when `A 1.2` exists, there are no constraints higher than `1.1` so vcpkg selects the minimum version possible.
60 * `B 1.0`, transitively required by `A 1.1`.
61 * `C 3.0`, upgraded by the transitive constraint added by `B 1.0` in order to satisfy version constraints.
62
63 ## Constraint resolution
64 Given a manifest with a set of versioned dependencies, vcpkg will attempt to calculate a package installation plan that satisfies all the constraints.
65
66 Version constraints come in the following flavors:
67 * **Declared constraints**: Constraints declared explicitly in the top-level manifest using `version>=`.
68 * **Baseline constraints**: Constraints added implicitly by the `builtin-baseline`.
69 * **Transitive constraints**: Constraints added indirectly by dependencies of your dependencies.
70 * **Overridden constraints**: Constraints overridden in the top-level manifest using `overrides` declarations.
71
72 To compute an installation plan, vcpkg follows roughly these steps:
73
74 * Add all top-level constraints to the plan.
75 * Recursively add transitive constraints to the plan.
76 * Each time a new package is added to the plan, also add its baseline constraint to the plan.
77 * Each time a constraint is added:
78 * If an override exists for the package
79 * Select the version in the override.
80 * Otherwise:
81 * If there is no previous version selected.
82 * Select the minimal version that satisfies the constraint.
83 * If there is a previous version selected:
84 * If the versioning scheme of the new constraint does not match that of the previously selected version:
85 * Add a version conflict.
86 * If the constraint's version is not comparable to the previously selected version. For example, comparing "version-string: apple" to "version-string: orange":
87 * Add a version conflict.
88 * If the constraints version is higher than the previously selected version:
89 * Select the highest version.
90 * Otherwise:
91 * Keep the previous selection.
92 * Review the plan:
93 * If there are no conflicts
94 * Install the selected packages
95 * Otherwise:
96 * Report the conflicts to the user
97
98 ## Acquiring port versions
99 Although the concept of package versions has always been present in vcpkg, the concept of version constraints has been not.
100
101 With the introduction of versioning constraints, it is now possible that a package depends on a port version that does not match the one available locally. This raises a problem as vcpkg needs to know how to acquire the port files for the requested version.
102
103 To solve this problem, a new set of metadata files was introduced. These files are located in the `versions/` directory at the root level of the vcpkg repository.
104
105 The `versions/` directory, will contain JSON files for each one of the ports available in the registry. Each file will list all the versions available for a package and contain a Git tree-ish object that vcpkg can check out to obtain that version's portfiles.
106
107 Example: `zlib.json`
108
109 ```
110 {
111 "versions": [
112 {
113 "git-tree": "2dfc991c739ab9f2605c2ad91a58a7982eb15687",
114 "version-string": "1.2.11",
115 "port-version": 9
116 },
117 ...
118 {
119 "git-tree": "a516e5ee220c8250f21821077d0e3dd517f02631",
120 "version-string": "1.2.10",
121 "port-version": 0
122 },
123 {
124 "git-tree": "3309ec82cd96d752ff890c441cb20ef49b52bf94",
125 "version-string": "1.2.8",
126 "port-version": 0
127 }
128 ]
129 }
130 ```
131
132 For each port, its corresponding versions file should be located in `versions/{first letter of port name}-/{port name}.json`. For example, zlib's version file will be located in `versions/z-/zlib.json`. Aside from port version files, the current baseline file is located in `versions/baseline.json`.
133
134