Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 96515 - equery doesn't account for symlinks
Summary: equery doesn't account for symlinks
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Tools (show other bugs)
Hardware: All Other
: High enhancement (vote)
Assignee: Portage Tools Team
URL:
Whiteboard:
Keywords: InVCS
: 102605 113708 134719 195083 286508 361259 (view as bug list)
Depends on:
Blocks: 237964
  Show dependency tree
 
Reported: 2005-06-19 04:31 UTC by Stuart Herbert (RETIRED)
Modified: 2011-05-10 22:54 UTC (History)
7 users (show)

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


Attachments
equery-b-symlinks.patch (equery-b-symlinks.patch,3.29 KB, patch)
2005-11-28 05:06 UTC, Harald van Dijk (RETIRED)
Details | Diff
better-symlink-resolution (better-symlink-resolution.patch,338 bytes, patch)
2011-03-31 21:42 UTC, Vikraman (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Herbert (RETIRED) gentoo-dev 2005-06-19 04:31:52 UTC
Hi,

I tried running 'equery belongs /usr/X11R6/lib/libaspell.so.<version>'.  equery was unable to find out which package this file belongs to.  

/usr/X11R6 is a symlink to /usr.  It appears that equery doesn't use realpath() to support symlinks.

Best regards,
Stu
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2005-06-19 04:36:03 UTC
Yeah, I always wondered why it does not work for me...
Comment 2 Jakub Moc (RETIRED) gentoo-dev 2005-08-15 06:42:05 UTC
*** Bug 102605 has been marked as a duplicate of this bug. ***
Comment 3 Paul Varner (RETIRED) gentoo-dev 2005-11-11 21:12:09 UTC
equery wasn't designed to check if the argument that is passed actually exists
on the file system.  It was designed to take the argument and search the
contents of the packages to see what package, if any, contains that argument. 
Since libaspell.so.<version> wasn't installed in /usr/X11R6/lib, it doesn't find
a package.

Right now, I don't see a clean and easy way to accomplish what you want based
upon the current design of equery.
Comment 4 Jakub Moc (RETIRED) gentoo-dev 2005-11-27 07:14:08 UTC
*** Bug 113708 has been marked as a duplicate of this bug. ***
Comment 5 Evgeniy Dushistov 2005-11-27 10:02:47 UTC
>equery wasn't designed to check if the argument that is passed actually exists
>on the file system

I suppose YOU didn't understand the problem,
>/usr/X11R6/lib/libaspell.so.<version>

<version> is used as indication,
not as real example.

I try show you facts:
fact one:
file /usr/X11R6/lib/libaspell.so.15 appera after "emerge aspell" and will disappear
after "emerge unmerge aspell",
hence it belongs to aspell package
fact number two
according to "equery b /usr/X11R6/lib/libaspell.so.15",
this file doesn't belong to any package,
this is BUG.

solution is simple:

equery b `readlink -f /usr/lib/libaspell.so.15.0.3`

BUT it is too boring every time check if some file is symbolic link or not and 
use readlink,

so can you before handle arguments use "readlink -f" or some similar stuff?
Comment 6 Marius Mauch (RETIRED) gentoo-dev 2005-11-28 01:11:42 UTC
(In reply to comment #5)
> >equery wasn't designed to check if the argument that is passed actually exists
> >on the file system
> 
> I suppose YOU didn't understand the problem,

Incorrect. You just don't understand the implications of the problem.

> I try show you facts:
> fact one:
> file /usr/X11R6/lib/libaspell.so.15 appera after "emerge aspell" and will
disappear
> after "emerge unmerge aspell",
> hence it belongs to aspell package

Wrong. There is no such file.

> fact number two
> according to "equery b /usr/X11R6/lib/libaspell.so.15",
> this file doesn't belong to any package,
> this is BUG.

It's not. It's a semantic screwup by xorg (unfortunately needed for compability).

> solution is simple:
> 
> equery b `readlink -f /usr/lib/libaspell.so.15.0.3`

That's completely unrelated to your example above. Also I guess you're mixing up
"solution" and "workaround".

> BUT it is too boring every time check if some file is symbolic link or not and 
> use readlink,
> 
> so can you before handle arguments use "readlink -f" or some similar stuff?

a) in your example the file being a symlink isn't the problem, it's the crappy
X11R6 symlink
b) using realpath (or something equivalent) unconditionally would generate wrong
results, so not an option
c) IMO `equery belongs` should match `equery files` which implicates that
symlinks shouldn't be resolved

So all in all if this gets implemented it should be an off-by-default option.
Comment 7 Jakob Schiotz 2005-11-28 01:59:11 UTC
I think that from a "logic" point of view Marius is right.  If a package
installs a symlink, it should be shown by equery belongs as well as by equery
files (and I strongly assume that it does).

If you can access a file thought a symlink from another package, then that path
to the file is clearly should not be printed by equery files, and if you give
priority to consistency between equery files and equery belongs then neither
should equery belongs recognize it.

However, I do not think we should give priority to consistency over
userfriendlyness unless consistency servers a higher purpose than consistency
itself ("A foolish consistency is the hobgoblin of little minds", but who can
say if a consistency is foolish?).

In this case, I think the typical use of "equery belongs" is to identify which
package is to blame for a problem with a file.  In that case, it is useful to
get a reply from equery belongs, even if it is not 100% consistent with equery
files.  Implementing it as a per-default off option is not going to help,
because if the user realizes he has to turn on the option he has probably
already solved his problem.

I suggest that if "equery belongs" fails to find a file, it tries again with the
 readlink trick, and then prints a warning along with the result:

# equery belongs /usr/lib/libgle.so.3.0.0
[ Searching for file(s) /usr/lib/libgle.so.3.0.0 in *... ]
media-libs/gle-3.0.1-r2 (/usr/lib/libgle.so.3.0.0)

# equery belongs /usr/X11R6/lib/libgle.so.3.0.0
[ Searching for file(s) /usr/X11R6/lib/libgle.so.3.0.0 in *... ]
media-libs/gle-3.0.1-r2 (/usr/lib/libgle.so.3.0.0 - ACCESSED THROUGH SYMBOLIC LINK)

/Jakob
Comment 8 Harald van Dijk (RETIRED) gentoo-dev 2005-11-28 05:06:18 UTC
Created attachment 73718 [details, diff]
equery-b-symlinks.patch

This patch allows equery b to work with symlink directories. Unlike the
readlink -f workaround/hack, this should work regardless of whether the ebuild
installed the file through a symlink or through the actual directory name. It
has its problems - previously supported functionality is removed (notably
equery b -f). Also, it only handles symlink directories; symlink files such as
#113708 (/usr/bin/gprof -> i686-pc-linux-gnu-gprof ->
../i686-pc-linux-gnu/bin/gprof) are not handled. (Personally, since
/usr/bin/gprof is not created by an ebuild, I don't think it should be shown,
and since /usr/X11R6/<...> is (with a different name, but it is the exact same
file), I think it should.) This patch is intended mainly as an idea of how this
could be handled, not as the actual solution.

$ gentoolkit-0.2.1_rc2/src/equery/equery b /usr/X11R6/X11R6
[ Searching for file(s) /usr/X11R6/X11R6 in *... ]
x11-base/xorg-x11-6.8.2-r6 (/usr/X11R6)
Comment 9 Marius Mauch (RETIRED) gentoo-dev 2006-05-29 04:01:31 UTC
*** Bug 134719 has been marked as a duplicate of this bug. ***
Comment 10 Jakub Moc (RETIRED) gentoo-dev 2007-10-08 19:25:07 UTC
*** Bug 195083 has been marked as a duplicate of this bug. ***
Comment 11 Douglas Anderson 2009-02-19 09:26:50 UTC
What's the word on this bug? The /usr/X11R6 example is pretty outdated. If someone can provide a modern example and justification for it, I'll work on doing this right. Otherwise, let's close it.
Comment 12 Paul Varner (RETIRED) gentoo-dev 2009-02-19 15:42:30 UTC
The more modern example is the /usr/lib symlink to /usr/lib64 on the amd64 architecture.

On my amd64 box:
# equery belongs /usr/lib | cat | wc -l
13
# equery belongs /usr/lib64 | cat | wc -l
461

All of the files actually reside in /usr/lib64, however for 13 packages in my system they were installed into /usr/lib

So for this to work, we need to be able to check both the symlinked path and the real path regardless of which path name was given as the argument.
Comment 13 Douglas Anderson 2009-10-26 23:39:51 UTC
*** Bug 286508 has been marked as a duplicate of this bug. ***
Comment 14 Douglas Anderson 2010-03-06 12:16:38 UTC
This was fixed a short time back. Reopen if you disagree.
Comment 15 Fabio Rossi 2010-03-07 08:42:18 UTC
Can you say in which version of gentoolkit it has been fixed? With the current stable version, 0.2.4.5, I have the same problems.
Comment 16 Douglas Anderson 2010-03-07 11:00:29 UTC
(In reply to comment #15)
> Can you say in which version of gentoolkit it has been fixed? With the current
> stable version, 0.2.4.5, I have the same problems.
> 

Latest unstable contains the fix... gentoolkit-0.3.0_rc9. The 0.2* branch is still actively maintained, but really only bugfixes are being backported. For new features and enhancements (and there are a lot) use the 0.3.0 branch.
Comment 17 Paul Varner (RETIRED) gentoo-dev 2011-03-31 21:34:04 UTC
*** Bug 361259 has been marked as a duplicate of this bug. ***
Comment 18 Paul Varner (RETIRED) gentoo-dev 2011-03-31 21:36:56 UTC
Broken again in the lastest version:


$ equery belongs /usr/lib/libedata-book-1.2.so.8.0.0
 * Searching for /usr/lib/libedata-book-1.2.so.8.0.0 ... 

$ equery belongs /usr/lib64/libedata-book-1.2.so.8.0.0
 * Searching for /usr/lib64/libedata-book-1.2.so.8.0.0 ... 
gnome-extra/evolution-data-server-2.32.2 (/usr/lib64/libedata-book-1.2.so.8.0.0)
Comment 19 Vikraman (RETIRED) gentoo-dev 2011-03-31 21:38:52 UTC
Try out my patch from bug #361259
Comment 20 Vikraman (RETIRED) gentoo-dev 2011-03-31 21:42:44 UTC
Created attachment 268039 [details, diff]
better-symlink-resolution
Comment 22 Paul Varner (RETIRED) gentoo-dev 2011-05-10 22:54:21 UTC
Released in gentoolkit-0.3.0