Jul 26, 2011

Print expanded SourceX: urls from spec files

I've noticed quite a few times that people add comments to their Source0: urls without macros to seemingly simplify manual downloading. It looks like this:
Name:      jsoup
Version:   1.6.1
# http://jsoup.org/packages/jsoup-1.6.1-sources.jar
Source0:        http://%{name}.org/packages/%{name}-%{version}-sources.jar
This creates burden on maintainers to keep those urls up-to-date as version changes, so I created simple python script for printing out Source urls from spec files:

import rpm
import sys

spec_obj = ts.parseSpec(sys.argv[1])

sources = spec_obj.sources

for url, num, flags in sources:
    print url
Chmod this +x, put into your PATH and enjoy by giving it path to spec file.
*Edit*: Probably much nicer way to do the same thing already present on your system (courtesy of Alexander Kurtakov):
spectool X.spec
I knew there was something like this, but forgot what it was. Oh well...2 minutes lost.



Post a Comment
  1. Why didn't use just use spectool -s

  2. And actually there is also

    spectool -g name.spec

    which downloads Source files. Usually when rebasing a package, I change .spec file and then run spectool -g specfile. By that I know I have Source tags right.