Reputation: 3629
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
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
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