I'm trying to extract a %global after it has been evaluated as it would end up during build time. rpmspec -P almost works, but the output is stripped of all the %global macros, so the macro is not able to be grepped. My understanding is that I can't use eval as that does not evalute macros that are done only at build time, which I assume is true for my spec below. I'm interested in getting the value of release_version, but I guess the process would be the same for any of them.
%global project_name heat Source99: sources %global release_version %(cat %{SOURCE99} | awk %'{sub(/%{project_name}-/, ""); sub(/.tar.gz/, ""); print $2}') ...
It would be great if there were a solution available in python, but I've not found anything in the TransactionSet API of value. Surely this must be possible as "fedpkg mockbuild" works as expected.
Jeff
On Fri, Jun 20, 2014 at 8:00 PM, Jeff Peeler jpeeler@redhat.com wrote:
It would be great if there were a solution available in python, but I've not found anything in the TransactionSet API of value. Surely this must be possible as "fedpkg mockbuild" works as expected.
This looks wrong but actually works just fine:
In [1]: import rpm
In [2]: rpm.spec('js-jquery.spec') Out[2]: <rpm.spec at 0x7f223f00bb70>
In [3]: rpm.expandMacro('%{shortcommit}') Out[3]: '4dec426'
(%{shortcommit} in this spec is used as explained in [1].)
There ought to be a more OO-way but I couldn't find it poking around when I needed this awhile ago.
-T.C.
[1] http://fedoraproject.org/wiki/Packaging:SourceURL#Github
On Fri, Jun 20, 2014 at 09:17:48PM -0700, T.C. Hollingsworth wrote:
On Fri, Jun 20, 2014 at 8:00 PM, Jeff Peeler jpeeler@redhat.com wrote:
It would be great if there were a solution available in python, but I've not found anything in the TransactionSet API of value. Surely this must be possible as "fedpkg mockbuild" works as expected.
This looks wrong but actually works just fine:
In [1]: import rpm
In [2]: rpm.spec('js-jquery.spec') Out[2]: <rpm.spec at 0x7f223f00bb70>
In [3]: rpm.expandMacro('%{shortcommit}') Out[3]: '4dec426'
(%{shortcommit} in this spec is used as explained in [1].)
There ought to be a more OO-way but I couldn't find it poking around when I needed this awhile ago.
-T.C.
[1] http://fedoraproject.org/wiki/Packaging:SourceURL#Github
It sure does, thanks! Just in case it's useful, I'll include the snippet for the archives since my macro also uses a source file:
#!/usr/bin/env python
import rpm import os
rpm.addMacro("_sourcedir", os.getcwd()) rpm.spec('openstack-heat.spec') print rpm.expandMacro('%{release_version}')
packaging@lists.fedoraproject.org