From 9c22356b423e0ea4ff55316108f68910f77e073e Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Nov 25 2016 08:45:00 +0000 Subject: Fix copying disk images Productmd does not list the path to that particular directory. We need to iterate over images.json and to extract paths from there. Fixes: https://pagure.io/pungi-fedora/issue/112 Signed-off-by: Lubomír Sedlář --- diff --git a/compose_utils/copy_compose.py b/compose_utils/copy_compose.py index bb464dd..189b5d9 100644 --- a/compose_utils/copy_compose.py +++ b/compose_utils/copy_compose.py @@ -69,6 +69,25 @@ def _collect_variant(compose, variant, dest, arch=None): elif arch in paths: sources.add(paths[arch]) + # Collect image paths: The images directory is not listed in + # composeinfo.json, therefore we iterate over relevant part of images.json + # to extract paths from there. + images = [] + try: + variant_images = compose.images.images[variant.uid] + if arch: + images = variant_images[arch] + else: + for vararch_images in variant_images.itervalues(): + images.extend(vararch_images) + except (KeyError, RuntimeError): + # Ignore missing images metadata or no images in the variant/arch + # combination. + pass + for image in images: + if not arch or image.arch == arch: + sources.add(os.path.dirname(image.path)) + return sources diff --git a/tests/composes/DP-1.0-20160315.t.0/compose/Server/x86_64/images/DP-1.0-20160315.t.0-Server-x86_64-sda1.raw.xz b/tests/composes/DP-1.0-20160315.t.0/compose/Server/x86_64/images/DP-1.0-20160315.t.0-Server-x86_64-sda1.raw.xz new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/composes/DP-1.0-20160315.t.0/compose/Server/x86_64/images/DP-1.0-20160315.t.0-Server-x86_64-sda1.raw.xz diff --git a/tests/composes/DP-1.0-20160315.t.0/compose/metadata/images.json b/tests/composes/DP-1.0-20160315.t.0/compose/metadata/images.json index e81291a..0166aa8 100644 --- a/tests/composes/DP-1.0-20160315.t.0/compose/metadata/images.json +++ b/tests/composes/DP-1.0-20160315.t.0/compose/metadata/images.json @@ -116,6 +116,23 @@ "type": "dvd", "volume_id": "DP-1.0 Server.x86_64", "subvariant": "Server" + }, + { + "arch": "x86_64", + "bootable": true, + "checksums": { + "sha256": "cb47ccafe3357a63bb14c066dcadc1e4621d7331d20f34c735b90ec620e747cc" + }, + "disc_count": 1, + "disc_number": 1, + "format": "raw.xz", + "implant_md5": null, + "mtime": 1458031335, + "path": "Server/x86_64/images/DP-1.0-20160315.t.0-Server-x86_64-sda1.raw.xz", + "size": 577536, + "type": "raw-xz", + "volume_id": null, + "subvariant": "Server" } ] } diff --git a/tests/composes/DP-1.0-20160315.t.1/compose/Server/x86_64/images/DP-1.0-20160315.t.1-Server-x86_64-sda1.raw.xz b/tests/composes/DP-1.0-20160315.t.1/compose/Server/x86_64/images/DP-1.0-20160315.t.1-Server-x86_64-sda1.raw.xz new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/composes/DP-1.0-20160315.t.1/compose/Server/x86_64/images/DP-1.0-20160315.t.1-Server-x86_64-sda1.raw.xz diff --git a/tests/composes/DP-1.0-20160315.t.1/compose/metadata/images.json b/tests/composes/DP-1.0-20160315.t.1/compose/metadata/images.json index 7cdc9d7..d5a2dfc 100644 --- a/tests/composes/DP-1.0-20160315.t.1/compose/metadata/images.json +++ b/tests/composes/DP-1.0-20160315.t.1/compose/metadata/images.json @@ -116,6 +116,23 @@ "type": "dvd", "volume_id": "DP-1.0 Server.x86_64", "subvariant": "Server" + }, + { + "arch": "x86_64", + "bootable": true, + "checksums": { + "sha256": "cb47ccafe3357a63bb14c066dcadc1e4621d7331d20f34c735b90ec620e747cc" + }, + "disc_count": 1, + "disc_number": 1, + "format": "raw.xz", + "implant_md5": null, + "mtime": 1458031335, + "path": "Server/x86_64/images/DP-1.0-20160315.t.1-Server-x86_64-sda1.raw.xz", + "size": 577536, + "type": "raw-xz", + "volume_id": null, + "subvariant": "Server" } ] }