mirror of
https://huihui.cat/mirrors/MikroTikPatch.git
synced 2025-12-10 03:24:37 +01:00
Update npk.py
Signed-off-by: elseif <elseif@live.cn>
This commit is contained in:
parent
808b637ebd
commit
3c5ed64380
1 changed files with 23 additions and 2 deletions
25
npk.py
25
npk.py
|
|
@ -207,7 +207,27 @@ class NovaPackage(Package):
|
|||
self._parts.append(NpkPartItem(NpkPartID(part_id),NpkInfo.unserialize_from(part_data)))
|
||||
else:
|
||||
self._parts.append(NpkPartItem(NpkPartID(part_id),part_data))
|
||||
|
||||
def set_null_block(self):
|
||||
if len(self._packages) > 0:
|
||||
for package in self._packages:
|
||||
count = 8
|
||||
for part in package._parts:
|
||||
count += 6
|
||||
if part.id == NpkPartID.NULL_BLOCK:
|
||||
break
|
||||
count += len(part.data)
|
||||
count += 6
|
||||
package[NpkPartID.NULL_BLOCK].data = b'\x00' * (4096-count)
|
||||
|
||||
else:
|
||||
count = 8
|
||||
for part in self._parts:
|
||||
count += 6
|
||||
if part.id == NpkPartID.NULL_BLOCK:
|
||||
break
|
||||
count += len(part.data)
|
||||
count += 6
|
||||
self[NpkPartID.NULL_BLOCK].data = b'\x00' * (4096-count)
|
||||
def get_digest(self,hash_fnc,package:Package=None)->bytes:
|
||||
parts = package._parts if package else self._parts
|
||||
for part in parts:
|
||||
|
|
@ -229,6 +249,7 @@ class NovaPackage(Package):
|
|||
import hashlib
|
||||
from mikro import mikro_kcdsa_sign,mikro_eddsa_sign
|
||||
build_time = os.getenv('BUILD_TIME',None)
|
||||
self.set_null_block()
|
||||
if len(self._packages) > 0:
|
||||
if build_time:
|
||||
self[NpkPartID.PKG_INFO].data._build_time = int(build_time)
|
||||
|
|
@ -356,4 +377,4 @@ if __name__=='__main__':
|
|||
option_npk.save(args.output)
|
||||
print(f'Created {args.output}')
|
||||
else:
|
||||
parser.print_help()
|
||||
parser.print_help()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue