bazeldnf
bazeldnf copied to clipboard
How to deal with alternatives?
How to handle alternatives?
In a minimal example that just depends on f37 binutils:
rpmtree(
name = "sandbox",
rpms = [
"@binutils-0__2.38-25.fc37.x86_64//rpm",
],
visibility = ["//visibility:public"],
)
.../usr/bin/ld
ends up being the GOLD linker:
$ .bazeldnf/sandbox/default/root/bin/ld --version
GNU gold (version 2.38-25.fc37) 1.16
In the binutils spec, BFD is the default through the alternatives mechanism: https://src.fedoraproject.org/rpms/binutils/blob/f36/f/binutils.spec#_455
A clean Fedora 37 container uses GNU ld by default even though binutils-gold is installed:
$ ld --version
GNU ld version 2.38-25.fc37
How can I replicate this using bazeldnf?
Our current workaround is to simply do it manually:
# Manually resolve alternatives (https://github.com/rmohr/bazeldnf/issues/28)
ln -r -s -f "${SANDBOX}/root/usr/bin/ld.bfd" "${SANDBOX}/root/usr/bin/ld"
symlinks can be directly set on the rpmtree
target like here: https://github.com/kubevirt/kubevirt/blob/a06915c634a6bc430dac02a8bc8bee048644bdcb/rpm/BUILD.bazel#L1377.