bazel: provide runtime dependencies of libvirt where needed

This adds nix store paths to container images that have binaries linking
against libvirt from nix.
This commit is contained in:
Malte Poll 2023-11-23 17:43:01 +01:00
parent 361b409eb2
commit fb735419ac
2 changed files with 16 additions and 5 deletions

View File

@ -67,7 +67,9 @@ oci_image(
entrypoint = ["/start.sh"],
os = "linux",
tars = [
"//rpm:containerized-libvirt",
# TODO(malt3): test if libvirt works before merging this change!!!
"@libvirt_x86_64-linux//:closure.tar",
"@libvirt_x86_64-linux//:bin-linktree.tar",
":start",
],
visibility = ["//visibility:public"],

View File

@ -2,6 +2,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@rules_oci//oci:defs.bzl", "oci_image")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("//bazel/go:platform.bzl", "platform_binary")
load("//bazel/patchelf:patchelf.bzl", "patchelf")
go_library(
name = "qemu-metadata-api_lib",
@ -29,18 +30,26 @@ go_binary(
platform_binary(
name = "qemu_metadata_api_linux_amd64",
platform = "@zig_sdk//libc_aware/platform:linux_amd64_gnu.2.23",
platform = "//bazel/platforms:constellation_os",
target_file = ":qemu-metadata-api",
visibility = ["//visibility:public"],
)
patchelf(
name = "qemu_metadata_api_patched",
src = ":qemu_metadata_api_linux_amd64",
out = "qemu_metadata_api_with_nix_rpath",
interpreter = "@libvirt_x86_64-linux//:dynamic-linker",
rpath = "@libvirt_x86_64-linux//:rpath",
)
pkg_tar(
name = "layer",
srcs = [
":qemu_metadata_api_linux_amd64",
":qemu_metadata_api_patched",
],
mode = "0755",
remap_paths = {"/platform:linux_amd64_gnu.2.23": "/server"},
remap_paths = {"/qemu_metadata_api_with_nix_rpath": "/server"},
)
oci_image(
@ -49,7 +58,7 @@ oci_image(
entrypoint = ["/server"],
os = "linux",
tars = [
"//rpm:libvirt-devel",
"@libvirt_x86_64-linux//:closure.tar",
":layer",
],
visibility = ["//visibility:public"],