chromium: Extend update.py to print a summary of the updates

As a first step to automate the commit messages as well.

+26
+26
pkgs/applications/networking/browsers/chromium/update.py
··· 102 } 103 104 105 channels = {} 106 last_channels = load_json(JSON_PATH) 107 ··· 174 sorted_channels = OrderedDict(sorted(channels.items(), key=get_channel_key)) 175 json.dump(sorted_channels, out, indent=2) 176 out.write('\n')
··· 102 } 103 104 105 + def channel_name_to_attr_name(channel_name): 106 + """Maps a channel name to the corresponding main Nixpkgs attribute name.""" 107 + if channel_name == 'stable': 108 + return 'chromium' 109 + if channel_name == 'beta': 110 + return 'chromiumBeta' 111 + if channel_name == 'dev': 112 + return 'chromiumDev' 113 + if channel_name == 'ungoogled-chromium': 114 + return 'ungoogled-chromium' 115 + print(f'Error: Unexpected channel: {channel_name}', file=sys.stderr) 116 + sys.exit(1) 117 + 118 + 119 + def print_updates(channels_old, channels_new): 120 + """Print a summary of the updates.""" 121 + print('Updates:') 122 + for channel_name in channels_old: 123 + version_old = channels_old[channel_name]["version"] 124 + version_new = channels_new[channel_name]["version"] 125 + if version_old < version_new: 126 + attr_name = channel_name_to_attr_name(channel_name) 127 + print(f'- {attr_name}: {version_old} -> {version_new}') 128 + 129 + 130 channels = {} 131 last_channels = load_json(JSON_PATH) 132 ··· 199 sorted_channels = OrderedDict(sorted(channels.items(), key=get_channel_key)) 200 json.dump(sorted_channels, out, indent=2) 201 out.write('\n') 202 + print_updates(last_channels, sorted_channels)