From 7acda0d943380cf3d3ce89a159f32b525bf19f26 Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Sep 08 2016 08:10:05 +0000 Subject: Add a script to generate legacy composeinfo The file is currently consumed by Beaker. Once they get the data from PDC (or preferably use productmd to parse the JSON file), this script will no longer be needed. See https://github.com/release-engineering/productmd/issues/37 for details. Signed-off-by: Lubomír Sedlář --- diff --git a/bin/compose-create-legacy-composeinfo b/bin/compose-create-legacy-composeinfo new file mode 100755 index 0000000..f04af21 --- /dev/null +++ b/bin/compose-create-legacy-composeinfo @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from __future__ import print_function + +import argparse +import os +import sys + +import productmd.compose + +here = sys.path[0] +if here != '/usr/bin': + sys.path.insert(0, os.path.dirname(here)) + +from compose_utils.legacy import write_legacy_composeinfo + + +def run(opts): + compose = productmd.compose.Compose(opts.compose) + target = opts.path or compose.compose_path + with open(os.path.join(target, '.composeinfo'), 'w') as f: + write_legacy_composeinfo(compose.info, f) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('compose', metavar='COMPOSE') + parser.add_argument('-p', '--path', + help='Directory in which to write the .composeinfo file. ' + 'Defaults to the compose subdirectory.') + + opts = parser.parse_args() + run(opts) diff --git a/compose_utils/legacy.py b/compose_utils/legacy.py new file mode 100644 index 0000000..39b29c8 --- /dev/null +++ b/compose_utils/legacy.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- + +import ConfigParser + + +def write_legacy_composeinfo(ci, file): + """Write a legacy INI-style composeinfo data into `file`.""" + conf = ConfigParser.SafeConfigParser(dict_type=SortedDict) + _serialize_compose(conf, ci.compose) + _serialize_product(conf, ci.release, ci.compose) + if ci.release.is_layered: + _serialize_base_product(conf, ci.base_product) + _serialize_variants(conf, ci.variants) + conf.write(file) + + +def _serialize_compose(conf, compose): + conf.add_section('compose') + conf.set('compose', 'date', compose.date) + conf.set('compose', 'id', compose.id) + conf.set('compose', 'respin', str(compose.respin)) + conf.set('compose', 'type', compose.type.lower()) + if compose.label: + conf.set('compose', 'label', compose.label) + + +def _serialize_product(conf, release, compose=None, section='product'): + conf.add_section(section) + if compose: + conf.set(section, 'family', release.name) + conf.set(section, 'name', compose.id) + else: + conf.set(section, 'name', release.name) + conf.set(section, 'short', release.short) + conf.set(section, 'type', release.type.lower()) + conf.set(section, 'version', release.version) + if release.is_layered: + conf.set(section, 'is_layered', 'true') + + +def _serialize_base_product(conf, bp): + conf.add_section('base_product') + conf.set('base_product', 'name', bp.name) + conf.set('base_product', 'short', bp.short) + conf.set('base_product', 'version', bp.version) + + +def any_path(paths, options, arch): + """Check if any path in `options` exists for `arch`.""" + for opt in options: + if arch in getattr(paths, opt, {}): + return True + return False + + +def _serialize_paths(conf, section, paths, arch): + conf.add_section(section) + + conf.set(section, "os_tree", paths.os_tree[arch]) + conf.set(section, "os_dir", paths.os_tree[arch]) + conf.set(section, "packages", paths.packages[arch]) + if paths.repository.get(arch, None): + conf.set(section, "repository", paths.repository[arch]) + if paths.isos.get(arch, None): + conf.set(section, "isos", paths.isos[arch]) + conf.set(section, "iso_dir", paths.isos[arch]) + if paths.jigdos.get(arch, None): + conf.set(section, "jigdos", paths.jigdos[arch]) + conf.set(section, "jigdo_dir", paths.jigdos[arch]) + + if any_path(paths, ["source_tree", "source_packages", "source_repository", + "source_isos", "source_jigdos"], arch): + conf.set(section, "source_tree", paths.source_tree[arch]) + conf.set(section, "source_dir", paths.source_tree[arch]) + conf.set(section, "source_packages", paths.source_packages[arch]) + if paths.source_repository.get(arch, None): + conf.set(section, "source_repository", paths.source_repository[arch]) + if paths.source_isos.get(arch, None): + conf.set(section, "source_isos", paths.source_isos[arch]) + conf.set(section, "source_iso_dir", paths.source_isos[arch]) + if paths.source_jigdos.get(arch, None): + conf.set(section, "source_jigdos", paths.source_jigdos[arch]) + conf.set(section, "source_jigdo_dir", paths.source_jigdos[arch]) + + if any_path(paths, ["debug_tree", "debug_packages", "debug_repository"], arch): + conf.set(section, "debug_tree", paths.debug_tree[arch]) + conf.set(section, "debug_dir", paths.debug_tree[arch]) + conf.set(section, "debug_packages", paths.debug_packages[arch]) + if paths.debug_repository.get(arch, None): + conf.set(section, "debug_repository", paths.debug_repository[arch]) + conf.set(section, "debuginfo", paths.debug_repository[arch]) + + +def _serialize_variant(conf, variant): + section = 'variant-%s' % variant.uid + conf.add_section(section) + + conf.set(section, 'id', variant.id) + conf.set(section, 'uid', variant.uid) + conf.set(section, 'name', variant.name) + conf.set(section, 'type', variant.type) + conf.set(section, 'arches', ','.join(sorted(variant.arches))) + + if variant.type == 'layered-product': + _serialize_product(conf, variant.release, section='product-%s' % variant.uid) + + for arch in sorted(variant.arches): + path_section = 'variant-%s.%s' % (variant.uid, arch) + _serialize_paths(conf, path_section, variant.paths, arch) + + children = set() + for child in variant.variants.itervalues(): + _serialize_variant(conf, child) + children.add(child.uid) + + if children: + conf.set(section, 'variants', ','.join(sorted(children))) + + +def _serialize_variants(conf, variants): + ids = sorted(variants.variants.keys()) + conf.set('product', 'variants', ','.join(ids)) + for variant_id in ids: + variant = variants.variants[variant_id] + _serialize_variant(conf, variant) + + +class SortedDict(dict): + """A dictionary that always returns keys sorted.""" + def __iter__(self): + for key in self.keys(): + yield key + + def iterkeys(self): + for key in self.keys(): + yield key + + def itervalues(self): + for key in self.keys(): + yield self[key] + + def keys(self): + return sorted(dict.keys(self), reverse=False) + + def iteritems(self): + for key in self.keys(): + yield (key, self[key]) + + def items(self): + return self.iteritems() diff --git a/tests/composes/DP-1.0-20160720.t.8/compose/.composeinfo b/tests/composes/DP-1.0-20160720.t.8/compose/.composeinfo new file mode 100644 index 0000000..97865bd --- /dev/null +++ b/tests/composes/DP-1.0-20160720.t.8/compose/.composeinfo @@ -0,0 +1,354 @@ +[compose] +date = 20160720 +id = DP-1.0-20160720.t.8 +respin = 8 +type = test + +[product] +family = Dummy Product +name = DP-1.0-20160720.t.8 +short = DP +type = ga +variants = BarTools,Client,Everything,FooTools,Live,Server +version = 1.0 + +[product-Server-Gluster] +is_layered = true +name = Gluster +short = Gluster +type = ga +version = 2.3 + +[variant-Bar-Tools] +arches = x86_64 +id = BarTools +name = Tools +type = variant +uid = Bar-Tools + +[variant-Bar-Tools.x86_64] +debug_dir = Bar-Tools/x86_64/debug/tree +debug_packages = Bar-Tools/x86_64/debug/tree/Packages +debug_repository = Bar-Tools/x86_64/debug/tree +debug_tree = Bar-Tools/x86_64/debug/tree +debuginfo = Bar-Tools/x86_64/debug/tree +iso_dir = Bar-Tools/x86_64/iso +isos = Bar-Tools/x86_64/iso +os_dir = Bar-Tools/x86_64/os +os_tree = Bar-Tools/x86_64/os +packages = Bar-Tools/x86_64/os/Packages +repository = Bar-Tools/x86_64/os +source_dir = Bar-Tools/source/tree +source_iso_dir = Bar-Tools/source/iso +source_isos = Bar-Tools/source/iso +source_packages = Bar-Tools/source/tree/Packages +source_repository = Bar-Tools/source/tree +source_tree = Bar-Tools/source/tree + +[variant-Client] +arches = i386,x86_64 +id = Client +name = Client +type = variant +uid = Client +variants = Client-optional + +[variant-Client-optional] +arches = i386,x86_64 +id = optional +name = optional +type = optional +uid = Client-optional + +[variant-Client-optional.i386] +debug_dir = Client-optional/i386/debug/tree +debug_packages = Client-optional/i386/debug/tree/Packages +debug_repository = Client-optional/i386/debug/tree +debug_tree = Client-optional/i386/debug/tree +debuginfo = Client-optional/i386/debug/tree +os_dir = Client-optional/i386/os +os_tree = Client-optional/i386/os +packages = Client-optional/i386/os/Packages +repository = Client-optional/i386/os +source_dir = Client-optional/source/tree +source_packages = Client-optional/source/tree/Packages +source_repository = Client-optional/source/tree +source_tree = Client-optional/source/tree + +[variant-Client-optional.x86_64] +debug_dir = Client-optional/x86_64/debug/tree +debug_packages = Client-optional/x86_64/debug/tree/Packages +debug_repository = Client-optional/x86_64/debug/tree +debug_tree = Client-optional/x86_64/debug/tree +debuginfo = Client-optional/x86_64/debug/tree +os_dir = Client-optional/x86_64/os +os_tree = Client-optional/x86_64/os +packages = Client-optional/x86_64/os/Packages +repository = Client-optional/x86_64/os +source_dir = Client-optional/source/tree +source_packages = Client-optional/source/tree/Packages +source_repository = Client-optional/source/tree +source_tree = Client-optional/source/tree + +[variant-Client.i386] +debug_dir = Client/i386/debug/tree +debug_packages = Client/i386/debug/tree/Packages +debug_repository = Client/i386/debug/tree +debug_tree = Client/i386/debug/tree +debuginfo = Client/i386/debug/tree +iso_dir = Client/i386/iso +isos = Client/i386/iso +os_dir = Client/i386/os +os_tree = Client/i386/os +packages = Client/i386/os/Packages +repository = Client/i386/os +source_dir = Client/source/tree +source_iso_dir = Client/source/iso +source_isos = Client/source/iso +source_packages = Client/source/tree/Packages +source_repository = Client/source/tree +source_tree = Client/source/tree + +[variant-Client.x86_64] +debug_dir = Client/x86_64/debug/tree +debug_packages = Client/x86_64/debug/tree/Packages +debug_repository = Client/x86_64/debug/tree +debug_tree = Client/x86_64/debug/tree +debuginfo = Client/x86_64/debug/tree +iso_dir = Client/x86_64/iso +isos = Client/x86_64/iso +os_dir = Client/x86_64/os +os_tree = Client/x86_64/os +packages = Client/x86_64/os/Packages +repository = Client/x86_64/os +source_dir = Client/source/tree +source_iso_dir = Client/source/iso +source_isos = Client/source/iso +source_packages = Client/source/tree/Packages +source_repository = Client/source/tree +source_tree = Client/source/tree + +[variant-Everything] +arches = i386,x86_64 +id = Everything +name = Everything +type = variant +uid = Everything + +[variant-Everything.i386] +debug_dir = Everything/i386/debug/tree +debug_packages = Everything/i386/debug/tree/Packages +debug_repository = Everything/i386/debug/tree +debug_tree = Everything/i386/debug/tree +debuginfo = Everything/i386/debug/tree +iso_dir = Everything/i386/iso +isos = Everything/i386/iso +os_dir = Everything/i386/os +os_tree = Everything/i386/os +packages = Everything/i386/os/Packages +repository = Everything/i386/os +source_dir = Everything/source/tree +source_iso_dir = Everything/source/iso +source_isos = Everything/source/iso +source_packages = Everything/source/tree/Packages +source_repository = Everything/source/tree +source_tree = Everything/source/tree + +[variant-Everything.x86_64] +debug_dir = Everything/x86_64/debug/tree +debug_packages = Everything/x86_64/debug/tree/Packages +debug_repository = Everything/x86_64/debug/tree +debug_tree = Everything/x86_64/debug/tree +debuginfo = Everything/x86_64/debug/tree +iso_dir = Everything/x86_64/iso +isos = Everything/x86_64/iso +os_dir = Everything/x86_64/os +os_tree = Everything/x86_64/os +packages = Everything/x86_64/os/Packages +repository = Everything/x86_64/os +source_dir = Everything/source/tree +source_iso_dir = Everything/source/iso +source_isos = Everything/source/iso +source_packages = Everything/source/tree/Packages +source_repository = Everything/source/tree +source_tree = Everything/source/tree + +[variant-Foo-Tools] +arches = x86_64 +id = FooTools +name = Tools +type = variant +uid = Foo-Tools + +[variant-Foo-Tools.x86_64] +debug_dir = Foo-Tools/x86_64/debug/tree +debug_packages = Foo-Tools/x86_64/debug/tree/Packages +debug_repository = Foo-Tools/x86_64/debug/tree +debug_tree = Foo-Tools/x86_64/debug/tree +debuginfo = Foo-Tools/x86_64/debug/tree +iso_dir = Foo-Tools/x86_64/iso +isos = Foo-Tools/x86_64/iso +os_dir = Foo-Tools/x86_64/os +os_tree = Foo-Tools/x86_64/os +packages = Foo-Tools/x86_64/os/Packages +repository = Foo-Tools/x86_64/os +source_dir = Foo-Tools/source/tree +source_iso_dir = Foo-Tools/source/iso +source_isos = Foo-Tools/source/iso +source_packages = Foo-Tools/source/tree/Packages +source_repository = Foo-Tools/source/tree +source_tree = Foo-Tools/source/tree + +[variant-Live] +arches = x86_64 +id = Live +name = Live +type = variant +uid = Live + +[variant-Live.x86_64] +debug_dir = Live/x86_64/debug/tree +debug_packages = Live/x86_64/debug/tree/Packages +debug_repository = Live/x86_64/debug/tree +debug_tree = Live/x86_64/debug/tree +debuginfo = Live/x86_64/debug/tree +iso_dir = Live/x86_64/iso +isos = Live/x86_64/iso +os_dir = Live/x86_64/os +os_tree = Live/x86_64/os +packages = Live/x86_64/os/Packages +repository = Live/x86_64/os +source_dir = Live/source/tree +source_iso_dir = Live/source/iso +source_isos = Live/source/iso +source_packages = Live/source/tree/Packages +source_repository = Live/source/tree +source_tree = Live/source/tree + +[variant-Server] +arches = s390x,x86_64 +id = Server +name = Server +type = variant +uid = Server +variants = Server-Gluster,Server-ResilientStorage,Server-optional + +[variant-Server-Gluster] +arches = x86_64 +id = Gluster +name = Gluster Layered Product +type = layered-product +uid = Server-Gluster + +[variant-Server-Gluster.x86_64] +debug_dir = Server-Gluster/x86_64/debug/tree +debug_packages = Server-Gluster/x86_64/debug/tree/Packages +debug_repository = Server-Gluster/x86_64/debug/tree +debug_tree = Server-Gluster/x86_64/debug/tree +debuginfo = Server-Gluster/x86_64/debug/tree +os_dir = Server-Gluster/x86_64/os +os_tree = Server-Gluster/x86_64/os +packages = Server-Gluster/x86_64/os/Packages +repository = Server-Gluster/x86_64/os +source_dir = Server-Gluster/source/tree +source_packages = Server-Gluster/source/tree/Packages +source_repository = Server-Gluster/source/tree +source_tree = Server-Gluster/source/tree + +[variant-Server-ResilientStorage] +arches = x86_64 +id = ResilientStorage +name = Resilient Storage +type = addon +uid = Server-ResilientStorage + +[variant-Server-ResilientStorage.x86_64] +debug_dir = Server/x86_64/debug/tree +debug_packages = Server/x86_64/debug/tree/addons/ResilientStorage +debug_repository = Server/x86_64/debug/tree/addons/ResilientStorage +debug_tree = Server/x86_64/debug/tree +debuginfo = Server/x86_64/debug/tree/addons/ResilientStorage +os_dir = Server/x86_64/os +os_tree = Server/x86_64/os +packages = Server/x86_64/os/addons/ResilientStorage +repository = Server/x86_64/os/addons/ResilientStorage +source_dir = Server/source/tree +source_packages = Server/source/tree/addons/ResilientStorage +source_repository = Server/source/tree/addons/ResilientStorage +source_tree = Server/source/tree + +[variant-Server-optional] +arches = s390x,x86_64 +id = optional +name = optional +type = optional +uid = Server-optional + +[variant-Server-optional.s390x] +debug_dir = Server-optional/s390x/debug/tree +debug_packages = Server-optional/s390x/debug/tree/Packages +debug_repository = Server-optional/s390x/debug/tree +debug_tree = Server-optional/s390x/debug/tree +debuginfo = Server-optional/s390x/debug/tree +os_dir = Server-optional/s390x/os +os_tree = Server-optional/s390x/os +packages = Server-optional/s390x/os/Packages +repository = Server-optional/s390x/os +source_dir = Server-optional/source/tree +source_packages = Server-optional/source/tree/Packages +source_repository = Server-optional/source/tree +source_tree = Server-optional/source/tree + +[variant-Server-optional.x86_64] +debug_dir = Server-optional/x86_64/debug/tree +debug_packages = Server-optional/x86_64/debug/tree/Packages +debug_repository = Server-optional/x86_64/debug/tree +debug_tree = Server-optional/x86_64/debug/tree +debuginfo = Server-optional/x86_64/debug/tree +os_dir = Server-optional/x86_64/os +os_tree = Server-optional/x86_64/os +packages = Server-optional/x86_64/os/Packages +repository = Server-optional/x86_64/os +source_dir = Server-optional/source/tree +source_packages = Server-optional/source/tree/Packages +source_repository = Server-optional/source/tree +source_tree = Server-optional/source/tree + +[variant-Server.s390x] +debug_dir = Server/s390x/debug/tree +debug_packages = Server/s390x/debug/tree/Packages +debug_repository = Server/s390x/debug/tree +debug_tree = Server/s390x/debug/tree +debuginfo = Server/s390x/debug/tree +iso_dir = Server/s390x/iso +isos = Server/s390x/iso +os_dir = Server/s390x/os +os_tree = Server/s390x/os +packages = Server/s390x/os/Packages +repository = Server/s390x/os +source_dir = Server/source/tree +source_iso_dir = Server/source/iso +source_isos = Server/source/iso +source_packages = Server/source/tree/Packages +source_repository = Server/source/tree +source_tree = Server/source/tree + +[variant-Server.x86_64] +debug_dir = Server/x86_64/debug/tree +debug_packages = Server/x86_64/debug/tree/Packages +debug_repository = Server/x86_64/debug/tree +debug_tree = Server/x86_64/debug/tree +debuginfo = Server/x86_64/debug/tree +iso_dir = Server/x86_64/iso +isos = Server/x86_64/iso +os_dir = Server/x86_64/os +os_tree = Server/x86_64/os +packages = Server/x86_64/os/Packages +repository = Server/x86_64/os +source_dir = Server/source/tree +source_iso_dir = Server/source/iso +source_isos = Server/source/iso +source_packages = Server/source/tree/Packages +source_repository = Server/source/tree +source_tree = Server/source/tree + diff --git a/tests/composes/DP-1.0-20160720.t.8/compose/metadata/composeinfo.json b/tests/composes/DP-1.0-20160720.t.8/compose/metadata/composeinfo.json new file mode 100644 index 0000000..419e0c0 --- /dev/null +++ b/tests/composes/DP-1.0-20160720.t.8/compose/metadata/composeinfo.json @@ -0,0 +1,509 @@ +{ + "header": { + "type": "productmd.composeinfo", + "version": "1.2" + }, + "payload": { + "compose": { + "date": "20160720", + "id": "DP-1.0-20160720.t.8", + "respin": 8, + "type": "test" + }, + "release": { + "name": "Dummy Product", + "short": "DP", + "type": "ga", + "version": "1.0" + }, + "variants": { + "Bar-Tools": { + "arches": [ + "x86_64" + ], + "id": "BarTools", + "name": "Tools", + "paths": { + "debug_packages": { + "x86_64": "Bar-Tools/x86_64/debug/tree/Packages" + }, + "debug_repository": { + "x86_64": "Bar-Tools/x86_64/debug/tree" + }, + "debug_tree": { + "x86_64": "Bar-Tools/x86_64/debug/tree" + }, + "isos": { + "x86_64": "Bar-Tools/x86_64/iso" + }, + "os_tree": { + "x86_64": "Bar-Tools/x86_64/os" + }, + "packages": { + "x86_64": "Bar-Tools/x86_64/os/Packages" + }, + "repository": { + "x86_64": "Bar-Tools/x86_64/os" + }, + "source_isos": { + "x86_64": "Bar-Tools/source/iso" + }, + "source_packages": { + "x86_64": "Bar-Tools/source/tree/Packages" + }, + "source_repository": { + "x86_64": "Bar-Tools/source/tree" + }, + "source_tree": { + "x86_64": "Bar-Tools/source/tree" + } + }, + "type": "variant", + "uid": "Bar-Tools" + }, + "Client": { + "arches": [ + "i386", + "x86_64" + ], + "id": "Client", + "name": "Client", + "paths": { + "debug_packages": { + "i386": "Client/i386/debug/tree/Packages", + "x86_64": "Client/x86_64/debug/tree/Packages" + }, + "debug_repository": { + "i386": "Client/i386/debug/tree", + "x86_64": "Client/x86_64/debug/tree" + }, + "debug_tree": { + "i386": "Client/i386/debug/tree", + "x86_64": "Client/x86_64/debug/tree" + }, + "isos": { + "i386": "Client/i386/iso", + "x86_64": "Client/x86_64/iso" + }, + "os_tree": { + "i386": "Client/i386/os", + "x86_64": "Client/x86_64/os" + }, + "packages": { + "i386": "Client/i386/os/Packages", + "x86_64": "Client/x86_64/os/Packages" + }, + "repository": { + "i386": "Client/i386/os", + "x86_64": "Client/x86_64/os" + }, + "source_isos": { + "i386": "Client/source/iso", + "x86_64": "Client/source/iso" + }, + "source_packages": { + "i386": "Client/source/tree/Packages", + "x86_64": "Client/source/tree/Packages" + }, + "source_repository": { + "i386": "Client/source/tree", + "x86_64": "Client/source/tree" + }, + "source_tree": { + "i386": "Client/source/tree", + "x86_64": "Client/source/tree" + } + }, + "type": "variant", + "uid": "Client", + "variants": [ + "optional" + ] + }, + "Client-optional": { + "arches": [ + "i386", + "x86_64" + ], + "id": "optional", + "name": "optional", + "paths": { + "debug_packages": { + "i386": "Client-optional/i386/debug/tree/Packages", + "x86_64": "Client-optional/x86_64/debug/tree/Packages" + }, + "debug_repository": { + "i386": "Client-optional/i386/debug/tree", + "x86_64": "Client-optional/x86_64/debug/tree" + }, + "debug_tree": { + "i386": "Client-optional/i386/debug/tree", + "x86_64": "Client-optional/x86_64/debug/tree" + }, + "os_tree": { + "i386": "Client-optional/i386/os", + "x86_64": "Client-optional/x86_64/os" + }, + "packages": { + "i386": "Client-optional/i386/os/Packages", + "x86_64": "Client-optional/x86_64/os/Packages" + }, + "repository": { + "i386": "Client-optional/i386/os", + "x86_64": "Client-optional/x86_64/os" + }, + "source_packages": { + "i386": "Client-optional/source/tree/Packages", + "x86_64": "Client-optional/source/tree/Packages" + }, + "source_repository": { + "i386": "Client-optional/source/tree", + "x86_64": "Client-optional/source/tree" + }, + "source_tree": { + "i386": "Client-optional/source/tree", + "x86_64": "Client-optional/source/tree" + } + }, + "type": "optional", + "uid": "Client-optional" + }, + "Everything": { + "arches": [ + "i386", + "x86_64" + ], + "id": "Everything", + "name": "Everything", + "paths": { + "debug_packages": { + "i386": "Everything/i386/debug/tree/Packages", + "x86_64": "Everything/x86_64/debug/tree/Packages" + }, + "debug_repository": { + "i386": "Everything/i386/debug/tree", + "x86_64": "Everything/x86_64/debug/tree" + }, + "debug_tree": { + "i386": "Everything/i386/debug/tree", + "x86_64": "Everything/x86_64/debug/tree" + }, + "isos": { + "i386": "Everything/i386/iso", + "x86_64": "Everything/x86_64/iso" + }, + "os_tree": { + "i386": "Everything/i386/os", + "x86_64": "Everything/x86_64/os" + }, + "packages": { + "i386": "Everything/i386/os/Packages", + "x86_64": "Everything/x86_64/os/Packages" + }, + "repository": { + "i386": "Everything/i386/os", + "x86_64": "Everything/x86_64/os" + }, + "source_isos": { + "i386": "Everything/source/iso", + "x86_64": "Everything/source/iso" + }, + "source_packages": { + "i386": "Everything/source/tree/Packages", + "x86_64": "Everything/source/tree/Packages" + }, + "source_repository": { + "i386": "Everything/source/tree", + "x86_64": "Everything/source/tree" + }, + "source_tree": { + "i386": "Everything/source/tree", + "x86_64": "Everything/source/tree" + } + }, + "type": "variant", + "uid": "Everything" + }, + "Foo-Tools": { + "arches": [ + "x86_64" + ], + "id": "FooTools", + "name": "Tools", + "paths": { + "debug_packages": { + "x86_64": "Foo-Tools/x86_64/debug/tree/Packages" + }, + "debug_repository": { + "x86_64": "Foo-Tools/x86_64/debug/tree" + }, + "debug_tree": { + "x86_64": "Foo-Tools/x86_64/debug/tree" + }, + "isos": { + "x86_64": "Foo-Tools/x86_64/iso" + }, + "os_tree": { + "x86_64": "Foo-Tools/x86_64/os" + }, + "packages": { + "x86_64": "Foo-Tools/x86_64/os/Packages" + }, + "repository": { + "x86_64": "Foo-Tools/x86_64/os" + }, + "source_isos": { + "x86_64": "Foo-Tools/source/iso" + }, + "source_packages": { + "x86_64": "Foo-Tools/source/tree/Packages" + }, + "source_repository": { + "x86_64": "Foo-Tools/source/tree" + }, + "source_tree": { + "x86_64": "Foo-Tools/source/tree" + } + }, + "type": "variant", + "uid": "Foo-Tools" + }, + "Live": { + "arches": [ + "x86_64" + ], + "id": "Live", + "name": "Live", + "paths": { + "debug_packages": { + "x86_64": "Live/x86_64/debug/tree/Packages" + }, + "debug_repository": { + "x86_64": "Live/x86_64/debug/tree" + }, + "debug_tree": { + "x86_64": "Live/x86_64/debug/tree" + }, + "isos": { + "x86_64": "Live/x86_64/iso" + }, + "os_tree": { + "x86_64": "Live/x86_64/os" + }, + "packages": { + "x86_64": "Live/x86_64/os/Packages" + }, + "repository": { + "x86_64": "Live/x86_64/os" + }, + "source_isos": { + "x86_64": "Live/source/iso" + }, + "source_packages": { + "x86_64": "Live/source/tree/Packages" + }, + "source_repository": { + "x86_64": "Live/source/tree" + }, + "source_tree": { + "x86_64": "Live/source/tree" + } + }, + "type": "variant", + "uid": "Live" + }, + "Server": { + "arches": [ + "s390x", + "x86_64" + ], + "id": "Server", + "name": "Server", + "paths": { + "debug_packages": { + "s390x": "Server/s390x/debug/tree/Packages", + "x86_64": "Server/x86_64/debug/tree/Packages" + }, + "debug_repository": { + "s390x": "Server/s390x/debug/tree", + "x86_64": "Server/x86_64/debug/tree" + }, + "debug_tree": { + "s390x": "Server/s390x/debug/tree", + "x86_64": "Server/x86_64/debug/tree" + }, + "isos": { + "s390x": "Server/s390x/iso", + "x86_64": "Server/x86_64/iso" + }, + "os_tree": { + "s390x": "Server/s390x/os", + "x86_64": "Server/x86_64/os" + }, + "packages": { + "s390x": "Server/s390x/os/Packages", + "x86_64": "Server/x86_64/os/Packages" + }, + "repository": { + "s390x": "Server/s390x/os", + "x86_64": "Server/x86_64/os" + }, + "source_isos": { + "s390x": "Server/source/iso", + "x86_64": "Server/source/iso" + }, + "source_packages": { + "s390x": "Server/source/tree/Packages", + "x86_64": "Server/source/tree/Packages" + }, + "source_repository": { + "s390x": "Server/source/tree", + "x86_64": "Server/source/tree" + }, + "source_tree": { + "s390x": "Server/source/tree", + "x86_64": "Server/source/tree" + } + }, + "type": "variant", + "uid": "Server", + "variants": [ + "Gluster", + "ResilientStorage", + "optional" + ] + }, + "Server-Gluster": { + "arches": [ + "x86_64" + ], + "id": "Gluster", + "name": "Gluster Layered Product", + "paths": { + "debug_packages": { + "x86_64": "Server-Gluster/x86_64/debug/tree/Packages" + }, + "debug_repository": { + "x86_64": "Server-Gluster/x86_64/debug/tree" + }, + "debug_tree": { + "x86_64": "Server-Gluster/x86_64/debug/tree" + }, + "os_tree": { + "x86_64": "Server-Gluster/x86_64/os" + }, + "packages": { + "x86_64": "Server-Gluster/x86_64/os/Packages" + }, + "repository": { + "x86_64": "Server-Gluster/x86_64/os" + }, + "source_packages": { + "x86_64": "Server-Gluster/source/tree/Packages" + }, + "source_repository": { + "x86_64": "Server-Gluster/source/tree" + }, + "source_tree": { + "x86_64": "Server-Gluster/source/tree" + } + }, + "release": { + "is_layered": true, + "name": "Gluster", + "short": "Gluster", + "type": "ga", + "version": "2.3" + }, + "type": "layered-product", + "uid": "Server-Gluster" + }, + "Server-ResilientStorage": { + "arches": [ + "x86_64" + ], + "id": "ResilientStorage", + "name": "Resilient Storage", + "paths": { + "debug_packages": { + "x86_64": "Server/x86_64/debug/tree/addons/ResilientStorage" + }, + "debug_repository": { + "x86_64": "Server/x86_64/debug/tree/addons/ResilientStorage" + }, + "debug_tree": { + "x86_64": "Server/x86_64/debug/tree" + }, + "os_tree": { + "x86_64": "Server/x86_64/os" + }, + "packages": { + "x86_64": "Server/x86_64/os/addons/ResilientStorage" + }, + "repository": { + "x86_64": "Server/x86_64/os/addons/ResilientStorage" + }, + "source_packages": { + "x86_64": "Server/source/tree/addons/ResilientStorage" + }, + "source_repository": { + "x86_64": "Server/source/tree/addons/ResilientStorage" + }, + "source_tree": { + "x86_64": "Server/source/tree" + } + }, + "type": "addon", + "uid": "Server-ResilientStorage" + }, + "Server-optional": { + "arches": [ + "s390x", + "x86_64" + ], + "id": "optional", + "name": "optional", + "paths": { + "debug_packages": { + "s390x": "Server-optional/s390x/debug/tree/Packages", + "x86_64": "Server-optional/x86_64/debug/tree/Packages" + }, + "debug_repository": { + "s390x": "Server-optional/s390x/debug/tree", + "x86_64": "Server-optional/x86_64/debug/tree" + }, + "debug_tree": { + "s390x": "Server-optional/s390x/debug/tree", + "x86_64": "Server-optional/x86_64/debug/tree" + }, + "os_tree": { + "s390x": "Server-optional/s390x/os", + "x86_64": "Server-optional/x86_64/os" + }, + "packages": { + "s390x": "Server-optional/s390x/os/Packages", + "x86_64": "Server-optional/x86_64/os/Packages" + }, + "repository": { + "s390x": "Server-optional/s390x/os", + "x86_64": "Server-optional/x86_64/os" + }, + "source_packages": { + "s390x": "Server-optional/source/tree/Packages", + "x86_64": "Server-optional/source/tree/Packages" + }, + "source_repository": { + "s390x": "Server-optional/source/tree", + "x86_64": "Server-optional/source/tree" + }, + "source_tree": { + "s390x": "Server-optional/source/tree", + "x86_64": "Server-optional/source/tree" + } + }, + "type": "optional", + "uid": "Server-optional" + } + } + } +} \ No newline at end of file diff --git a/tests/test_legacy_composeinfo.py b/tests/test_legacy_composeinfo.py new file mode 100644 index 0000000..50da51c --- /dev/null +++ b/tests/test_legacy_composeinfo.py @@ -0,0 +1,32 @@ +# -*- encoding: utf-8 -*- + +import unittest +import os +import StringIO +import sys + +import productmd.compose + +sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) + +from compose_utils.legacy import write_legacy_composeinfo + + +BASE_PATH = os.path.join(os.path.dirname(__file__), 'composes', 'DP-1.0-20160720.t.8') + + +class LegacyComposeInfoTest(unittest.TestCase): + + def setUp(self): + self.compose = productmd.compose.Compose(BASE_PATH) + + def test_write_legacy_file(self): + output = StringIO.StringIO() + write_legacy_composeinfo(self.compose.info, output) + with open(os.path.join(BASE_PATH, 'compose', '.composeinfo')) as f: + expected = f.read().split() + self.assertEqual(output.getvalue().split(), expected) + + +if __name__ == '__main__': + unittest.main()