Browse Source

modified: patch.py

pull/55/head
zyb 2 years ago
parent
commit
36a4b687c8
  1. 6
      patch.py

6
patch.py

@ -284,8 +284,7 @@ def patch_npk_package(package,key_dict):
extract_dir = 'squashfs-root' extract_dir = 'squashfs-root'
open(squashfs_file,'wb').write(package[NpkPartID.SQUASHFS].data) open(squashfs_file,'wb').write(package[NpkPartID.SQUASHFS].data)
print(f"extract {squashfs_file} ...") print(f"extract {squashfs_file} ...")
_, stderr = run_shell_command(f"unsquashfs -d {extract_dir} {squashfs_file}")
print(stderr.decode())
run_shell_command(f"unsquashfs -d {extract_dir} {squashfs_file}")
patch_squashfs(extract_dir,key_dict) patch_squashfs(extract_dir,key_dict)
keygen = os.path.join(extract_dir,'bin/keygen') keygen = os.path.join(extract_dir,'bin/keygen')
if 'ARCH' in os.environ and os.environ['ARCH'] =='': if 'ARCH' in os.environ and os.environ['ARCH'] =='':
@ -299,8 +298,7 @@ def patch_npk_package(package,key_dict):
run_shell_command(f"sudo sed -i '8s#.*# elseif@live.cn https://github.com/elseif/MikroTikPatch#' {logo}") run_shell_command(f"sudo sed -i '8s#.*# elseif@live.cn https://github.com/elseif/MikroTikPatch#' {logo}")
print(f"pack {extract_dir} ...") print(f"pack {extract_dir} ...")
run_shell_command(f"rm -f {squashfs_file}") run_shell_command(f"rm -f {squashfs_file}")
_, stderr = run_shell_command(f"mksquashfs {extract_dir} {squashfs_file} -quiet -comp xz -no-xattrs -b 256k")
print(stderr.decode())
run_shell_command(f"mksquashfs {extract_dir} {squashfs_file} -quiet -comp xz -no-xattrs -b 256k")
except Exception as e: except Exception as e:
print(e) print(e)
print(f"clean ...") print(f"clean ...")

Loading…
Cancel
Save