-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue #56 Follow-up and credit to @alexconrey (PR #55), @ericlchen1 (PR #64) and @benmccown (PR #67) for their work on similar PRs that I've reviewed and drawn some inspiration to create "one 💍 PR to merge them all" 😅 Problem: Debian has two types of repos: "canonical" and "flat". Each has a different sources.list syntax: "canonical": ``` deb uri distribution [component1] [component2] [...] ``` (see https://wiki.debian.org/DebianRepository/Format#Overview) flat: ``` deb uri directory/ ``` (see https://wiki.debian.org/DebianRepository/Format#Flat_Repository_Format) A flat repository does not use the dists hierarchy of directories, and instead places meta index and indices directly into the archive root (or some part below it) Thus, the URL logic in _fetch_package_index() is incorrect for these repos and it always fails to fetch the Package index. Solution: Just use the Debian sources.list convention in the 'sources' section of the manifest to add canonical and flat repos. Depending on whether the channel has one directory that ends in '/' or a (dist, component, ...) structure the _fetch_package_index and other internal logic will know whether the source is a canonical or a flat repo. For example: ``` version: 1 sources: # canonical repo - channel: bullseye main contrib url: https://snapshot-cloudflare.debian.org/archive/debian/20240210T223313Z # flat repos, note the trailing '/' and the lack of distribution or components - channel: bullseye-cran40/ url: https://cloud.r-project.org/bin/linux/debian - channel: ubuntu2404/x86_64/ url: https://developer.download.nvidia.com/compute/cuda/repos archs: - amd64 packages: - bash - r-mathlib - nvidia-container-toolkit-base ``` Disregarding the "mixing" of Ubuntu and Debian repos for the purpose of the example, this manifest shows that you can mix canonical and flat repos and you can mix multiarch and single-arch flat repos and canonical repos. You will still have the same problems as before with packages that only exist for one architecture and/or repos that only support one architecture. In those cases, simply separate the repos and packages into their own manifests. NOTE: The NVIDIA CUDA repos don't follow Debian specs and have issues with the package filenames. This is addressed in a separate commit.
- Loading branch information
Showing
7 changed files
with
139 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
load("@container_structure_test//:defs.bzl", "container_structure_test") | ||
load("@rules_distroless//apt:defs.bzl", "dpkg_status") | ||
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_load") | ||
|
||
PACKAGES = [ | ||
"@bullseye//dpkg", | ||
"@bullseye//apt", | ||
"@bullseye_rproject//r-mathlib", | ||
] | ||
|
||
# Creates /var/lib/dpkg/status with installed package information. | ||
dpkg_status( | ||
name = "dpkg_status", | ||
controls = [ | ||
"%s/amd64:control" % package | ||
for package in PACKAGES | ||
], | ||
) | ||
|
||
oci_image( | ||
name = "apt", | ||
architecture = "amd64", | ||
os = "linux", | ||
tars = [ | ||
":dpkg_status", | ||
] + [ | ||
"%s/amd64" % package | ||
for package in PACKAGES | ||
], | ||
) | ||
|
||
oci_load( | ||
name = "tarball", | ||
image = ":apt", | ||
repo_tags = [ | ||
"distroless/test:latest", | ||
], | ||
) | ||
|
||
container_structure_test( | ||
name = "test", | ||
configs = ["test_linux_amd64.yaml"], | ||
image = ":apt", | ||
target_compatible_with = [ | ||
"@platforms//cpu:x86_64", | ||
"@platforms//os:linux", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"packages": { | ||
"r-mathlib": { | ||
"amd64": { | ||
"arch": "amd64", | ||
"dependencies": [], | ||
"name": "r-mathlib", | ||
"sha256": "cbe3abbcc74261f2ad84159b423b856c1a0b4ebe6fef2de763d8783ff00245d5", | ||
"url": "https://cloud.r-project.org/bin/linux/debian/bullseye-cran40/r-mathlib_4.4.1-1~bullseyecran.0_amd64.deb", | ||
"version": "4.4.1-1~bullseyecran.0" | ||
} | ||
} | ||
}, | ||
"version": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Packages for examples/debian_flat_repo. | ||
# | ||
# Anytime this file is changed, the lockfile needs to be regenerated. | ||
# | ||
# To generate the bullseye_rproject.lock.json run the following command | ||
# | ||
# bazel run @bullseye_rproject//:lock | ||
# | ||
# See debian_package_index at WORKSPACE.bazel | ||
version: 1 | ||
|
||
sources: | ||
- channel: bullseye-cran40/ | ||
url: https://cloud.r-project.org/bin/linux/debian | ||
|
||
archs: | ||
- amd64 | ||
|
||
packages: | ||
- r-mathlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
schemaVersion: "2.0.0" | ||
|
||
commandTests: | ||
- name: "apt list --installed" | ||
command: "apt" | ||
args: ["list", "--installed"] | ||
expectedOutput: | ||
- Listing\.\.\. | ||
- r-mathlib/now 4.4.1-1~bullseyecran.0 amd64 \[installed,local\] |