patchelf --add-needed libX Y && patchelf --add-needed libX Y will add libX twice. The same goes for patchelf --add-rpath.
It would be very handy if there were a way to enable patchelf to only make additions when the requested NEEDED/RPATH is not already present.
Ordering matters for both of these, so this feature would likely only come into effect for duplicates that would otherwise have a lower precedence than an existing entry.
This feature could be added numerous ways:
patchelf --add-needed libX --add-rpath /path/y --uniq-needed --uniq-rpaths Z
This would be strictly more general than merely making --add-needed/--add-rpath idempotent, but it would achieve the goal.
(Indeed, --shrink-rpath probably has this effect, but it cannot be used when the RPATH contains directories that don't exist yet.)
A more granular option could be:
patchelf --add-needed-idempotent libX Z
Obviously this functionality can be achieved with a few calls to patchelf --print-needed/patchelf --print-rpath along with some tr and awk. But that's also true of many features (e.g. --add-rpath could be implemented in terms of --print-rpath and --set-rpath) and I think it's probably the semantics people mean when they say --add-needed etc. It's also just much more convenient for patchelf to do it, while also more efficient.
patchelf --add-needed libX Y && patchelf --add-needed libX Y
will addlibX
twice. The same goes forpatchelf --add-rpath
.It would be very handy if there were a way to enable
patchelf
to only make additions when the requested NEEDED/RPATH is not already present.Ordering matters for both of these, so this feature would likely only come into effect for duplicates that would otherwise have a lower precedence than an existing entry.
This feature could be added numerous ways:
This would be strictly more general than merely making
--add-needed
/--add-rpath
idempotent, but it would achieve the goal.(Indeed,
--shrink-rpath
probably has this effect, but it cannot be used when the RPATH contains directories that don't exist yet.)A more granular option could be:
Obviously this functionality can be achieved with a few calls to
patchelf --print-needed
/patchelf --print-rpath
along with sometr
andawk
. But that's also true of many features (e.g.--add-rpath
could be implemented in terms of--print-rpath
and--set-rpath
) and I think it's probably the semantics people mean when they say--add-needed
etc. It's also just much more convenient forpatchelf
to do it, while also more efficient.