mirror of
https://github.com/botlabsDev/npkpy.git
synced 2025-12-10 06:54:37 +01:00
add package type 25
This commit is contained in:
parent
547e1550bb
commit
20ea41029b
7 changed files with 39 additions and 104 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
from npkpy.npk.pck_preheader import NPK_PCK_PREHEADER, PckPreHeader
|
||||||
from npkpy.npk.pck_multicontainer_list import NPK_MULTICONTAINER_LIST, PktMulticontainerList
|
from npkpy.npk.pck_multicontainer_list import NPK_MULTICONTAINER_LIST, PktMulticontainerList
|
||||||
from npkpy.npk.cnt_architecture_tag import NPK_ARCHITECTURE_TAG, CntArchitectureTag
|
from npkpy.npk.cnt_architecture_tag import NPK_ARCHITECTURE_TAG, CntArchitectureTag
|
||||||
from npkpy.npk.cnt_null_block import NPK_NULL_BLOCK, CntNullBlock
|
from npkpy.npk.cnt_null_block import NPK_NULL_BLOCK, CntNullBlock
|
||||||
|
|
@ -16,8 +17,6 @@ from npkpy.npk.cnt_flag_a import NPK_FLAG_A, CntFlagA
|
||||||
from npkpy.npk.pck_multicontainer_header import NPK_MULTICONTAINER_HEADER, PktMulticontainerHeader
|
from npkpy.npk.pck_multicontainer_header import NPK_MULTICONTAINER_HEADER, PktMulticontainerHeader
|
||||||
from npkpy.npk.cnt_mpls import NPK_MPLS, CntMpls
|
from npkpy.npk.cnt_mpls import NPK_MPLS, CntMpls
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CNT_HANDLER = {
|
CNT_HANDLER = {
|
||||||
NPK_CNT_BASIC: CntBasic,
|
NPK_CNT_BASIC: CntBasic,
|
||||||
0: "?",
|
0: "?",
|
||||||
|
|
@ -45,7 +44,7 @@ CNT_HANDLER = {
|
||||||
NPK_NULL_BLOCK: CntNullBlock,
|
NPK_NULL_BLOCK: CntNullBlock,
|
||||||
NPK_ECKCDSA_HASH: PckEckcdsaHash,
|
NPK_ECKCDSA_HASH: PckEckcdsaHash,
|
||||||
NPK_RELEASE_TYP: PckReleaseTyp,
|
NPK_RELEASE_TYP: PckReleaseTyp,
|
||||||
25: "?",
|
NPK_PCK_PREHEADER: PckPreHeader,
|
||||||
26: "?",
|
26: "?",
|
||||||
27: "?",
|
27: "?",
|
||||||
28: "?",
|
28: "?",
|
||||||
|
|
|
||||||
8
npkpy/npk/pck_preheader.py
Normal file
8
npkpy/npk/pck_preheader.py
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
from npkpy.npk.cnt_basic import CntBasic
|
||||||
|
|
||||||
|
NPK_PCK_PREHEADER = 25
|
||||||
|
|
||||||
|
class PckPreHeader(CntBasic):
|
||||||
|
@property
|
||||||
|
def _regular_cnt_id(self):
|
||||||
|
return NPK_PCK_PREHEADER
|
||||||
|
|
@ -7,7 +7,7 @@ from npkpy.npk.npk import Npk, MAGIC_BYTES
|
||||||
|
|
||||||
class GpsFile_Test(unittest.TestCase):
|
class GpsFile_Test(unittest.TestCase):
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
self.npkFile = Path("tests/testData/gps-6.45.6.npk")
|
self.npkFile = Path("tests/testData/6_45_6/gps-6.45.6.npk")
|
||||||
self.npk = Npk(self.npkFile)
|
self.npk = Npk(self.npkFile)
|
||||||
self.cnt = self.npk.pck_cnt_list
|
self.cnt = self.npk.pck_cnt_list
|
||||||
|
|
||||||
|
|
|
||||||
12
tests/pck_preheader_test.py
Normal file
12
tests/pck_preheader_test.py
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from npkpy.npk.pck_preheader import PckPreHeader
|
||||||
|
from tests.constants import get_dummy_basic_cnt
|
||||||
|
|
||||||
|
|
||||||
|
class Test_pckPreHeader(unittest.TestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
self.cnt = PckPreHeader(get_dummy_basic_cnt(cnt_id=25), offset_in_pck=0)
|
||||||
|
|
||||||
|
def test_validateCntId(self):
|
||||||
|
self.assertEqual(25, self.cnt.cnt_id)
|
||||||
|
|
@ -1,85 +0,0 @@
|
||||||
gps-6.45.6.npk
|
|
||||||
Cnt: 0:PckHeader
|
|
||||||
Cnt: 1:PckReleaseTyp
|
|
||||||
Cnt: 2:CntArchitectureTag
|
|
||||||
Cnt: 3:PckDescription
|
|
||||||
Cnt: 4:PckEckcdsaHash
|
|
||||||
Cnt: 5:PckRequirementsHeader
|
|
||||||
Cnt: 6:CntNullBlock
|
|
||||||
Cnt: 7:CntSquashFsImage
|
|
||||||
Cnt: 8:CntSquashFsHashSignature
|
|
||||||
Cnt: 9:CntArchitectureTag
|
|
||||||
PckHeader
|
|
||||||
Cnt id: 1
|
|
||||||
Cnt offset: 8
|
|
||||||
Cnt len: 42
|
|
||||||
Payload len: 36
|
|
||||||
Payload[0:10]: b'gps\x00\x00\x00\x00\x00\x00\x00' [...]
|
|
||||||
Program name: gps
|
|
||||||
Os version: 6.45.6 - rc(?): 102
|
|
||||||
Created at: 2019-09-10 09:06:31
|
|
||||||
NullBlock: (0, 0, 0, 0)
|
|
||||||
Flags: (0, 0, 0, 0, 2, 0, 0)
|
|
||||||
PckReleaseTyp
|
|
||||||
Cnt id: 24
|
|
||||||
Cnt offset: 50
|
|
||||||
Cnt len: 12
|
|
||||||
Payload len: 6
|
|
||||||
Payload[0:6]: b'stable' [...]
|
|
||||||
CntArchitectureTag
|
|
||||||
Cnt id: 16
|
|
||||||
Cnt offset: 62
|
|
||||||
Cnt len: 10
|
|
||||||
Payload len: 4
|
|
||||||
Payload[0:4]: b'i386' [...]
|
|
||||||
PckDescription
|
|
||||||
Cnt id: 2
|
|
||||||
Cnt offset: 72
|
|
||||||
Cnt len: 31
|
|
||||||
Payload len: 25
|
|
||||||
Payload[0:10]: b'Provides s' [...]
|
|
||||||
PckEckcdsaHash
|
|
||||||
Cnt id: 23
|
|
||||||
Cnt offset: 103
|
|
||||||
Cnt len: 46
|
|
||||||
Payload len: 40
|
|
||||||
Payload[0:10]: b'1a7d206bbf' [...]
|
|
||||||
PckRequirementsHeader
|
|
||||||
Cnt id: 3
|
|
||||||
Cnt offset: 149
|
|
||||||
Cnt len: 40
|
|
||||||
Payload len: 34
|
|
||||||
Payload[0:10]: b'\x01\x00system\x00\x00' [...]
|
|
||||||
StructID: 1
|
|
||||||
Offset: 149
|
|
||||||
Program name: system
|
|
||||||
Null block: (0, 0, 0, 0)
|
|
||||||
Os versionFrom: 6.45.6 - rc(?): 102
|
|
||||||
Os versionTo: 6.45.6 - rc(?): 102
|
|
||||||
Flags: <not available for version 0,1>
|
|
||||||
CntNullBlock
|
|
||||||
Cnt id: 22
|
|
||||||
Cnt offset: 189
|
|
||||||
Cnt len: 3901
|
|
||||||
Payload len: 3895
|
|
||||||
Payload[0:10]: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' [...]
|
|
||||||
CntSquashFsImage
|
|
||||||
Cnt id: 21
|
|
||||||
Cnt offset: 4090
|
|
||||||
Cnt len: 49158
|
|
||||||
Payload len: 49152
|
|
||||||
Payload[0:10]: b'hsqs\x15\x00\x00\x00\xa2m' [...]
|
|
||||||
calc Sha1Hash: b'c\x033\x82{\x9a$er\x92=o\x8a\xfeL-Q\x02hW'
|
|
||||||
CntSquashFsHashSignature
|
|
||||||
Cnt id: 9
|
|
||||||
Cnt offset: 53248
|
|
||||||
Cnt len: 74
|
|
||||||
Payload len: 68
|
|
||||||
Payload[0:10]: b'\x8e\xa2\xb1\x8e\xf7n\xef355' [...]
|
|
||||||
Payload[-10:]: b"Y\x9e'\xac\xccw\x91\x06]\t"
|
|
||||||
CntArchitectureTag
|
|
||||||
Cnt id: 16
|
|
||||||
Cnt offset: 53322
|
|
||||||
Cnt len: 7
|
|
||||||
Payload len: 1
|
|
||||||
Payload[0:1]: b'I' [...]
|
|
||||||
|
|
@ -8,9 +8,9 @@ class Test_npkpy(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self) -> None:
|
def setUp(self) -> None:
|
||||||
# TODO: create DummyPkg and replace gps-6.45.6.npk
|
# TODO: create DummyPkg and replace gps-6.45.6.npk
|
||||||
self.npk_file = Path("tests/testData/gps-6.45.6.npk")
|
self.npk_file = Path("tests/testData/6_48_4/gps-6.48.4.npk")
|
||||||
self.path_to_npk = str(self.npk_file.absolute())
|
self.path_to_npk = str(self.npk_file.absolute())
|
||||||
self.npk_container_list = Path("tests/testData/gps-6.45.6.result").read_text()
|
self.npk_container_list = Path("tests/testData/6_48_4/gps-6.48.4.result").read_text()
|
||||||
self.dst_folder = Path(tempfile.mkdtemp())
|
self.dst_folder = Path(tempfile.mkdtemp())
|
||||||
|
|
||||||
def tearDown(self) -> None:
|
def tearDown(self) -> None:
|
||||||
|
|
@ -38,25 +38,26 @@ class Test_npkpy(unittest.TestCase):
|
||||||
run_command_in_terminal(cmd)
|
run_command_in_terminal(cmd)
|
||||||
|
|
||||||
exported_container = sorted(str(_file.relative_to(self.dst_folder)) for _file in self.dst_folder.rglob('*'))
|
exported_container = sorted(str(_file.relative_to(self.dst_folder)) for _file in self.dst_folder.rglob('*'))
|
||||||
self.assertEqual(['npkPyExport_gps-6.45.6',
|
self.assertEqual(['npkPyExport_gps-6.48.4',
|
||||||
'npkPyExport_gps-6.45.6/000_cnt_PckHeader.raw',
|
'npkPyExport_gps-6.48.4/000_cnt_PckPreHeader.raw',
|
||||||
'npkPyExport_gps-6.45.6/001_cnt_PckReleaseTyp.raw',
|
'npkPyExport_gps-6.48.4/001_cnt_PckHeader.raw',
|
||||||
'npkPyExport_gps-6.45.6/002_cnt_CntArchitectureTag.raw',
|
'npkPyExport_gps-6.48.4/002_cnt_PckReleaseTyp.raw',
|
||||||
'npkPyExport_gps-6.45.6/003_cnt_PckDescription.raw',
|
'npkPyExport_gps-6.48.4/003_cnt_CntArchitectureTag.raw',
|
||||||
'npkPyExport_gps-6.45.6/004_cnt_PckEckcdsaHash.raw',
|
'npkPyExport_gps-6.48.4/004_cnt_PckDescription.raw',
|
||||||
'npkPyExport_gps-6.45.6/005_cnt_PckRequirementsHeader.raw',
|
'npkPyExport_gps-6.48.4/005_cnt_PckEckcdsaHash.raw',
|
||||||
'npkPyExport_gps-6.45.6/006_cnt_CntNullBlock.raw',
|
'npkPyExport_gps-6.48.4/006_cnt_PckRequirementsHeader.raw',
|
||||||
'npkPyExport_gps-6.45.6/007_cnt_CntSquashFsImage.raw',
|
'npkPyExport_gps-6.48.4/007_cnt_CntNullBlock.raw',
|
||||||
'npkPyExport_gps-6.45.6/008_cnt_CntSquashFsHashSignature.raw',
|
'npkPyExport_gps-6.48.4/008_cnt_CntSquashFsImage.raw',
|
||||||
'npkPyExport_gps-6.45.6/009_cnt_CntArchitectureTag.raw'], exported_container)
|
'npkPyExport_gps-6.48.4/009_cnt_CntSquashFsHashSignature.raw',
|
||||||
|
'npkPyExport_gps-6.48.4/010_cnt_CntArchitectureTag.raw'], exported_container)
|
||||||
|
|
||||||
def test_extract_squashfs_container_from_npk(self):
|
def test_extract_squashfs_container_from_npk(self):
|
||||||
cmd = ["npkpy", "--file", self.path_to_npk, "--dst-folder", self.dst_folder.absolute(), "--export-squashfs"]
|
cmd = ["npkpy", "--file", self.path_to_npk, "--dst-folder", self.dst_folder.absolute(), "--export-squashfs"]
|
||||||
|
|
||||||
run_command_in_terminal(cmd)
|
run_command_in_terminal(cmd)
|
||||||
|
|
||||||
self.assert_container_extracted(['npkPyExport_gps-6.45.6',
|
self.assert_container_extracted(['npkPyExport_gps-6.48.4',
|
||||||
'npkPyExport_gps-6.45.6/007_cnt_CntSquashFsImage.raw'])
|
'npkPyExport_gps-6.48.4/008_cnt_CntSquashFsImage.raw'])
|
||||||
|
|
||||||
def test_extract_zlib_container_from_npk_nonexisting_not_extracted(self):
|
def test_extract_zlib_container_from_npk_nonexisting_not_extracted(self):
|
||||||
cmd = ["npkpy", "--file", self.path_to_npk, "--dst-folder", self.dst_folder.absolute(), "--export-zlib"]
|
cmd = ["npkpy", "--file", self.path_to_npk, "--dst-folder", self.dst_folder.absolute(), "--export-zlib"]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue