Re: Using rpmspec to query .spec file macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/05/2015 09:44 PM, Philip Prindeville wrote:
I'm trying to write some build automation using mock, etc. and I need to
be able to query a .spec file for some values.  I did a "rpmspec --help"
and tried to go by the output but it never mentions where the spec file
goes in the arguments, for instance!

I tried:

target=fedora-21-x86_64
...
rpmspec --target=$target *.spec --eval="%version"

but this just prints "%version" as the output.  How do you query a .spec
file for the macros it defines?

You dont, basically. It queries header tags of packages, not macros, ie --queryformat just like any other rpm queries.

So to query a package version from a spec, you'd use --qf "%{version}", not --eval. There's a gotcha involved in that by default, rpmspeq queries all the binary packages that would be created from the spec, which probably isn't what you wanted in this case:

[pmatilai@mursu popt]$ rpmspec -q --qf "%{version}\n" popt.spec
1.13
1.13
1.13
1.13
[pmatilai@mursu popt]$

Regardless of how many sub-packages there might be, there can only ever be exactly one source package per spec, so querying that instead helps in these kind of situations:

[pmatilai@mursu popt]$ rpmspec -q --srpm --qf "%{version}\n" popt.spec
1.13
[pmatilai@mursu popt]$


I did a quick search for "rpmspec" "--eval" but this didn't turn up
anything useful.

Is there a tutorial on using rpmdevtools?

rpmspec is part of rpm itself, not rpmdevtools.

I'm not aware of any tutorials on it, but http://www.rpm.org/wiki/Docs/QueryFormat has info on general rpm query formatting.

	- Panu -

--
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/devel
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux