[FL-3045] Fix core2 permisions (#2742)

* Fix core2 permisions

* Fix Python code style

* scripts: copro: changed int literals

* scripts: copro: shorter string line in code

---------

Co-authored-by: hedger <hedger@nanode.su>
Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
Max Andreev 2023-06-06 23:33:04 +04:00 committed by GitHub
parent dbd48a04d4
commit 6f6ead1726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -58,14 +58,23 @@ class Copro:
def _getFileName(self, name): def _getFileName(self, name):
return posixpath.join(self.COPRO_TAR_DIR, name) return posixpath.join(self.COPRO_TAR_DIR, name)
def _addFileReadPermission(self, tarinfo):
tarinfo.mode = 0o644
return tarinfo
def addFile(self, array, filename, **kwargs): def addFile(self, array, filename, **kwargs):
source_file = os.path.join(self.mcu_copro, filename) source_file = os.path.join(self.mcu_copro, filename)
self.output_tar.add(source_file, arcname=self._getFileName(filename)) self.output_tar.add(
source_file,
arcname=self._getFileName(filename),
filter=self._addFileReadPermission,
)
array.append({"name": filename, "sha256": file_sha256(source_file), **kwargs}) array.append({"name": filename, "sha256": file_sha256(source_file), **kwargs})
def bundle(self, output_file, stack_file_name, stack_type, stack_addr=None): 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) self.output_tar = tarfile.open(output_file, "w:gz", format=tarfile.USTAR_FORMAT)
fw_directory = tarfile.TarInfo(self.COPRO_TAR_DIR) fw_directory = tarfile.TarInfo(self.COPRO_TAR_DIR)
fw_directory.mode = 0o755
fw_directory.type = tarfile.DIRTYPE fw_directory.type = tarfile.DIRTYPE
self.output_tar.addfile(fw_directory) self.output_tar.addfile(fw_directory)

View File

@ -46,7 +46,10 @@ class CoproFooterBase:
_SIG_BIN_COMMON_SIZE = 2 * 4 _SIG_BIN_COMMON_SIZE = 2 * 4
def get_version(self): def get_version(self):
return f"Version {self.version_major}.{self.version_minor}.{self.version_sub}, branch {self.version_branch}, build {self.version_build} (magic {self.magic:X})" return (
f"Version {self.version_major}.{self.version_minor}.{self.version_sub}, "
f"branch {self.version_branch}, build {self.version_build} (magic {self.magic:X})"
)
def get_details(self): def get_details(self):
raise CoproException("Not implemented") raise CoproException("Not implemented")