| |
@@ -205,12 +205,47 @@
|
| |
)
|
| |
return result
|
| |
|
| |
+ def image_id(self, img):
|
| |
+ """Get a unique identifier for an image. Currently we use a
|
| |
+ 3-tuple (subvariant, type, arch). Should produce a sensible
|
| |
+ human-readable text when run through " ".join(). Should also
|
| |
+ be hashable for use as a dict key.
|
| |
+ """
|
| |
+ return (img['subvariant'], img['type'], img['arch'])
|
| |
+
|
| |
+ def get_images(self, compose):
|
| |
+ """Parse a compose's image list and return a dict whose keys
|
| |
+ are image identifiers (whatever self.image_id gives) and whose
|
| |
+ values are the original Image instances `serialize`d into
|
| |
+ dicts.
|
| |
+ """
|
| |
+ imgs = {}
|
| |
+ imgdict = compose.images.images
|
| |
+ for variant in imgdict:
|
| |
+ for arch in imgdict[variant]:
|
| |
+ for img in imgdict[variant][arch]:
|
| |
+ # the way Image.serialize works is a bit odd...
|
| |
+ parser = []
|
| |
+ img.serialize(parser)
|
| |
+ img = parser[0]
|
| |
+ imgs[self.image_id(img)] = img
|
| |
+ return imgs
|
| |
+
|
| |
def get_changelog(self, old_compose, new_compose, max_logs=-1):
|
| |
result = {}
|
| |
|
| |
result["old_compose"] = old_compose.rpms.compose.id
|
| |
result["new_compose"] = new_compose.rpms.compose.id
|
| |
|
| |
+ imgs_old = self.get_images(old_compose)
|
| |
+ imgs_new = self.get_images(new_compose)
|
| |
+ imgs_old_ids = set(imgs_old.keys())
|
| |
+ imgs_new_ids = set(imgs_new.keys())
|
| |
+ result["added_images"] = [imgs_new[imid] for imid in
|
| |
+ imgs_new_ids - imgs_old_ids]
|
| |
+ result["dropped_images"] = [imgs_old[imid] for imid in
|
| |
+ imgs_old_ids - imgs_new_ids]
|
| |
+
|
| |
srpms_old = self.get_srpms(old_compose)
|
| |
srpms_new = self.get_srpms(new_compose)
|
| |
|
| |
@@ -235,6 +270,8 @@
|
| |
pkgs_changed = set(rpm_headers_old) & set(rpm_headers_new)
|
| |
|
| |
result["summary"] = {
|
| |
+ "added_images": len(result["added_images"]),
|
| |
+ "dropped_images": len(result["dropped_images"]),
|
| |
"added_packages": 0,
|
| |
"dropped_packages": 0,
|
| |
"upgraded_packages": 0,
|
| |
@@ -321,6 +358,8 @@
|
| |
def _get_summary(self, changelog_data):
|
| |
result = []
|
| |
result.append("===== SUMMARY =====")
|
| |
+ result.append("Added images: %s" % changelog_data["summary"]["added_images"])
|
| |
+ result.append("Dropped images: %s" % changelog_data["summary"]["dropped_images"])
|
| |
result.append("Added packages: %s" % changelog_data["summary"]["added_packages"])
|
| |
result.append("Dropped packages: %s" % changelog_data["summary"]["dropped_packages"])
|
| |
result.append("Upgraded packages: %s" % changelog_data["summary"]["upgraded_packages"])
|
| |
@@ -347,6 +386,16 @@
|
| |
|
| |
result.extend(self._get_summary(changelog_data))
|
| |
|
| |
+ result.append("===== ADDED IMAGES =====")
|
| |
+ for i in changelog_data["added_images"]:
|
| |
+ result.append(" ".join(self.image_id(i)))
|
| |
+ result.append("")
|
| |
+
|
| |
+ result.append("===== DROPPED IMAGES =====")
|
| |
+ for i in changelog_data["dropped_images"]:
|
| |
+ result.append(" ".join(self.image_id(i)))
|
| |
+ result.append("")
|
| |
+
|
| |
result.append("===== ADDED PACKAGES =====")
|
| |
for i in changelog_data["added_packages"]:
|
| |
result.append("%(name)s: %(nvr)s" % i)
|
| |
@@ -377,6 +426,18 @@
|
| |
|
| |
result.extend(self._get_summary(changelog_data))
|
| |
|
| |
+ result.append("===== ADDED IMAGES =====")
|
| |
+ for i in changelog_data["added_images"]:
|
| |
+ result.append("Image: %s" % " ".join(self.image_id(i)))
|
| |
+ result.append("Path: %s" % i['path'])
|
| |
+ result.append("")
|
| |
+
|
| |
+ result.append("===== DROPPED IMAGES =====")
|
| |
+ for i in changelog_data["dropped_images"]:
|
| |
+ result.append("Image: %s" % " ".join(self.image_id(i)))
|
| |
+ result.append("Path: %s" % i['path'])
|
| |
+ result.append("")
|
| |
+
|
| |
result.append("===== ADDED PACKAGES =====")
|
| |
for i in changelog_data["added_packages"]:
|
| |
result.append("Package: %s" % i["nvr"])
|
| |
Why did you remove this?