Hi all,
This morning I wrote a small script that converts yum's medata into a small json
blob that can be used to check if a package is present in RHEL before creating a
branch for it in EPEL, or to restrict building the package on EPEL for certain
arch.
What is does it basically:
- For a list of RHEL version
- For a list of directories specific to that RHEL version
- Find all the primary.sqlite database
- Decompress them if needed
- For all the packages listed in the database
- get the base package (using the srpm info)
- get the epoch, version, release (does nothing w/ it atm)
- get the arch - As more arch are found the list grows
- Store of the info in a json
- Dump the json into a text file
So using this, we are quickly able to check if a package is in RHELX, for
example:
>>> import json
>>> with open('pkg_el7.json') as stream:
... data = json.load(stream)
>>> 'python-zope-interface' in data
True
>>> data['python-zope-interface']
{u'release': u'4.el7', u'epoch': u'0', u'version': u'4.0.5', u'arch': [u'ppc64',
u'x86_64']}
The script is fairly quick to run:
time python rhel_to_json.py
...
2316 packages retrieved in el6
Output File: pkg_el6.json
...
2514 packages retrieved in el7
Output File: pkg_el7.json
...
1395 packages retrieved in el5
Output File: pkg_el5.json
real 0m47.411s
user 0m16.989s
sys 0m5.888s
And its output:
du -sh pkg_*
144K pkg_el5.json
240K pkg_el6.json
252K pkg_el7.json
Hope this helps,
Pierre