rhel_to_json

Pierre-Yves Chibon pingou at pingoured.fr
Mon Jan 19 16:41:41 UTC 2015


On Fri, Nov 07, 2014 at 01:32:32PM +0100, Pierre-Yves Chibon wrote:
> 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']}

I would like to hear if people are fine with me breaking this already. It has
been running for a week now and afaik we have nothing (in prod or testing)
depending on it yet so it seems like the best time to make the schema evolve.

Basically I would like to go from:
{
  "pkg1": {
     "version": 0.2,
     "arch": ["i686", "x86_64"],
     ...
  },
  "pkg2": {
     "version": ...
  },
  ...
}

To:
{
  "packages": [
    "pkg1": {
       "version": 0.2,
       "arch": ["i686", "x86_64"],
       ...
    },
    "pkg2": {
       "version": ...
    }, 
    ...
  ],
  "arches": ["i686", "x86_64", "ppc64"...],
  <eventually something if we need to>
}

Thoughts? +1/-1?

Thanks,
Pierre


More information about the rel-eng mailing list