Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix symlinks
  • Loading branch information
thesayyn committed Mar 10, 2026
commit 604ac6deb3bdd9614728cb007f1eb2d079ffde3e
12 changes: 7 additions & 5 deletions apt/private/deb_cc_export.bzl → apt/private/deb_export.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

TAR_TOOLCHAIN_TYPE = "@tar.bzl//tar/toolchain:type"

def _apt_cursed_symlink(ctx):
def _deb_export_impl(ctx):
bsdtar = ctx.toolchains[TAR_TOOLCHAIN_TYPE]

for (i, target) in ctx.attr.foreign_symlinks.items():
Expand All @@ -28,7 +28,10 @@ def _apt_cursed_symlink(ctx):
)
ctx.actions.run(
executable = bsdtar.tarinfo.binary,
inputs = ctx.files.srcs,
# the archive may contain symlinks that point to symlinks that reference
# files from other packages, therefore symlink_outs must be present in the
# sandbox for Bazel to succesfully track them.
inputs = ctx.files.srcs + ctx.outputs.symlink_outs,
outputs = ctx.outputs.outs,
arguments = [args],
mnemonic = "Unpack",
Expand All @@ -43,11 +46,10 @@ def _apt_cursed_symlink(ctx):
),
)

deb_cc_export = rule(
implementation = _apt_cursed_symlink,
deb_export = rule(
implementation = _deb_export_impl,
attrs = {
"srcs": attr.label_list(allow_files = True),
"deps": attr.label_list(allow_files = True),
# mapping of symlink_outs indice to a foreign label
"foreign_symlinks": attr.string_keyed_label_dict(allow_files = True),
"symlink_outs": attr.output_list(),
Expand Down
6 changes: 3 additions & 3 deletions apt/private/deb_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load(":util.bzl", "util")
# BUILD.bazel template
_DEB_IMPORT_BUILD_TMPL = '''
load("@rules_distroless//apt/private:deb_postfix.bzl", "deb_postfix")
load("@rules_distroless//apt/private:deb_cc_export.bzl", "deb_cc_export")
load("@rules_distroless//apt/private:deb_export.bzl", "deb_export")
load("@rules_distroless//apt/private:apt_cursed_symlink.bzl", "apt_cursed_symlink")
load("@rules_cc//cc/private/rules_impl:cc_import.bzl", "cc_import")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
Expand All @@ -34,8 +34,8 @@ filegroup(
)


deb_cc_export(
name = "cc_export",
deb_export(
name = "export",
srcs = glob(["data.tar*"]),
foreign_symlinks = {foreign_symlinks},
symlink_outs = {symlink_outs},
Expand Down