Upon trying to build for Ubuntu 24.04 - I'm running into an error when parsing the universe channel. It seems that the btm package (at minimum, I expect this to be a trend with other packages) are exporting package metadata which seemingly contain newlines.
I produced the following output from the most recent tag (v0.3.2.) I made the following change to a local checkout of rules_distroless to grab additional debugging information provided below:
rules_distroless$ git diff apt/private/package_index.bzl
diff --git a/apt/private/package_index.bzl b/apt/private/package_index.bzl
index 620a021..0649ad6 100644
--- a/apt/private/package_index.bzl
+++ b/apt/private/package_index.bzl
@@ -21,6 +21,7 @@ def _parse_package_index(state, contents, arch, root):
last_key = ""
pkg = {}
for group in contents.split("\n\n"):
+ print(group)
for line in group.split("\n"):
if line.strip() == "":
continue
I have been able to work around this by dropping X- package metadata when parsing the Packages.gz list, as follows:
diff --git a/apt/private/package_index.bzl b/apt/private/package_index.bzl
index 620a021..2bba704 100644
--- a/apt/private/package_index.bzl
+++ b/apt/private/package_index.bzl
@@ -28,6 +28,10 @@ def _parse_package_index(state, contents, arch, root):
pkg[last_key] += "\n" + line
continue
+ # Ignore package metadata, a newline/bad formatting of a package can break parsing
+ if line.startswith("X-"):
+ continue
+
(key, value) = line.split(": ", 1)
if not last_key and len(pkg) == 0 and key != "Package":
fail("do not expect this. fix it.")
$ bazel run --sandbox_debug --override_repository=rules_distroless=$HOME/git/alexconrey/rules_distroless @ubuntu_noble//:lock
DEBUG: /home/ubuntu/.cache/bazel/_bazel_ubuntu/c72e88c157bca566b19afcd933de7ae4/external/rules_distroless/apt/private/package_resolution.bzl:141:22: Warning: optional dependencies are not supported yet. https://github.com/GoogleContainerTools/rules_distroless/issues/27
DEBUG: /home/ubuntu/.cache/bazel/_bazel_ubuntu/c72e88c157bca566b19afcd933de7ae4/external/rules_distroless/apt/private/resolve.bzl:96:22: the following packages have unmet dependencies: awk
INFO: Analyzed target @@ubuntu_noble//:lock (90 packages loaded, 742 targets configured).
INFO: Found 1 target...
Target @@ubuntu_noble_resolution//:lock up-to-date:
bazel-bin/external/ubuntu_noble_resolution/lock
INFO: Elapsed time: 25.746s, Critical Path: 0.05s
INFO: 5 processes: 5 internal.
INFO: Build completed successfully, 5 total actions
INFO: Running command line: bazel-bin/external/ubuntu_noble_resolution/lock external/ubuntu_noble_resolution/lock.json
Writing lockfile to ubuntu/24.04/packages.lock.json
Run the following command to add the lockfile or pass --autofix flag to do it automatically.
buildozer set lock @@//ubuntu/24.04:packages.lock.json WORKSPACE.bazel:ubuntu_noble
Upon trying to build for Ubuntu 24.04 - I'm running into an error when parsing the
universe
channel. It seems that thebtm
package (at minimum, I expect this to be a trend with other packages) are exporting package metadata which seemingly contain newlines.I produced the following output from the most recent tag (v0.3.2.) I made the following change to a local checkout of
rules_distroless
to grab additional debugging information provided below:(
~/Downloads/Packages
-> https://mirror.d.umn.edu/ubuntu/dists/noble/universe/binary-amd64/Packages.gz -> untar)I have been able to work around this by dropping
X-
package metadata when parsing the Packages.gz list, as follows:My packages.yaml file is as follows:
I distilled this YAML file down to minimal components to debug this issue.