Skip to content

Commit

Permalink
refactor: bring deb_index on par with bzlmod api
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Nov 13, 2024
1 parent 6ccc030 commit c5bb79a
Show file tree
Hide file tree
Showing 11 changed files with 5,772 additions and 832 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ concurrency:

jobs:
test:
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@d76fcd39cb9e689104db71853e7c1f1053550463
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@8889dd1e94d2f85d52106c5ebc770b1cb83f4e41
with:
folders: |
[
Expand Down
56 changes: 56 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,65 @@ use_repo(bazel_lib_toolchains, "yq_linux_ppc64le")
use_repo(bazel_lib_toolchains, "yq_linux_s390x")
use_repo(bazel_lib_toolchains, "yq_windows_amd64")

# Dev dependencies
bazel_dep(name = "gazelle", version = "0.34.0", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "6.1.2", dev_dependency = True)
bazel_dep(name = "platforms", version = "0.0.10", dev_dependency = True)
bazel_dep(name = "rules_oci", version = "2.0.0-rc0", dev_dependency = True)
bazel_dep(name = "container_structure_test", version = "1.16.0", dev_dependency = True)

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "example-bullseye-ca-certificates",
build_file_content = 'exports_files(["data.tar.xz", "control.tar.xz"])',
sha256 = "b2d488ad4d8d8adb3ba319fc9cb2cf9909fc42cb82ad239a26c570a2e749c389",
urls = ["https://snapshot.debian.org/archive/debian/20231106T210201Z/pool/main/c/ca-certificates/ca-certificates_20210119_all.deb"],
)

http_archive(
name = "example-bullseye-libc-bin",
build_file_content = 'exports_files(["data.tar.xz"])',
sha256 = "8b048ab5c7e9f5b7444655541230e689631fd9855c384e8c4a802586d9bbc65a",
urls = ["https://snapshot.debian.org/archive/debian-security/20231106T230332Z/pool/updates/main/g/glibc/libc-bin_2.31-13+deb11u7_amd64.deb"],
)

http_archive(
name = "example-bookworm-libc-bin",
build_file_content = 'exports_files(["data.tar.xz"])',
sha256 = "38c44247c5b3e864d6db2877edd9c9a0555fc4e23ae271b73d7f527802616df5",
urls = ["https://snapshot.debian.org/archive/debian-security/20231106T230332Z/pool/updates/main/g/glibc/libc-bin_2.36-9+deb12u3_armhf.deb"],
)

apt = use_extension(
"@rules_distroless//apt:extensions.bzl",
"apt",
dev_dependency = True,
)
apt.install(
name = "bullseye",
lock = "//examples/debian_snapshot:bullseye.lock.json",
manifest = "//examples/debian_snapshot:bullseye.yaml",
)
apt.install(
name = "bullseye_nolock",
manifest = "//examples/debian_snapshot:bullseye_nolock.yaml",
nolock = True,
)
apt.install(
name = "apt_security",
manifest = "//examples/debian_snapshot_security:security.yaml",
nolock = True,
)
apt.install(
name = "shared_dependencies",
lock = "//examples/debian_shared_dependencies:bullseye.lock.json",
manifest = "//examples/debian_shared_dependencies:bullseye.yaml",
)
apt.install(
name = "noble",
lock = "//examples/ubuntu_snapshot:noble.lock.json",
manifest = "//examples/ubuntu_snapshot:noble.yaml",
)
use_repo(apt, "apt_security", "apt_security_resolve", "bullseye", "bullseye_nolock", "noble", "shared_dependencies")
6,427 changes: 5,693 additions & 734 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

Empty file added WORKSPACE
Empty file.
79 changes: 0 additions & 79 deletions WORKSPACE.bazel

This file was deleted.

6 changes: 3 additions & 3 deletions apt/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

exports_files([
"index.bzl",
"apt.bzl",
])

bzl_library(
Expand All @@ -15,8 +15,8 @@ bzl_library(
)

bzl_library(
name = "index",
srcs = ["index.bzl"],
name = "apt",
srcs = ["apt.bzl"],
visibility = ["//visibility:public"],
deps = [
"//apt/private:index",
Expand Down
6 changes: 5 additions & 1 deletion apt/index.bzl → apt/apt.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
load("//apt/private:index.bzl", _deb_package_index = "deb_package_index")
load("//apt/private:resolve.bzl", _deb_resolve = "deb_resolve")

def deb_index(
def _apt_install(
name,
manifest,
lock = None,
Expand Down Expand Up @@ -100,3 +100,7 @@ def deb_index(
lock = lock if lock else "@" + name + "_resolve//:lock.json",
package_template = package_template,
)

apt = struct(
install = _apt_install,
)
2 changes: 1 addition & 1 deletion docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ stardoc_with_diff_test(

stardoc_with_diff_test(
name = "apt",
bzl_library_target = "//apt:index",
bzl_library_target = "//apt:apt",
)

update_docs(name = "update")
18 changes: 9 additions & 9 deletions docs/apt.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e/smoke/.bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.0
7.0.0
6 changes: 3 additions & 3 deletions e2e/smoke/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ load("@rules_distroless//distroless:toolchains.bzl", "distroless_register_toolch

distroless_register_toolchains()

load("@rules_distroless//apt:index.bzl", "deb_index")
load("@rules_distroless//apt:apt.bzl", "apt")

# bazel run @bullseye//:lock
deb_index(
apt.install(
name = "bullseye",
lock = "@@//:bullseye.lock.json",
manifest = "//:bullseye.yaml",
Expand All @@ -63,7 +63,7 @@ load("@bullseye//:packages.bzl", "bullseye_packages")

bullseye_packages()

deb_index(
apt.install(
name = "bullseye_nolock",
manifest = "//:bullseye.yaml",
nolock = True,
Expand Down

0 comments on commit c5bb79a

Please sign in to comment.