Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 194234 - app-portage/gentoolkit-0.2.4_pre7: revdep-rebuild-rewrite's "portable find" function is slightly bogus
Summary: app-portage/gentoolkit-0.2.4_pre7: revdep-rebuild-rewrite's "portable find" f...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Tools (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Portage Tools Team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 170220
  Show dependency tree
 
Reported: 2007-09-30 00:10 UTC by David Leverton
Modified: 2008-02-21 01:52 UTC (History)
1 user (show)

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


Attachments
patch (revdep-rebuild.patch,1.43 KB, patch)
2007-09-30 00:12 UTC, David Leverton
Details | Diff
revdep-rebuild_r453_find_find.patch (revdep-rebuild_r453_find_find.patch,1.40 KB, patch)
2008-01-22 22:15 UTC, michael@smith-li.com
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Leverton 2007-09-30 00:10:53 UTC
The "find" function in revdep-rebuild-rewrite assumes that the script itself will have the executable bit.  While this is true when it is installed from an ebuild, it may not be when, for example, downloading the latest version of the script from viewvc with a web browser.

This leads to the second issue: if the script isn't executable, all the tests of find's syntax fail, and it falls through to the "Last resort" branch, which replaces -executable etc with "-exec test ...".  This fails because all it does is cause the test command to be executed for each file - find doesn't do anything with the return value.  If the actual call to find specifies an explicit action it well be executed regardless of whether the file is actually executable, otherwise the default -print action will /not/ be executed at all.
Comment 1 David Leverton 2007-09-30 00:12:56 UTC
Created attachment 132207 [details, diff]
patch

This fixes both issues: for the first, use $(type -P find) as the assumed-executable to test, since if it isn't executable then things are /really/ hopeless.  For the second, since no-one's complained before we can assume that no implementation of find requires the "last resort", so we can just replace it with a die.
Comment 2 michael@smith-li.com 2008-01-21 19:54:43 UTC
In reply to comment #0:  Hi, David,  I agree that testing the executability of $(type -P find) is more appropriate than testing $0. As for the Last Resort branch, find(1p) claims that  for the syntax "-exec utility_name [argument...] ;", "...the utility utility_name shall be invoked once for each pathname and the primary shall evaluate as true if the utility returns a zero value as exit status."  It's certainly possible my implementation was faulty, but the man page backs up the theory behind the "Last Resort" method. Is it possible that the failure you experienced had a different cause?
Comment 3 David Leverton 2008-01-21 21:03:36 UTC
(In reply to comment #2)
> As for the Last Resort branch, find(1p) claims that  for the syntax "-exec
> utility_name [argument...] ;", "...the utility utility_name shall be invoked
> once for each pathname and the primary shall evaluate as true if the utility
> returns a zero value as exit status."

Yeah, sorry, I must have missed that part of the doc.

> It's certainly possible my implementation was faulty, but the man page backs
> up the theory behind the "Last Resort" method. Is it possible that the
> failure you experienced had a different cause? 

In

>	while read LIST; do
>		break # Set LIST
>	done < <(find $HOME/ /var/tmp/ /tmp/ -writable)

when the last resort method is used, the use of -exec suppresses the default -print, causing find not to output anything.  It seems to work fine if the -print is specified explicitly, so that would be better than what I suggested before.
Comment 4 michael@smith-li.com 2008-01-22 22:15:03 UTC
Created attachment 141612 [details, diff]
revdep-rebuild_r453_find_find.patch

How does this patch look? I believe it should fix this bug.
Comment 5 David Leverton 2008-01-22 22:51:23 UTC
(In reply to comment #4)
> How does this patch look? I believe it should fix this bug.
> 

Looks good to me.  Tested and it works fine here.
Comment 6 Paul Varner (RETIRED) gentoo-dev 2008-02-16 20:36:14 UTC
$ svn commit -m "Apply patch for revdep-rebuild portable find function. (Bug 194234)"
Sending        revdep-rebuild/revdep-rebuild
Transmitting file data .
Committed revision 460.
Comment 7 Paul Varner (RETIRED) gentoo-dev 2008-02-21 01:52:11 UTC
Released in gentoolkit-0.2.4_rc2