Skip to content

Commit

Permalink
Resolve symlinks when copying in rabbitmqctl.bzl
Browse files Browse the repository at this point in the history
(cherry picked from commit ca70275)
(cherry picked from commit cabae34)
(cherry picked from commit c65238a)
  • Loading branch information
HoloRin authored and mergify[bot] committed May 2, 2024
1 parent 30d03d9 commit 82091b2
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions deps/rabbitmq_cli/rabbitmqctl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ ElixirAppInfo = provider(
},
)

def _copy(ctx, src, dst):
ctx.actions.run_shell(
inputs = [src],
outputs = [dst],
command = """set -euo pipefail
cp -RL "{src}" "{dst}"
""".format(
src = src.path,
dst = dst.path,
),
)

def deps_dir_contents(ctx, deps, dir):
files = []
for dep in deps:
Expand All @@ -51,15 +64,7 @@ def deps_dir_contents(ctx, deps, dir):
lib_info.app_name,
rp,
))
args = ctx.actions.args()
args.add(src)
args.add(f)
ctx.actions.run(
inputs = [src],
outputs = [f],
executable = "cp",
arguments = [args],
)
_copy(ctx, src, f)
files.append(f)
for beam in lib_info.beam:
if not beam.is_directory:
Expand All @@ -69,15 +74,7 @@ def deps_dir_contents(ctx, deps, dir):
"ebin",
beam.basename,
))
args = ctx.actions.args()
args.add(beam)
args.add(f)
ctx.actions.run(
inputs = [beam],
outputs = [f],
executable = "cp",
arguments = [args],
)
_copy(ctx, beam, f)
files.append(f)
else:
fail("unexpected directory in", lib_info)
Expand Down

0 comments on commit 82091b2

Please sign in to comment.