@@ -159,7 +159,7 @@ def post_process_generated_files(output_path: Path):
159159 continue
160160
161161
162- def synchronize_zcl_with_base (zcl_json : Path ):
162+ def synchronize_zcl_with_base (zcl_json : Path , matter_path : Path = DEFAULT_MATTER_PATH ):
163163 """
164164 Synchronizes a zcl.json file with the base/default zcl.json from Matter SDK.
165165
@@ -170,15 +170,15 @@ def synchronize_zcl_with_base(zcl_json: Path):
170170
171171 print (f"Synchronizing { zcl_json } with base zcl.json" )
172172
173- base_zcl_path = DEFAULT_MATTER_PATH / DEFAULT_ZCL_JSON_RELATIVE_PATH
173+ base_zcl_path = matter_path / DEFAULT_ZCL_JSON_RELATIVE_PATH
174174 with open (base_zcl_path , 'r' ) as f :
175175 base_zcl_data = json .load (f )
176176
177177 with open (zcl_json , 'r' ) as f :
178178 target_zcl_data = json .load (f )
179179
180180 modified = False
181- fields_to_skip = {'xmlRoot' } # Fields to skip in comparison
181+ fields_to_skip = {'xmlRoot' , 'manufacturersXml' } # Fields to skip in comparison
182182
183183 for key , value in base_zcl_data .items ():
184184 if key in fields_to_skip :
@@ -188,6 +188,10 @@ def synchronize_zcl_with_base(zcl_json: Path):
188188 target_zcl_data [key ] = value
189189 modified = True
190190 print (f"Added missing field: '{ key } '" )
191+ if value != target_zcl_data [key ]:
192+ target_zcl_data [key ] = value
193+ modified = True
194+ print (f"Updated field: '{ key } '" )
191195
192196 if modified :
193197 with open (zcl_json , 'w' ) as f :
@@ -199,9 +203,23 @@ def synchronize_zcl_with_base(zcl_json: Path):
199203 print ("Done" )
200204
201205
206+ def fix_sandbox_permissions (e : subprocess .CalledProcessError ) -> None :
207+ """
208+ Fix sandbox permissions if needed.
209+ """
210+ if e .returncode == - 5 :
211+ log .inf ("\n The wrong sandbox permissions are used. Do you wanto to add the permissions to the sandbox?" )
212+ answer = input ("y/n: " )
213+ if answer == "y" :
214+ subprocess .check_call (['sudo' , 'chown' , 'root' , str (
215+ self .get_install_path () / 'chrome-sandbox' )])
216+ subprocess .check_call (['sudo' , 'chmod' , '4755' , str (self .get_install_path () / 'chrome-sandbox' )])
217+ log .inf ("Permissions added to the sandbox" )
218+
219+
202220class ZapInstaller :
203221 INSTALL_DIR = Path ('.zap-install' )
204- ZAP_URL_PATTERN = 'https://github.com/project-chip/zap/releases/download/v%04d.%02d.%02d /%s.zip'
222+ ZAP_URL_PATTERN = 'https://github.com/project-chip/zap/releases/download/%s /%s.zip'
205223
206224 def __init__ (self , matter_path : Path ):
207225 self .matter_path = matter_path
@@ -261,22 +279,20 @@ def get_zap_cli_path(self) -> Path:
261279 """
262280 return self .install_path / self .zap_cli_exe
263281
264- def get_recommended_version (self ) -> Tuple [ int , int , int ] :
282+ def get_recommended_version (self ) -> str :
265283 """
266284 Returns ZAP package recommended version as a tuple of integers.
267285
268- Parses zap_execution.py script from Matter SDK to determine the minimum
269- required ZAP package version.
286+ Reads the version from zap.version file in Matter SDK.
287+ Expected format: v{YEAR}.{MONTH}.{DAY}[-suffix]
288+ Example: v2025.09.23-nightly
270289 """
271- RE_MIN_ZAP_VERSION = r'MIN_ZAP_VERSION\s*=\s*\'(\d+)\.(\d+)\.(\d+)'
272- zap_execution_path = self .matter_path / 'scripts/tools/zap/zap_execution.py'
290+ zap_version_path = self .matter_path / 'scripts/setup/zap.version'
273291
274- with open (zap_execution_path , 'r' ) as f :
275- if match := re .search (RE_MIN_ZAP_VERSION , f .read ()):
276- return tuple (int (group ) for group in match .groups ())
277- raise RuntimeError (f'Failed to find MIN_ZAP_VERSION in { zap_execution_path } ' )
292+ with open (zap_version_path , 'r' ) as f :
293+ return f .read ().strip ()
278294
279- def get_current_version (self ) -> Tuple [ int , int , int ] :
295+ def get_current_version (self ) -> str :
280296 """
281297 Returns ZAP package current version as a tuple of integers.
282298
@@ -292,7 +308,7 @@ def get_current_version(self) -> Tuple[int, int, int]:
292308
293309 RE_VERSION = r'Version:\s*(\d+)\.(\d+)\.(\d+)'
294310 if match := re .search (RE_VERSION , output ):
295- return tuple ( int ( group ) for group in match .groups () )
311+ return match . group ( 1 ) + '.' + match .group ( 2 ) + '.' + match . group ( 3 )
296312
297313 raise RuntimeError ("Failed to find version in ZAP output" )
298314
@@ -301,7 +317,7 @@ def install_zap(self, version: Tuple[int, int, int]) -> None:
301317 Downloads and unpacks selected ZAP package version.
302318 """
303319 with tempfile .TemporaryDirectory () as temp_dir :
304- url = ZapInstaller .ZAP_URL_PATTERN % (* version , self .package )
320+ url = ZapInstaller .ZAP_URL_PATTERN % (version , self .package )
305321 log .inf (f'Downloading { url } ...' )
306322 zip_file_path = str (Path (temp_dir ).joinpath (f'{ self .package } .zip' ))
307323
@@ -343,15 +359,24 @@ def update_zap_if_needed(self) -> None:
343359 recommended_version = self .get_recommended_version ()
344360 current_version = self .get_current_version ()
345361
346- log .inf (f'ZAP installation directory: { self .install_path } ' )
362+ # Extract version without prefix and suffix for comparison
363+ # recommended_version format: v2025.09.23-nightly or v2025.09.23
364+ # current_version format: 2025.9.23
365+ recommended_version_clean = recommended_version
366+ if match := re .search (r'v?(\d+\.\d+\.\d+)' , recommended_version ):
367+ year , month , day = match .group (1 ).split ('.' )
368+ recommended_version_clean = f"{ int (year )} .{ int (month )} .{ int (day )} "
369+
370+ log .inf (f'ZAP installation directory: { self .install_path } ' )
371+ log .inf (f"Current ZAP version: { current_version } " )
347372
348- if current_version :
349- verdict = 'up to date' if current_version == recommended_version else 'outdated'
350- log .inf ('Found ZAP {}.{}.{} ({})' .format (* current_version , verdict ))
373+ if current_version :
374+ verdict = 'up to date' if current_version == recommended_version_clean else 'outdated'
375+ log .inf ('Found ZAP {} ({})' .format (current_version , verdict ))
351376
352- if current_version != recommended_version :
353- log .inf ('Installing ZAP {}.{}.{} ' .format (* recommended_version ))
354- self .install_zap (recommended_version )
377+ if current_version != recommended_version_clean :
378+ log .inf ('Installing ZAP {}' .format (recommended_version ))
379+ self .install_zap (recommended_version )
355380
356381 @staticmethod
357382 def set_exec_permission (path : Path ) -> None :
0 commit comments