2022-05-15 20:31:22 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
import json
|
|
|
|
|
|
|
|
old_drv = sys.argv[1]
|
|
|
|
new_drv = sys.argv[2]
|
|
|
|
|
|
|
|
# Read both derivations recursively
|
|
|
|
|
2022-05-15 20:54:48 +00:00
|
|
|
old_derivation = json.load(open(old_drv))
|
|
|
|
new_derivation = json.load(open(new_drv))
|
2022-05-15 20:31:22 +00:00
|
|
|
|
|
|
|
packages = {}
|
|
|
|
|
2023-01-13 20:11:44 +00:00
|
|
|
|
|
|
|
def get_name(drv):
|
|
|
|
if "pname" in drv["env"]:
|
|
|
|
return drv["env"]["pname"]
|
|
|
|
name = drv["env"]["name"]
|
|
|
|
if "version" in drvData["env"]:
|
|
|
|
return name.removesuffix("-" + drvData["env"]["version"])
|
|
|
|
return name
|
|
|
|
|
|
|
|
|
2022-05-15 20:31:22 +00:00
|
|
|
for drv in old_derivation:
|
|
|
|
drvData = old_derivation[drv]
|
2022-06-19 05:56:08 +00:00
|
|
|
if not "pname" in drvData["env"] and not "name" in drvData["env"]:
|
|
|
|
continue
|
2023-01-13 20:11:44 +00:00
|
|
|
used_name = get_name(drvData)
|
2022-06-19 06:06:09 +00:00
|
|
|
if not "version" in drvData["env"]:
|
|
|
|
continue
|
|
|
|
version = drvData["env"]["version"]
|
2022-06-19 05:46:18 +00:00
|
|
|
if used_name in packages:
|
|
|
|
packages[used_name]["old"].add(version)
|
|
|
|
else:
|
|
|
|
packages[used_name] = {"old": {version}}
|
2022-05-15 20:31:22 +00:00
|
|
|
|
|
|
|
for drv in new_derivation:
|
|
|
|
drvData = new_derivation[drv]
|
2022-06-19 05:56:08 +00:00
|
|
|
if not "pname" in drvData["env"] and not "name" in drvData["env"]:
|
|
|
|
continue
|
2023-01-13 20:11:44 +00:00
|
|
|
used_name = get_name(drvData)
|
2022-06-19 06:06:09 +00:00
|
|
|
if not "version" in drvData["env"]:
|
|
|
|
continue
|
|
|
|
version = drvData["env"]["version"]
|
2022-06-19 05:46:18 +00:00
|
|
|
if used_name in packages:
|
|
|
|
if "new" in packages[used_name]:
|
|
|
|
packages[used_name]["new"].add(version)
|
2022-05-15 20:31:22 +00:00
|
|
|
else:
|
2022-06-19 05:46:18 +00:00
|
|
|
packages[used_name]["new"] = {version}
|
|
|
|
else:
|
|
|
|
packages[used_name] = {"new": {version}}
|
2022-05-15 20:31:22 +00:00
|
|
|
|
2023-01-13 20:11:44 +00:00
|
|
|
pkg_names = sorted(packages)
|
|
|
|
|
|
|
|
print("New packages")
|
|
|
|
for package in pkg_names:
|
|
|
|
if "new" in packages[package] and "old" not in packages[package]:
|
|
|
|
print(package + ": " + ", ".join(sorted(packages[package]["new"])))
|
|
|
|
|
|
|
|
print()
|
|
|
|
print("Old packages")
|
|
|
|
for package in pkg_names:
|
|
|
|
if "old" in packages[package] and "new" not in packages[package]:
|
|
|
|
print(package + ": " + ", ".join(sorted(packages[package]["old"])))
|
|
|
|
|
|
|
|
print()
|
|
|
|
print("Updated packages")
|
|
|
|
for package in pkg_names:
|
2022-05-15 20:31:22 +00:00
|
|
|
if "old" in packages[package] and "new" in packages[package]:
|
2023-01-13 20:11:44 +00:00
|
|
|
if packages[package]["old"] == packages[package]["new"]:
|
|
|
|
continue
|
|
|
|
common_versions = packages[package]["old"].intersection(
|
|
|
|
packages[package]["new"])
|
|
|
|
removed_versions = packages[package]["old"].difference(common_versions)
|
|
|
|
added_versions = packages[package]["new"].difference(common_versions)
|
|
|
|
common_versions_string = ", ".join(sorted(common_versions))
|
|
|
|
removed_versions_string = ", ".join(sorted(removed_versions))
|
|
|
|
added_versions_string = ", ".join(sorted(added_versions))
|
|
|
|
print(
|
|
|
|
f"{package}: [{removed_versions_string}] -> [{added_versions_string}] (common: {common_versions_string})"
|
|
|
|
)
|