diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-02-28 13:23:03 +0900 |
---|---|---|
committer | Javier Jardón <jjardon@gnome.org> | 2017-05-11 08:24:25 +0000 |
commit | dd902de3691d822f190c8c216815a02a471482f2 (patch) | |
tree | 2098afb9a827e9ba24ddb16d6a32bf32149f04cc | |
parent | 95d1726e4c19a5cc573b01e2a2997b53be6ad66e (diff) | |
download | ybd-dd902de3691d822f190c8c216815a02a471482f2.tar.gz |
rpm.py: Support dictionary variant for rpm-metadata
The new rpm-metadata format allows us to encode more things
into the per chunk metadata (specifically, we need to be able
to manually specify which spec file to parse in the odd cases
of repositories contiaining many spec files).
-rw-r--r-- | ybd/rpm.py | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -1,4 +1,5 @@ import os +from collections import Mapping from cache import cache_key, get_cache from app import log, timer import time @@ -96,7 +97,18 @@ def generate_spec(dn, stage_dir, metafile, output, name, time): output_f.write('%s\n' % description) output_f.write('\n') - for package in dn['rpm-metadata']: + # Support two formats of 'rpm-metadata', the older + # format specifies 'rpm-metadata' as a list of packages, + # the new format specifies 'rpm-metadata' as a dictionary + # and the package list is found in it's 'packages' member. + # + rpm_metadata = dn['rpm-metadata'] + if isinstance(rpm_metadata, Mapping): + package_list = rpm_metadata.get('packages', []) + else: + package_list = rpm_metadata + + for package in package_list: if package['name'] != name: # Sub-Package header output_f.write('%%package -n %s\n' % package['name']) |