summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-02-28 13:23:03 +0900
committerJavier Jardón <jjardon@gnome.org>2017-05-11 08:24:25 +0000
commitdd902de3691d822f190c8c216815a02a471482f2 (patch)
tree2098afb9a827e9ba24ddb16d6a32bf32149f04cc
parent95d1726e4c19a5cc573b01e2a2997b53be6ad66e (diff)
downloadybd-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.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/ybd/rpm.py b/ybd/rpm.py
index 8a78dbc..4887a4c 100644
--- a/ybd/rpm.py
+++ b/ybd/rpm.py
@@ -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'])