diff --git a/.github/workflows/update-hook-manifest.yml b/.github/workflows/update-hook-manifest.yml index a8ab214..115bb0f 100644 --- a/.github/workflows/update-hook-manifest.yml +++ b/.github/workflows/update-hook-manifest.yml @@ -7,7 +7,7 @@ on: - 'store/encodings/*' - 'store/fonts/*' - 'store/offsets/*' - - 'metadata/hook.json' + - 'metadata/hook_v2.json' - '.github/workflows/update-hook-manifest.yml' pull_request: branches: @@ -17,7 +17,7 @@ on: - 'store/encodings/*' - 'store/fonts/*' - 'store/offsets/*' - - 'metadata/hook.json' + - 'metadata/hook_v2.json' - '.github/workflows/update-hook-manifest.yml' jobs: diff --git a/README.md b/README.md index 0d6a431..62728a3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,10 @@ Data backend for [dfint installer](https://github.com/dfint/installer). -- [`metadata/hook.json`](metadata/hook.json) contains info about releases of [df-steam-hook-rs](https://github.com/dfint/df-steam-hook-rs), configs, offset files - [`metadata/hook_v2.json`](metadata/hook_v2.json) metadata for installer 0.2.0 and higher, also contains info about [dfhooks](https://github.com/DFHack/dfhooks) library - [`metadata/dict.json`](metadata/dict.json) contains info about localization languages: url of their csv files, font files, encoding specific configs - [`store`](store) directory contains files referenced from metadata, like encoding specific configs, offsets for different DF versions, and other misc. stuff. + +Legacy, not updated anymore: + +- [`metadata/hook.json`](metadata/hook.json) contains info about releases of [df-steam-hook-rs](https://github.com/dfint/df-steam-hook-rs), configs, offset files for installer older then 0.2.0. diff --git a/automation/hook_manifest_add.py b/automation/hook_manifest_add.py index 38d478a..a72be1a 100644 --- a/automation/hook_manifest_add.py +++ b/automation/hook_manifest_add.py @@ -15,8 +15,7 @@ base_dir = Path(__file__).parent.parent # base directory of the repository -hook_json_path = base_dir / "metadata/hook.json" -hook_v2_json_path = base_dir / "metadata/hook_v2.json" +hook_json_path = base_dir / "metadata/hook_v2.json" offsets_toml_path = base_dir / "store/offsets" config_path = base_dir / "store" @@ -32,22 +31,18 @@ class ConfigItem(NamedTuple): hook_lib_url: str config_url: str offsets_url: str - dfhooks_url: str | None + dfhooks_url: str def dict(self) -> dict[str, Any]: - item = { + return { "df": self.df_checksum, "checksum": self.payload_checksum, "lib": self.hook_lib_url, "config": self.config_url, "offsets": self.offsets_url, + "dfhooks": self.dfhooks_url, } - if self.dfhooks_url: - item["dfhooks"] = self.dfhooks_url - - return item - def update_or_append(manifest_path: str, config_item: ConfigItem): hook_manifest = json.loads(manifest_path.read_text()) @@ -72,21 +67,9 @@ def main(hook_lib_url: str, config_file_name: str, offsets_file_name: str, dfhoo df_checksum = offsets_data["metadata"]["checksum"] payload_checksum = crc32(res_hook + res_config + res_offsets) payload_checksum_v2 = crc32(res_hook + res_config + res_offsets + res_dfhooks) - - update_or_append( - hook_json_path, - ConfigItem( - df_checksum, - payload_checksum, - hook_lib_url, - config_base_url + config_file_name, - offsets_base_url + offsets_file_name, - None, - ) - ) update_or_append( - hook_v2_json_path, + hook_json_path, ConfigItem( df_checksum, payload_checksum_v2, diff --git a/automation/hook_manifest_update.py b/automation/hook_manifest_update.py index 30c54c2..40bffdf 100644 --- a/automation/hook_manifest_update.py +++ b/automation/hook_manifest_update.py @@ -13,27 +13,23 @@ def main(): base_dir = Path(__file__).parent.parent # base directory of the repository - hook_json_path = [ - base_dir / "metadata/hook.json", - base_dir / "metadata/hook_v2.json", - ] - - for path in hook_json_path: - manifest = json.loads(path.read_text(encoding="utf-8")) - - for item in manifest: - print(f"Recalculating checksum for {item["df"]=}...") - try: - data = get_from_url(item["lib"]) + get_from_url(item["config"]) + get_from_url(item["offsets"]) - if item.get("dfhooks"): - data += get_from_url(item["dfhooks"]) - checksum = binascii.crc32(data) - item["checksum"] = checksum - except Exception as ex: - print(f"Failed on recalculation {item["df"]=}") - raise - - path.write_text(json.dumps(manifest, indent=2, ensure_ascii=False), encoding="utf-8") + path = base_dir / "metadata/hook_v2.json" + + manifest = json.loads(path.read_text(encoding="utf-8")) + + for item in manifest: + print(f"Recalculating checksum for {item["df"]=}...") + try: + data = get_from_url(item["lib"]) + get_from_url(item["config"]) + get_from_url(item["offsets"]) + if item.get("dfhooks"): + data += get_from_url(item["dfhooks"]) + checksum = binascii.crc32(data) + item["checksum"] = checksum + except Exception as ex: + print(f"Failed on recalculation {item["df"]=}") + raise + + path.write_text(json.dumps(manifest, indent=2, ensure_ascii=False), encoding="utf-8") if __name__ == "__main__":