Bug 86273 - rpm '-q --specfile' query is sometimes broken
rpm '-q --specfile' query is sometimes broken
Status: CLOSED UPSTREAM
Product: Red Hat Linux
Classification: Retired
Component: rpm (Show other bugs)
8.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Paul Nasrat
Mike McLean
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-03-18 12:40 EST by Denice
Modified: 2007-04-18 12:52 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-09-29 15:19:43 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch file for rpm-4.1 to get around Icon: preamble --specfile query problem (5.19 KB, patch)
2003-03-18 12:43 EST, Denice
no flags Details | Diff

  None (edit)
Description Denice 2003-03-18 12:40:52 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003

Description of problem:
I have been playing around extracting _all_ the .spec files from RH 8 and from
Phoebe src.rpms, and have some annomolies to report about the --specfile option.

I am mainly documenting this behaviour here, so that it can be taken into
consideration for future versions of rpm; ie:  What is the role of the
--specfile query in future versions of rpm?  Should one be able to extract
information about an rpm from the specfile without being required to
install the .src.rpm file?

There are a few potholes on the road to trying to automate a task such
as extracting all spec files from a red hat distro.  I start from the
assumption that it is interesting to extract the specfiles withOUT having
to install the source rpms to get them (ie. with 'rpm2cpio').
This is apparently a wrong assumption as I have learned :o~

There is a lot of interesting info to be culled from the --specfile query
option, and one succeeds _most_ of the time.  But the query fails for certain
cases which I document here.  For brevity's sake I refer to it here as the
SF query.

All I was trying to do (besides extract the spec files) was to get the names
of the packages from the specfile, with
 $ rpm -q --specfile $thisspecfile  --queryformat='%{NAME} '

There are 2 categories of problems caused by less than 3% of all src.rpms:

  - 1.4% of src.rpms:
    If the .spec preamble contains an 'Icon: ' directive then the SF query
    will fail, unless you have installed the src rpm.  'rpm' will try to open
    and read the icon file.  This is easily enough patched; I am attaching a
    candidate patch against rpm-4.1, in case there is any interest in such a
    patch.  Note that the patch assumes in 'query.c' that we can pass
    a flag 'qOnly' set to true; I don't know if this is a valid thing to do
    (but it worked for me).

    12 src.rpms:
    RH 8   ethereal, kde2-compat, kdebase, kdegames, kdegraphics, kdelibs,
           kdemultimedia, kdenetwork, kdepim, kdetoys, mtr, w3c-libwww
    Phoebe kdebase, kdegames, kdegraphics, kdelibs, kdenetwork, kdepim,
           kdetoys, kdevelop, kdoc, quanta

  - 0.8% of src.rpms:
  - There are 7 remaining cases where either the 'Requires:' directive or
    the 'Version:' directive cause a parse error when the SF query causes
    the affected src.rpms want to exec a shell command (awk or cat) on
    non-existant files, in order to satisfy a macro.
    Example:            Requires: httpd-mmn = %(cat %{_includedir}/httpd/.mmn)

        There are 2 sub-categories here:

         - For 2, if you had installed the src.rpm files then this would not
           be a problem.
            both RH8 and Phoebe: rhn-applet, up2date

         - For the last 5, you must have installed the httpd-devel RPM in
           order to run the SF query ( they all want '/usr/include/httpd/.mmn')
            both RH8 and Phoebe:
             mod_auth_mysql, mod_auth_pgsql, mod_perl, mod_python, php

There is also one anomoly, and one other annoyance:

  - the 'rpmdb-redhat' spec file, unlike all other src.rpm files, has a
    '.spec.in' extension.
    Furthermore, you need to add a macro name for %{rpmdbname} in ~/.rpmmacros
    to get it to report its name properly -- eg:
       $ rpm -q --specfile rpmdb-redhat.spec.in  --queryformat='%{NAME}\n'
       rpmdb-%{rpmdbname}

  - 3 src.rpms use the same .spec filenames as their antecedents.  I have
    reported these as bugz 86116, 86118 and 86119 (well, add openssl to
    the list for phoebe and rawhide, as I have just discovered..).
    RH 8 (libxml2/libxml, readline/readline14, slang/compat-slang)
    Phoebe (openssl*, libxml2/libxml, readline/readline14, slang/compat-slang)


There is one final note -- even on getting the names of the packages
with
 $ rpm -q --specfile $thisspecfile  --queryformat='%{NAME} '

One finds that a package name in a src.rpm file does not necessarily
mean that such a package is built.  Some packages are 'superpackages', like
kdegames.  The specfile lists a whole slew of packages, but it only
builds one package: kdegames.   Maybe I just haven't stumbled on the
right query to get this info...

 cheers,
   denice

PS. Anyway, the end result is that I fiddled until I extracted all the spec
files, and made version 3 of my comps.xml browsing web page at:
 http://penguin.epfl.ch/comps/8.0/comps-8.0.php#v3
Warning: the generated .html file is a monster, and needs to be rethought.


Version-Release number of selected component (if applicable):
rpm-4.1

How reproducible:
Always

Steps to Reproduce:
1.extract a specfile like kdebase, up2date or mod_perl with rpm2cpio
2.try to query the specfile; it will fail unless you have the .src.rpm
file installed, or in some cases the httpd-devel package installed.
3.
    

Additional info:
Comment 1 Denice 2003-03-18 12:43:33 EST
Created attachment 90649 [details]
patch file for rpm-4.1 to get around Icon: preamble --specfile query problem
Comment 2 Paul Nasrat 2005-09-29 15:19:43 EDT
This feature is currently not being evaluated for rpm. Should you wish to persue
it further with an updated patch against rpm 4.4.x/HEAD please use:

https://lists.dulug.duke.edu/mailman/listinfo/rpm-devel

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