mirror of
https://github.com/elseif/MikroTikPatch
synced 2026-07-17 18:49:41 +00:00
modified: npk.py
modified: patch.py
This commit is contained in:
parent
7324df7744
commit
89a1042e60
3
npk.py
3
npk.py
@ -261,7 +261,8 @@ if __name__=='__main__':
|
|||||||
eddsa_private_key = bytes.fromhex(os.environ['CUSTOM_NPK_SIGN_PRIVATE_KEY'])
|
eddsa_private_key = bytes.fromhex(os.environ['CUSTOM_NPK_SIGN_PRIVATE_KEY'])
|
||||||
kcdsa_public_key = bytes.fromhex(os.environ['CUSTOM_LICENSE_PUBLIC_KEY'])
|
kcdsa_public_key = bytes.fromhex(os.environ['CUSTOM_LICENSE_PUBLIC_KEY'])
|
||||||
eddsa_public_key = bytes.fromhex(os.environ['CUSTOM_NPK_SIGN_PUBLIC_KEY'])
|
eddsa_public_key = bytes.fromhex(os.environ['CUSTOM_NPK_SIGN_PUBLIC_KEY'])
|
||||||
build_time = os.environ['BUILD_TIME']
|
|
||||||
|
build_time = os.environ['BUILD_TIME'] if 'BUILD_TIME' in os.environ else None
|
||||||
if args.command =='sign':
|
if args.command =='sign':
|
||||||
print(f'Signing {args.input}')
|
print(f'Signing {args.input}')
|
||||||
npk = NovaPackage.load(args.input)
|
npk = NovaPackage.load(args.input)
|
||||||
|
|||||||
8
patch.py
8
patch.py
@ -111,9 +111,10 @@ def patch_npk_file(key_dict,kcdsa_private_key,eddsa_private_key,input_file,outpu
|
|||||||
keygen = os.path.join(extract_dir,'bin/keygen')
|
keygen = os.path.join(extract_dir,'bin/keygen')
|
||||||
if os.environ['ARCH'] =='':
|
if os.environ['ARCH'] =='':
|
||||||
run_shell_command(f"sudo cp keygen/keygen_x86_64 {keygen}")
|
run_shell_command(f"sudo cp keygen/keygen_x86_64 {keygen}")
|
||||||
|
run_shell_command(f"sudo chmod a+x {keygen}")
|
||||||
elif os.environ['ARCH'] == '-arm64':
|
elif os.environ['ARCH'] == '-arm64':
|
||||||
run_shell_command(f"sudo cp keygen/keygen_aarch64 {keygen}")
|
run_shell_command(f"sudo cp keygen/keygen_aarch64 {keygen}")
|
||||||
run_shell_command(f"sudo chmod a+x {keygen}")
|
run_shell_command(f"sudo chmod a+x {keygen}")
|
||||||
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")
|
_, stderr = run_shell_command(f"mksquashfs {extract_dir} {squashfs_file} -quiet -comp xz -no-xattrs -b 256k")
|
||||||
@ -124,10 +125,9 @@ def patch_npk_file(key_dict,kcdsa_private_key,eddsa_private_key,input_file,outpu
|
|||||||
run_shell_command(f"rm -rf {extract_dir}")
|
run_shell_command(f"rm -rf {extract_dir}")
|
||||||
npk[NpkPartID.SQUASHFS].data = open(squashfs_file,'rb').read()
|
npk[NpkPartID.SQUASHFS].data = open(squashfs_file,'rb').read()
|
||||||
run_shell_command(f"rm -f {squashfs_file}")
|
run_shell_command(f"rm -f {squashfs_file}")
|
||||||
|
build_time = os.environ['BUILD_TIME'] if 'BUILD_TIME' in os.environ else None
|
||||||
build_time = os.environ['BUILD_TIME']
|
|
||||||
if build_time:
|
if build_time:
|
||||||
npk[NpkPartID.NAME_INFO].data._build_time = int(build_time)
|
npk[NpkPartID.NAME_INFO].data._build_time = int(os.environ['BUILD_TIME'])
|
||||||
npk.sign(kcdsa_private_key,eddsa_private_key)
|
npk.sign(kcdsa_private_key,eddsa_private_key)
|
||||||
npk.save(output_file or input_file)
|
npk.save(output_file or input_file)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user