Portage outputs several bad substitution errors: /var/db/pkg/dev-cpp/sourcetrail-2018.3.13/NEEDED.ELF.2: $: bad substitution /var/db/pkg/dev-cpp/sourcetrail-2018.3.13/NEEDED.ELF.2: $: bad substitution This seems to be the same root cause as the following bug reports: #547520 #542796 But both bugs where closed stating that this is fixed in portage-2.2.19, but I am running portage-2.3.40-r1 and still see the problem. I have run into this issue while writing an ebuild for a binary package called Sourcetrail, see https://github.com/gentoo/gentoo/pull/9513 for details. In the ebuild I have used the workaround suggested in one of the bug reports above, but mgorny suggested to report this as a Portage bug, so here we go :) Reproducible: Always
Long story short, rpath contains $$ORIGIN (in addition to $ORIGIN).
It seems that $$ORIGIN is not resolved by ldd either. Test case with /opt/firefox/libxul.so from firefox-bin: > # cp -a /opt/firefox/libxul.so /opt/firefox/libxul_.so > # ldd /opt/firefox/libxul_.so | grep 'not found' > /opt/firefox/libxul_.so: /usr/lib64/libnss3.so: version `NSS_3.30' not found (required by /opt/firefox/libxul_.so) > libmozsandbox.so => not found > liblgpllibs.so => not found > libmozsqlite3.so => not found > libmozgtk.so => not found > # patchelf --set-rpath '$$ORIGIN' /opt/firefox/libxul_.so > # ldd /opt/firefox/libxul_.so | grep 'not found' > /opt/firefox/libxul_.so: /usr/lib64/libnss3.so: version `NSS_3.30' not found (required by /opt/firefox/libxul_.so) > libmozsandbox.so => not found > liblgpllibs.so => not found > libmozsqlite3.so => not found > libmozgtk.so => not found > # patchelf --set-rpath '$ORIGIN' /opt/firefox/libxul_.so > # ldd /opt/firefox/libxul_.so | grep 'not found' So $ORIGIN works with ldd, while $$ORIGIN does not. Portage behavior is consistent with ldd.
(In reply to David Hallas from comment #0) > I have run into this issue while writing an ebuild for a binary package > called Sourcetrail, see https://github.com/gentoo/gentoo/pull/9513 for > details. In the ebuild I have used the workaround suggested in one of the > bug reports above, but mgorny suggested to report this as a Portage bug, so > here we go :) The portage "bad substitution" message is valid and useful. You probably want the Sourcetrail ebuild to use patchelf as described in bug 542796, comment 41.
It would be nice to trigger a QA Notice for cases like this.
No, it wouldn't. There's no point in editing a lot of prebuilt files for the sake of removing harmless '$$ORIGIN'.
Portage uses $ORIGIN to resolve library dependencies for preserve-libs, so if the rpath contains $$ORIGIN instead then it can lead to inappropriately preserved libraries.
Not if it contains both $ORIGIN and $$ORIGIN, as it the result of working around buggy CMake behavior.
Okay, so we can silence the "bad substitution" warning for $$ORIGIN if rpath also contains $ORIGIN.
<[Arfrever]> zmedico: Re $ORIGIN : libc supports also $LIB (e.g. "lib" or "lib64") and $PLATFORM, but they are not expanded in Portage.
(In reply to Zac Medico from comment #9) > <[Arfrever]> zmedico: Re $ORIGIN : libc supports also $LIB (e.g. "lib" or > "lib64") and $PLATFORM, but they are not expanded in Portage. They're documented in the ld.so man page. Also see: https://sourceware.org/bugzilla/show_bug.cgi?id=4177 http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#shobj_dependencies
Is there any update on this? Can I help out in anyway? If you throw me some pointers I don't mind trying to fix this in portage, but I have never done portage changes before so I would need some guidance :) I guess I should keep the patchelf workaround in the ebuild for now? BTW: Here is the original rpath from the Sourcetrail binary: patchelf --print-rpath Sourcetrail $ORIGIN/lib/:$$ORIGIN/lib/:/opt/llvm/lib:/opt/boost/lib:/opt/qt5.10.1/lib
How about something like this: > diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh > index 34492e086..c131408ac 100755 > --- a/bin/misc-functions.sh > +++ b/bin/misc-functions.sh > @@ -245,2 +245,3 @@ install_qa_check() { > needed=${l%%;*}; l=${l#*;} > + needed=${needed//\$\$ORIGIN/\$ORIGIN} > echo "${obj} ${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED^
Hi Zac, thanks for the quick turn-around :D Your quick fix almost worked, it seems like this information ends up in the rpath variable and not the needed variable, so if I simply do rpath=${rpath//\$\$ORIGIN/\$ORIGIN} then the bad substitution error goes away. So would this be the way to fix this? If you want you can pull the ebuild from the pull request and play around with it, then can see what exactly ends up in the NEEDED.ELF.2 file. Or I can attach some before and after dumps if needed.
Silencing "bad substitution" warning is good idea (or better to replace it with a more informative warning). However Portage should not record the corrected value of RPATH into NEEDED.ELF.2 when actually installed executables / libraries still have broken value of RPATH.
Since SourceTrail was removed from Gentoo quite a while ago I am going to close this ticket.