Commit 8235de2
authored
Fix edge-cases of virtual packages (#203)
This fixes some edge-cases with virtual packages resolution introduced
in #146
- Sometimes multiple versions of the same package are available, just
pick the most recent one
- Fix comparison in version_constraint
- Sometimes virtual packages are not in the arch folder
One way to reproduce this is to use the following manifest slightly
adapted from the examples folder to:
- add the curl package that will have several of the issues solved by
this patch
- bump the snapshot time
<details><summary>Example manifest</summary>
```
version: 1
sources:
- channel: noble main
url: https://snapshot.ubuntu.com/ubuntu/20250930T150000Z
- channel: noble-security main
url: https://snapshot.ubuntu.com/ubuntu/20250930T150000Z
- channel: noble-updates main
url: https://snapshot.ubuntu.com/ubuntu/20250930T150000Z
archs:
- "amd64"
- "arm64"
packages:
- "ncurses-base"
- "libncurses6"
- "tzdata"
- "bash"
- "coreutils" # for commands like `ls`
- "grep"
# for apt list --installed
- "dpkg"
- "apt"
- "perl"
- "curl"
```
</details>
This will build but you should see the following warning messages with the current main version:
```
DEBUG:
[cache]/external/rules_distroless+/apt/private/apt_dep_resolver.bzl:40:14:
Multiple candidates for virtual package 'libnettle8': ["libnettle8t64",
"libnettle8t64"]
DEBUG:
[cache]/external/rules_distroless+/apt/private/apt_dep_resolver.bzl:40:14:
Multiple candidates for virtual package 'libhogweed6':
["libhogweed6t64", "libhogweed6t64"]
WARNING: Following dependencies could not be resolved for curl:
libnettle8,libhogweed6,libgnutls30
DEBUG: [cache]/external/rules_distroless+/apt/extensions.bzl:27:26:
```
The first two are solved by picking whichever of the package has the most recent version.
For the `libgnutls30` issue reported here, I had to add some extra ouptut to figure things out. In this version of the snapshot, the package is required with a constraint `>= 3.8.1` and the packages available in the snapshot have versions `3.8.3-1.1ubuntu3` and `3.8.3-1.1ubuntu4`. They should both satisfy the constraint but because the operands are inverted they are rejected.
The last point is more peculiar. We saw this happen with the OpenVINO apt distribution (see [here](https://docs.openvino.ai/2025/get-started/install-openvino/install-openvino-apt.html)) but I think it's fairly reasonable to fallback to the all architecture just in case 🤔1 parent 8fe8488 commit 8235de2
2 files changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
37 | 47 | | |
38 | 48 | | |
39 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
0 commit comments