Files
60154f160d fix(rpm): set file colors on executable ELF files (#1155)
* fix(rpm): set file colors on executable ELF files

rpmbuild records a color for each file: 1 for 32-bit ELF objects, 2 for
64-bit ones, 0 otherwise. rpm uses these colors to let the 32-bit and
64-bit builds of a multilib package, e.g. foo.i686 and foo.x86_64, be
installed side by side: when both packages ship the same path, the
file of the preferred color wins instead of a file conflict. nfpm left
every file uncolored, so two architecture builds of the same package
that ship an ELF file at the same path conflicted.

Color regular files the way rpmbuild does: only executable files, and
only when the ELF header is one libelf accepts, i.e. complete, with a
valid byte order and version. The header is only read for executable
files.

Add a unit test covering 32-bit, 64-bit, non-executable, truncated and
invalid ELF files, a script and a symlink, an elfcolors acceptance test
that reads the colors back with rpm, and an ELF file in the srpm rebuild
acceptance test, which checks that rpmbuild --rebuild gives the same
color.

* fix(rpm): leave executable eBPF objects uncolored

Address the review feedback on #1152 by reading e_machine in the declared byte order and excluding EM_BPF from file colors. Cover both byte orders in the serialized FILECOLORS regression test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 0575e7ad-9af0-45bc-bc30-65b2298188a5
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

---------

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
Co-authored-by: Laurent Coustet <laurent.coustet@bluemind.net>
Copilot-Session: 0575e7ad-9af0-45bc-bc30-65b2298188a5
2026-10-12 17:07:22 +00:00

52 B