Caruccio
Caruccio

Reputation: 3629

RPM: find subpackages names from spec

How could I known what are the subpackages of a spec file? There is any macro expanding to the list of package+subpackages?

I do not want to use grep because subpackages may be defined using -n or even be defined by another macro (which leads to re-eval it)

Example:

$ rpmbuild project.spec --eval '%packages_list'

Upvotes: 2

Views: 1277

Answers (4)

Saturn Junction
Saturn Junction

Reputation: 39

rpm -q --queryformat="%{NAME}\n" --specfile project.spec

Upvotes: 1

DimStar
DimStar

Reputation: 56

I generally use the simple form:

rpm -q --specfile FILENAME.SPEC

Upvotes: 3

user648129
user648129

Reputation:

Little bit of python will do the job for you. I am sure rpm-4.8 also had python bindings with spec object (assume a file with +x set and name specinfo.py):

#!/usr/bin/python                                                                                                        
import sys
import rpm
spec = rpm.spec(sys.argv[1])
for subpackages in spec.packages:
    print subpackages.header["name"]

can be used to get all subpackages. You can run this command on spec file in same directory as:

python specinfo.py <spec file>

Upvotes: 2

Stan
Stan

Reputation: 2599

Well, I used a bit of sed, but since I also used rpmspec to first unroll the macros this should be fairly OK:

$ export SPEC_FILE=maven-surefire.spec
$ rpmspec -P $SPEC_FILE | grep '^%package' | sed "s/-n //;t end;s/^/${SPEC_FILE/.spec}-/;:end;s/%package //"

Note that it would need basename call to work with paths, but otherwise should be quite error-resilient.

Upvotes: 0

Related Questions