Bug 58519 - /usr/lib/rpm/find-{provides,requires}.{perl,} are obsolete/broken
Summary: /usr/lib/rpm/find-{provides,requires}.{perl,} are obsolete/broken
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: rpm-build
Version: 7.2
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Jeff Johnson
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2002-01-18 16:36 UTC by dharris
Modified: 2008-05-01 15:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2002-01-19 14:26:55 UTC

Attachments (Terms of Use)
Suggested patch to solve problem (2.54 KB, patch)
2002-01-18 16:40 UTC, dharris
no flags Details | Diff
Second patch. Obsoletes first patch. Fixes find-{provides,requires} and creates stubs out of find-{provides,requires}.perl (3.16 KB, patch)
2002-01-19 14:26 UTC, dharris
no flags Details | Diff

Description dharris 2002-01-18 16:36:48 UTC
Description of Problem:

The /usr/lib/rpm/cpanflute script creates RPM SPEC files that contain the 
following lines to make sure RPM detects what perl modules are provided and 
required by this module:

# Provide perl-specific find-{provides,requires}.
%define __find_provides /usr/lib/rpm/find-provides.perl
%define __find_requires /usr/lib/rpm/find-requires.perl

These lines are actually un-needed because the default __find_provides and 
__find_requires scripts detect perl requirements and provisions already. They 
probably didn't at the time cpanflute was written.

It's probably best to patch cpanflute to remove adding these extra lines, as 
they are not needed and may confuse users.

Additionally, I would recommend making the /usr/lib/rpm/find-
{provides,requires}.perl scripts stubs that simply execute 
the /usr/lib/rpm/find-{provides,requires} scripts without adding any logic. (Or 
symlinks.) Otherwise the detection logic has to be maintained in two places, 
which will most certainly cause problems in the future. Stubs or symlinks need 
to exist otherwise existing RPM SPEC files that use these scripts will no 
longer build.
Version-Release number of selected component (if applicable):


How Reproducible:

(1) Fix bug #58517 on your system.
(2) Create an RPM with cpanflute
(3) Build it and see that the perl(module) requires and provides are properly 
(4) Remove the "%define __find_provides" and "%define __find_requires" lines 
from the SPEC file.
(5) See that the perl(module) requires and provides are STILL properly detected.

I have performed all of these steps. If I had more time, I would include a 
shell script log.

Comment 1 dharris 2002-01-18 16:40:59 UTC
Created attachment 42834 [details]
Suggested patch to solve problem

Comment 2 dharris 2002-01-18 16:43:08 UTC
NOTE: I have not tested this patch. It looks simple enough to me to be correct. 
However, I recommend that you test it before using.

Comment 3 dharris 2002-01-18 19:14:31 UTC
Mea culpa. I was wrong when I stated that find-requires.perl and find-requires 
produce the same result. (However, I still find that find-provides.perl and 
find-provides produce the same result.)

I ran this command as a test:

# find /usr/lib/perl5 | /usr/lib/rpm/find-requires | sort | uniq > 
# find /usr/lib/perl5 | /usr/lib/rpm/find-requires.perl | sort | uniq > 
# diff -u3 requires.normal requires.perl

A big diff results because find-requires and find-requires.perl produce 
different results. (More on how they are different later.)

I was, however, correct when stating that find-provides and find-provides.perl 
produce the same result:

# find /usr/lib/perl5 | /usr/lib/rpm/find-provides | sort | uniq > 
# find /usr/lib/perl5 | /usr/lib/rpm/find-provides.perl | sort | uniq > 
# diff -u3 provides.normal provides.perl

No diffs result, which shows that find-provides and find-provides.perl produce 
the same results.


Well, how find-requires and find-requires.perl different?

The find-requires script does not find search for requirements in .pm perl 
module files, only in perl script files. The find-requires.perl script also 
looks in .pm perl module files for requirements.

I see no reason for the behavior. I suggest that find-requires should be 
updated to find requirements in .pm perl module files as well. Any other 
changes that are required to make their behavior the same should be done. Then 
find-requires.perl should be obsolete and become a stub file pointing to find-

This is good because:

(1) This prevents logic duplication. 

(2) I suspect that the lack of searching for perl requirements in .pm module 
files by find-requires is actually a bug, not a feature. This removes an 
undocumented difference. Theres never a good reason to not search for perl 
requirements, is there? :-)

Comment 4 dharris 2002-01-19 14:24:55 UTC
I dug deeper into the scripts to see exactly how things worked and to find out 
what the differences between find-requires and find-requires.perl were.

I have created a new patch to solve the original problem. The patch unifies all 
the logic into find-{requires,provides} and replaced find-
{requires,provides}.perl with stubs.


find-requires had a bug where on line 66:

    *)          [ "${f%.pm}" != "${f}" ] && perllist="$perllist $f" ;;

This line attempts to add .pm perl module files to $perllist for later 
inspection by /usr/lib/rpm/perl.req. The problem is that a previous test on 
line 61 in this loop restricts processing to only $f files that were 
executable. Since perl module files are usually not executable, they are missed 
by this code.

I did not see any bugs in find-requires.perl, which parsed *.pm files 
regardless of the execute bit.

Obviously the intent was to parse .pm files for their perl requirements.

In my patch, I patched find-requires so that it adds .pm files to $perllist 
regardless of if they are executable. This makes it logically equivalent to 
find-requires.perl. I then replaced find-requires.perl with a stub to find-
requires, as they are logically equivalent now.


On inspection, I found that find-provides and find-provides.perl are logically 
different even though they produced the same results in my test.

(a) find-provides.perl gives every file in $filelist to /usr/lib/rpm/perl.prov 
for inspection (see line 9).

(b) find-provides *attempts* to give only *.pm files from $filelist 
to /usr/lib/rpm/perl.prov for inspection (see lines 10 and 50). However, there 
is a bug on line 10:

perllist=$(echo $filelist | grep '\.pm$')

Since $filelist is a space separated list (and grep is thinking line-
separated), either all or none of the files get acced to $perllist depending 
only on the last file in the list.

To determine if all files (what find-provides.perl does) or just the *.pm files 
(what find-provides attempts to do) should be parsed by perl.prov, I looked at 
the perl.prov script and saw that it is designed specifically to parse perl 
module files and treats any file given to it as a perl module. Therefore, I 
believe the behavior from find-provides which only looks at *.pm files is 

In my patch, I fixed find-provides to pass only *.pm files to perl.prov for 
inspection. I then replaced find-provides.perl with a stub pointing to find-

Comment 5 dharris 2002-01-19 14:26:50 UTC
Created attachment 42875 [details]
Second patch. Obsoletes first patch. Fixes find-{provides,requires} and creates stubs out of find-{provides,requires}.perl

Comment 6 Jeff Johnson 2002-01-23 00:11:06 UTC
Again, thanks for the patch, should be in rpm-4.0.4-0.17 (with
the perl.req execute bit turned on :-)

Note You need to log in before you can comment on or make changes to this bug.