From a551922c84f8985f37549a79af311172dfba603d Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Sat, 11 Jan 2025 15:47:07 +0100 Subject: [PATCH] Adapt download.py to run as a package script --- .../src/component_hash_update/download.py | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/scripts/component_hash_update/src/component_hash_update/download.py b/scripts/component_hash_update/src/component_hash_update/download.py index 7b7c6e602..aa64d5982 100644 --- a/scripts/component_hash_update/src/component_hash_update/download.py +++ b/scripts/component_hash_update/src/component_hash_update/download.py @@ -318,32 +318,36 @@ def download_hash(only_downloads: [str]) -> None: yaml.dump(data, checksums_yml) logger.info("Updated %s", CHECKSUMS_YML) -parser = argparse.ArgumentParser(description=f"Add new patch versions hashes in {CHECKSUMS_YML}", - formatter_class=argparse.RawTextHelpFormatter, - epilog=f""" - This script only lookup new patch versions relative to those already existing - in the data in {CHECKSUMS_YML}, - which means it won't add new major or minor versions. - In order to add one of these, edit {CHECKSUMS_YML} - by hand, adding the new versions with a patch number of 0 (or the lowest relevant patch versions) - and a hash value of 0. - ; then run this script. - - Note that the script will try to add the versions on all - architecture keys already present for a given download target. - - EXAMPLES: - - crictl_checksums: - ... - amd64: -+ 1.30.0: 0 - 1.29.0: d16a1ffb3938f5a19d5c8f45d363bd091ef89c0bc4d44ad16b933eede32fdcbb - 1.28.0: 8dc78774f7cbeaf787994d386eec663f0a3cf24de1ea4893598096cb39ef2508""" - -) -parser.add_argument('binaries', nargs='*', choices=downloads.keys(), - help='if provided, only obtain hashes for these compoments') - -args = parser.parse_args() -download_hash(args.binaries) + +def main(): + + logging.basicConfig(stream=sys.stdout, level=logging.INFO) + parser = argparse.ArgumentParser(description=f"Add new patch versions hashes in {CHECKSUMS_YML}", + formatter_class=argparse.RawTextHelpFormatter, + epilog=f""" + This script only lookup new patch versions relative to those already existing + in the data in {CHECKSUMS_YML}, + which means it won't add new major or minor versions. + In order to add one of these, edit {CHECKSUMS_YML} + by hand, adding the new versions with a patch number of 0 (or the lowest relevant patch versions) + and a hash value of 0. + ; then run this script. + + Note that the script will try to add the versions on all + architecture keys already present for a given download target. + + EXAMPLES: + + crictl_checksums: + ... + amd64: + + 1.30.0: 0 + 1.29.0: d16a1ffb3938f5a19d5c8f45d363bd091ef89c0bc4d44ad16b933eede32fdcbb + 1.28.0: 8dc78774f7cbeaf787994d386eec663f0a3cf24de1ea4893598096cb39ef2508""" + + ) + parser.add_argument('binaries', nargs='*', choices=downloads.keys(), + help='if provided, only obtain hashes for these compoments') + + args = parser.parse_args() + download_hash(args.binaries)