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
f91f8e15d0
commit
96670cbe60
1 changed files with 5 additions and 5 deletions
10
npk.py
10
npk.py
|
|
@ -218,20 +218,20 @@ class NovaPackage(Package):
|
||||||
os.system('rm -rf squashfs-root')
|
os.system('rm -rf squashfs-root')
|
||||||
with open('squashfs.sfs', 'rb') as f:
|
with open('squashfs.sfs', 'rb') as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
def get_size(package,size=8):
|
def get_size(package,size):
|
||||||
for part in package._parts:
|
for part in package._parts:
|
||||||
size += 6
|
size += 6
|
||||||
size += len(part.data)
|
size += len(part.data)
|
||||||
return size
|
return size
|
||||||
|
|
||||||
def set_null(package,offset=None):
|
def set_null(package,offset):
|
||||||
has_squashfs = False
|
has_squashfs = False
|
||||||
for part in package._parts:
|
for part in package._parts:
|
||||||
if part.id == NpkPartID.SQUASHFS and len(part.data) >= 4 and part.data[:4] in [b'hsqs',b'sqsh']:
|
if part.id == NpkPartID.SQUASHFS and len(part.data) >= 4 and part.data[:4] in [b'hsqs',b'sqsh']:
|
||||||
part.data = rebuild_squashfs(part.data)
|
part.data = rebuild_squashfs(part.data)
|
||||||
has_squashfs = True
|
has_squashfs = True
|
||||||
if has_squashfs:
|
if has_squashfs:
|
||||||
count = offset or 8
|
count = offset
|
||||||
for part in package._parts:
|
for part in package._parts:
|
||||||
count += 6
|
count += 6
|
||||||
if part.id == NpkPartID.NULL_BLOCK:
|
if part.id == NpkPartID.NULL_BLOCK:
|
||||||
|
|
@ -241,8 +241,8 @@ class NovaPackage(Package):
|
||||||
pad_len = (4096 - (count % 4096)) % 4096
|
pad_len = (4096 - (count % 4096)) % 4096
|
||||||
package[NpkPartID.NULL_BLOCK].data = b'\x00' * pad_len
|
package[NpkPartID.NULL_BLOCK].data = b'\x00' * pad_len
|
||||||
|
|
||||||
set_null(self)
|
set_null(self,8)
|
||||||
offset = get_size(self)
|
offset = get_size(self,8)
|
||||||
for package in self._packages:
|
for package in self._packages:
|
||||||
set_null(package,offset)
|
set_null(package,offset)
|
||||||
offset += get_size(package,0)
|
offset += get_size(package,0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue