From 12229320071316508117948b092e81903ca92611 Mon Sep 17 00:00:00 2001 From: Sylvain Baubeau Date: Sat, 25 Mar 2023 15:10:08 +0100 Subject: [PATCH] Use version from zap.json to download zap (#25791) --- scripts/tools/zap/zap_download.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/tools/zap/zap_download.py b/scripts/tools/zap/zap_download.py index 951691d65fbd19..1418133f8df4bd 100755 --- a/scripts/tools/zap/zap_download.py +++ b/scripts/tools/zap/zap_download.py @@ -16,9 +16,9 @@ import enum import io +import json import logging import os -import re import shlex import shutil import subprocess @@ -141,19 +141,19 @@ def _GetZapVersionToUse(project_root): # This heuristic may be bad at times, however then you can also override the # version in command line parameters - match_re = re.compile(r'.*ENV\s+ZAP_VERSION=([^# ]*)') - - docker_path = os.path.join(project_root, "integrations/docker/images/chip-build/Dockerfile") - - with open(docker_path, 'rt') as f: - for l in f.readlines(): - l = l.strip() - m = match_re.match(l) - if not m: - continue - return m.group(1) - - raise Exception(f"Failed to determine version from {docker_path}") + zap_version = "" + zap_path = os.path.join(project_root, "scripts/setup/zap.json") + zap_json = json.load(open(zap_path)) + for package in zap_json.get("packages", []): + for tag in package.get("tags", []): + if tag.startswith("version:2@"): + zap_version = tag.removeprefix("version:2@") + suffix_index = zap_version.rfind(".") + if suffix_index != -1: + zap_version = zap_version[:suffix_index] + return zap_version + + raise Exception(f"Failed to determine version from {zap_path}") @click.command()