Discussion:
Extract source URLs from RPM spec files
Mildred
2007-12-06 21:57:27 UTC
Permalink
Hi,

I would like to create a probram that would download automatically the
source files of packages given a spec file and build it using rpmbuild.

But I just wonder how to extract the source URLs from the spec file. I can't
use standard srep and sed since often the Source line contains variables
that need to be resolved.

I found that rpm has an option --specfile that seems deigned for that
purpose. But rpm do not seems to be aware of the source filenames
unfortunately.

Does anyone knows how I could extract this information without writing a
spec file parser ?

Thanks.

Mildred
--
Mildred Ki'lya
Site: <http://mildred632.free.fr/>
XMPP: <***@jabber.fr> (GoogleTalk, Jabber)

GPG: 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]
Michael Jennings
2007-12-08 18:24:52 UTC
Permalink
On Thursday, 06 December 2007, at 22:57:27 (+0100),
Post by Mildred
I would like to create a probram that would download automatically
the source files of packages given a spec file and build it using
rpmbuild.
I believe rpmbuild in RPM 5 already does this.
Post by Mildred
But I just wonder how to extract the source URLs from the spec
file. I can't use standard srep and sed since often the Source line
contains variables that need to be resolved.
I found that rpm has an option --specfile that seems deigned for
that purpose. But rpm do not seems to be aware of the source
filenames unfortunately.
Does anyone knows how I could extract this information without
writing a spec file parser ?
rpm --eval "`cat foo.spec`" will get you most of the way there.

Michael
--
Michael Jennings (a.k.a. KainX) http://www.kainx.org/ <***@kainx.org>
Linux Server/Cluster Admin, LBL.gov Author, Eterm (www.eterm.org)
-----------------------------------------------------------------------
"I have failed over and over again in my life. And that is why I
succeed." -- Michael Jordan
Jeff Johnson
2007-12-08 18:36:34 UTC
Permalink
Post by Mildred
Hi,
I would like to create a probram that would download automatically the
source files of packages given a spec file and build it using rpmbuild.
FYI: rpmbuild (in rpm-4.4.6 and later) will already fetch sources/patches,

rpm-4.4.9 will also fetch Icon: url's, as well as verify digests/signatures

of the fetch'ed elements (if the information is added to spec file build
dependencies).
Post by Mildred
But I just wonder how to extract the source URLs from the spec file. I can't
use standard srep and sed since often the Source line contains variables
that need to be resolved.
I found that rpm has an option --specfile that seems deigned for that
purpose. But rpm do not seems to be aware of the source filenames
unfortunately.
Yep. The issue is that there is an ambiguity of exactly what is

being queried with --specfile. The default for --specfile queries all binary

(sub-)packages, as that is arguably more useful to most.
Post by Mildred
Does anyone knows how I could extract this information without writing a
spec file parser ?
FYI: Here's what is in rpm-5.0:


$ rpm -q --qf '[%{source}\n]' --specsrpm time.spec

time-1.7.tar.gz


(I fergit when I implemented --specsrpm, more than a year ago for sure)


which is a start, but does not include (because the *.src.rpm header does
not include)

the full URL, only the basename of the included file.


It wouldn't be hard to add the full source URL as an additional tag in
*.src.rpm if you want.


Post an RFE to <rpm-***@rpm5.org> if you (or someone else) wants the
ability

to query the full source url from spec files and *.src.rpm headers.


hth


73 de Jeff

Loading...