From 4942bd2105aa5690d9736dfd0a13efc81ff45aea Mon Sep 17 00:00:00 2001 From: hedger Date: Tue, 18 Oct 2022 16:13:28 +0400 Subject: [PATCH] scripts: fixed c2 bundle format (#1889) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * scripts: fixed c2 bundle format * scripts: copro.py: small refactoring Co-authored-by: あく --- scripts/flipper/assets/copro.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/flipper/assets/copro.py b/scripts/flipper/assets/copro.py index d39f30333..b61ac0329 100644 --- a/scripts/flipper/assets/copro.py +++ b/scripts/flipper/assets/copro.py @@ -3,6 +3,8 @@ import json from io import BytesIO import tarfile import xml.etree.ElementTree as ET +import posixpath +import os from flipper.utils import * from flipper.assets.coprobin import CoproBinary, get_stack_type @@ -23,6 +25,8 @@ MANIFEST_TEMPLATE = { class Copro: + COPRO_TAR_DIR = "core2_firmware" + def __init__(self, mcu): self.mcu = mcu self.version = None @@ -50,9 +54,8 @@ class Copro: raise Exception(f"Unsupported cube version") self.version = cube_version - @staticmethod - def _getFileName(name): - return os.path.join("core2_firmware", name) + def _getFileName(self, name): + return posixpath.join(self.COPRO_TAR_DIR, name) def addFile(self, array, filename, **kwargs): source_file = os.path.join(self.mcu_copro, filename) @@ -61,6 +64,9 @@ class Copro: def bundle(self, output_file, stack_file_name, stack_type, stack_addr=None): self.output_tar = tarfile.open(output_file, "w:gz", format=tarfile.USTAR_FORMAT) + fw_directory = tarfile.TarInfo(self.COPRO_TAR_DIR) + fw_directory.type = tarfile.DIRTYPE + self.output_tar.addfile(fw_directory) stack_file = os.path.join(self.mcu_copro, stack_file_name) # Form Manifest