Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 265372 - sci-geosciences/googleearth-5.0.11337.1968_beta preserving /usr/lib/libicuuc.so.38.1 from dev-libs/icu due to using LD_LIBRARY_PATH as substitute for RPATH
Summary: sci-geosciences/googleearth-5.0.11337.1968_beta preserving /usr/lib/libicuuc....
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Julian Ospald
URL: http://blog.flameeyes.eu/2010/06/the-...
Whiteboard:
Keywords:
Depends on:
Blocks: 704320
  Show dependency tree
 
Reported: 2009-04-07 18:49 UTC by Martin von Gagern
Modified: 2020-01-05 08:01 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin von Gagern 2009-04-07 18:49:28 UTC
!!! existing preserved libs:
>>> package: dev-libs/icu-4.0.1
 *  - /usr/lib/libicuuc.so.38
 *  - /usr/lib/libicuuc.so.38.1
 *      used by /opt/googleearth/libevll.so
                  (x11-misc/googleearth-5.0.11337.1968_beta)

Googleearth provides its own copy of libicuuc.so in its own directory, as /opt/googleearth/libicuuc.so.38 , so there should be no need to preserve this lib system-wide for googleearth. Is there some kind of automatic lib preservation exclusion mechanism, like CONFIG_PROTECT_MASK for config files, so that packages can declare directories that shouldn't be checked?
Comment 1 Zac Medico gentoo-dev 2009-04-07 21:43:12 UTC
It's a flaw in the algorithm that decides what to preserve. There's no reason ebuilds should have to be aware of it. As a workaround, you can manually remove the preserved library.
Comment 2 Zac Medico gentoo-dev 2009-04-21 23:12:36 UTC
Actually, ldd reports that it links to /usr/lib/libicuuc.so.38.1, so I'm not quite sure how we're going to handle this. However, googleearth still appears to run if I move /usr/lib/libicuuc.so.38.1 to a temporary location, and lsof reports that "/opt/googleearth/libicuuc.so.38" is mapped into memory when googleearth is running. In this case, ldd reports "libicuuc.so.38 => not found". The RPATH doesn't provide a clue, since `scanelf -r /opt/googleearth/libevll.so` simply reports of bunch of paths that don't exist.
Comment 3 Martin von Gagern 2009-04-22 07:45:31 UTC
(In reply to comment #1)
> There's no reason ebuilds should have to be aware of it.

I was quite surprised when you wrote this. Seems there is no magic way out.

(In reply to comment #2)
> Actually, ldd reports that it links to /usr/lib/libicuuc.so.38.1,

To reproduce the environment as the googleearth wrapper script sets it up:
$ cd /opt/googleearth
$ LD_LIBRARY_PATH=. ldd libevll.so

> so I'm not quite sure how we're going to handle this.

I notice that for files like ./libminizip.so, the above is even different from a simple LD_LIBRARY_PATH=/opt/googleearth in some other working directory. For portage to reproduce this, it would need to know working directory and LD_LIBRARY_PATH modification. It would be easier to simply mask the whole googleeath package from library preservation, and rely on the dependencies stated in the ebuild to take care of everything.
Comment 4 SpanKY gentoo-dev 2009-04-24 23:33:19 UTC
there's no real way to push LD_LIBRARY_PATH hacks up into portage (nor do i think we should)

if the binary had RPATH of like $ORIGIN/../lib/, then it'd probably "just work" without any wrapper script
Comment 5 Vlastimil Babka (Caster) (RETIRED) gentoo-dev 2009-06-22 21:54:29 UTC
An idea that's also a hack but perhaps smaller - just check if the supposedly needed preserved file is part of the package itself? And maybe restrict that check to /opt only? Not sure how much is that tailored to this particular case, or how generally useful it could be, though.
Comment 6 Sebastian Luther (few) 2009-06-23 08:50:47 UTC
I havn't looked into the logic that decides what to preserve, but I see two problems. 

1) ldd reports things like "./libIGCore.so => not found". This can be solved by running ldd in the directory containing the lib. It then reports "./libIGCore.so (0xf77f4000)"

2) Portage needs to handle "./<library>"-cases correctly.
Comment 7 Martin von Gagern 2009-07-05 08:02:02 UTC
(In reply to comment #4)
> there's no real way to push LD_LIBRARY_PATH hacks up into portage (nor do i
> think we should)

I agree.

> if the binary had RPATH of like $ORIGIN/../lib/, then it'd probably "just
> work" without any wrapper script

Google Earth is closed source, so setting RPATH using linker flags is not an option. Should the googleearth ebuild use app-admin/chrpath to change the rpath of the binary before installing it? And if that works, get rid of the wrapper?

(In reply to comment #5)
> An idea that's also a hack but perhaps smaller - just check if the supposedly
> needed preserved file is part of the package itself?

You mean check by base name only, ignoring the directory? Hackish indeed, but sounds sensible nevertheless.
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-04-29 07:20:08 UTC

*** This bug has been marked as a duplicate of bug 215242 ***
Comment 9 Zac Medico gentoo-dev 2012-04-29 23:18:04 UTC
(In reply to comment #7)
> Google Earth is closed source, so setting RPATH using linker flags is not an
> option. Should the googleearth ebuild use app-admin/chrpath to change the
> rpath of the binary before installing it? And if that works, get rid of the
> wrapper?

That chrpath approach seems like an excellent solution.
Comment 10 Zac Medico gentoo-dev 2012-04-29 23:23:37 UTC
Considering that chrpath can potentially bug used to fix this bug, it is much different from the case(s) described in bug #215242.
Comment 11 Zac Medico gentoo-dev 2012-04-30 01:34:35 UTC
I've tried adding a line like this to googleearth-6.2.1.6014-r1.ebuild:

  chrpath -r /opt/googleearth ${PN}-bin gpsbabel *.so *.so.* || die

And it fails with the following error:

googleearth-bin: no rpath or runpath tag found.
gpsbabel: no rpath or runpath tag found.
libalchemyext.so: no rpath or runpath tag found.
libapiloader.so: no rpath or runpath tag found.
libauth.so: no rpath or runpath tag found.
libbase.so: no rpath or runpath tag found.
libbasicingest.so: no rpath or runpath tag found.
libcollada.so: no rpath or runpath tag found.
libcommon_gui.so: no rpath or runpath tag found.
libcommon_platform.so: no rpath or runpath tag found.
libcommon.so: no rpath or runpath tag found.
libcommon_webbrowser.so: no rpath or runpath tag found.
libcomponentframework.so: no rpath or runpath tag found.
libevll.so: no rpath or runpath tag found.
[SNIP]
Comment 12 Zac Medico gentoo-dev 2012-05-04 21:11:46 UTC
This seems to set the RPATH correctly:

	# Set RPATH for preserve-libs handling (bug #265372).
	local x
	for x in ${PN}-bin gpsbabel *.so *.so.* ; do
		patchelf --set-rpath /opt/${PN} ${x} || \
			die "patchelf failed on ${x}"
	done

However, scanelf no longer works with the binaries after they've been patched like this (tested with pax-utils-0.3.0 and 0.4). It just exits successfully and doesn't produce any output. The output of ldd shows it properly resolving the libraries in /opt/googleearth though, and googleearth appears to run correctly.

@vapier: Do you want a separate bug report for this scanelf issue?
Comment 13 Zac Medico gentoo-dev 2012-05-05 05:40:56 UTC
(In reply to comment #12)
> However, scanelf no longer works with the binaries after they've been
> patched like this (tested with pax-utils-0.3.0 and 0.4). It just exits
> successfully and doesn't produce any output. The output of ldd shows it
> properly resolving the libraries in /opt/googleearth though, and googleearth
> appears to run correctly.
> 
> @vapier: Do you want a separate bug report for this scanelf issue?

Nevermind the above. It didn't work because I was using scanelf -qf instead of -qF.

I was also confused by missing /var/db/pkg/sci-geosciences/googleearth-6.2.1.6014-r1/NEEDED{,.ELF.2} files, but that was due to the ebuild setting RESTRICT=binchecks, which causes portage to skip the scanelf call.
Comment 14 Zac Medico gentoo-dev 2012-05-05 05:49:11 UTC
So, in summary, the solution that I would suggest for this sort of issue is to adjust the RPATH with patchelf --set-rpath, so that preserve-libs can properly resolve the library dependencies.

Also, we might want to reconsider the use of RESTRICT=binchecks in googleearth-6.2.1.6014-r1.ebuild, since that prevents portage from generating the NEEDED.ELF.2 file that is required for FEATURES=preserve-libs to operate.
Comment 15 Zac Medico gentoo-dev 2012-05-05 07:34:35 UTC
(In reply to comment #14)
> Also, we might want to reconsider the use of RESTRICT=binchecks in
> googleearth-6.2.1.6014-r1.ebuild, since that prevents portage from
> generating the NEEDED.ELF.2 file that is required for FEATURES=preserve-libs
> to operate.

I've fixed portage to generate NEEDED.ELF.2 regardless of RESTRICT=binchecks, and to trigger a QA Notice if RESTRICT=binchecks is used and ELF files are installed:

http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=61571e4e8ee3f4f999782c542b4be84d8be8c729
http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=72314d2e24aa96af614b052b8b29e6d02d37a641
Comment 16 Zac Medico gentoo-dev 2012-05-06 20:20:53 UTC
@caster: Any objection to adding something like this to src_prepare for all googleearth ebuilds?

	# Set RPATH for preserve-libs handling (bug #265372).
	local x
	for x in ${PN}-bin gpsbabel *.so *.so.* ; do
		patchelf --set-rpath /opt/${PN} ${x} || \
			die "patchelf failed on ${x}"
	done
Comment 17 Zac Medico gentoo-dev 2012-05-08 08:52:57 UTC
For testing, I've added the following code to googleearth-6.2.2.6613.ebuild:

# Set RPATH for preserve-libs handling (bug #265372).
local x
for x in * ; do
	# Use \x7fELF header to separate ELF executables and libraries
	[[ -f ${x} && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]] || continue
	patchelf --set-rpath '$ORIGIN' "${x}" || \
		die "patchelf failed on ${x}"
done

If there are no complains, we can go ahead and backport this to the older ebuilds.
Comment 18 Vlastimil Babka (Caster) (RETIRED) gentoo-dev 2012-05-08 15:55:04 UTC
(In reply to comment #17)
> For testing, I've added the following code to googleearth-6.2.2.6613.ebuild:
> 
> # Set RPATH for preserve-libs handling (bug #265372).
> local x
> for x in * ; do
> 	# Use \x7fELF header to separate ELF executables and libraries
> 	[[ -f ${x} && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]] || continue
> 	patchelf --set-rpath '$ORIGIN' "${x}" || \
> 		die "patchelf failed on ${x}"
> done
> 
> If there are no complains, we can go ahead and backport this to the older
> ebuilds.

Sure, thanks for the solution!
Just leave this open so I can remove the launcher script later, at least on versions where I don't patch it to workaround a locale bug.
Comment 19 Zac Medico gentoo-dev 2012-10-10 01:43:33 UTC
(In reply to comment #18)
> Just leave this open so I can remove the launcher script later, at least on
> versions where I don't patch it to workaround a locale bug.

Okay, reassigned.