Bug 117261 - Want a way to find out what rpms a build command will create
Want a way to find out what rpms a build command will create
Product: Red Hat Linux
Classification: Retired
Component: rpm-build (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Johnson
: FutureFeature
Depends On:
  Show dependency treegraph
Reported: 2004-03-02 07:30 EST by Toralf
Modified: 2007-04-18 13:03 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-03-02 10:57:29 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Toralf 2004-03-02 07:30:30 EST
Description of problem:
I'll file this here since I got no response on the rpm mailing list:

A simple and direct way to ask rpmbuild what files it's going to
create, would be nice. So far I've been using

rpm -q [<--defines etc. used during build>] --specfile <spec>
--queryformat "`rpm --eval '%{_rpmdir}/%{_rpmfilename}'`"


  1. I've always been thinking that there ought to be a more
     direct way
  2. If I have a package "foo" with
     %package server
     %package client
     (to use an example from "Maximum RPM"), and also
     %files server
     %files client
     but no filelist for the main package, my query will list
     something like
     but an actual rpmbuild will create just the latter two files;
     there will be no rpm for "foo" itself, since it has no %files!

Version-Release number of selected component (if applicable):
4.2-1, 4.2-0.69 and various earlier releases...
Comment 1 Toralf 2004-03-02 07:46:32 EST
I also thought that

rpmbuild -bb --nobuild ...

might help, but it doesn't, since it will exit with error messages
about missing files. Which doesn't make sense, at least when using
BuildRoot; *of course* the files are missing when you skip the build
Comment 2 Jeff Johnson 2004-03-02 10:32:49 EST
    rpm -q --specfile foo.spec
You can add --queryformat if you need exact file paths.
Comment 3 Toralf 2004-03-02 10:50:55 EST
I think you missed the point. What I was saying was that

1. There ought to be a *simple* and *direct* way to get this info, IMO.

rpm -q --specfile ... --queryformat "`rpm --eval

is neither simple, nor direct.

2. This method will simply return the list that results from expanding
or whatever, once for each package mentioned in the spec file. That's
generally *not* the same thing as a list of the files rpmbuild with
the spec file would create, since there may be packages for which rpms
are never created (namely the ones which have no %files)
Comment 4 Jeff Johnson 2004-03-02 10:57:29 EST
What makes you think that there is anything simpler or
more direct than querying the specfile? No matter what,
a parse needs to happen, and sub-packages can be conditional
on %ifarch.
Comment 5 Toralf 2004-03-02 11:16:15 EST
What makes me think that, is the observation that an actual build can
work out the file name based on internal info, rather than
--queryformat etc. Well, I'm stating the obvious yet another time, but
the point is that the code that parses the data the right way must be
there already, so why not offer a way to run this code separately, and
print the result on screen?
Comment 6 Jeff Johnson 2004-03-02 11:27:04 EST
I *did* give you a way to run this code seperately and
print the result.

You complained "not simple and direct".

What do you want? If you want a single option
to do the dirty deed. then put the following
in /etc/popt (watch for typos):

    rpm alias --showpkgstobebuiltfromspecfile -q --sepcfile
    rpmq alias --showpkgstobebultfromspecfile -q --specfile

and invoke as

    rpm --showpkgstobebuiltfromspecfile foo.spec

     rpm --q
Comment 7 Toralf 2004-03-02 11:37:01 EST
I think you misunderstood. I'm not saying that "rpm -q --specfile"
isn't simple enough. My objection is that to get the output filenames,
I have to rpm --eval '%{_rpmdir}/%{_rpmfilename}' and feed the result
back into rpm --queryformat.
Comment 8 Jeff Johnson 2004-03-02 11:41:24 EST
And? What do you expect? There is no simpler or more direct.
wrap the command in a 2 libe shell script if it bothers you.

Or use a popt alias.

Or use a shell alias.
Comment 9 Toralf 2004-03-02 11:53:16 EST
I expect a mode of operation where rpm -q does the above mentioned
eval and queryformat setup implicitly, just like rpmbuild does.

But having said that, I didn't add this report because I was too
worried about running two commands instead of one; the main issue is
that the method doesn't quite work, due to the above mentioned problem
with packages that have no file list.

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