modified: npk.py

modified:   patch.py
This commit is contained in:
zyb 2024-07-15 20:17:12 +08:00
parent 7324df7744
commit 89a1042e60
2 changed files with 6 additions and 5 deletions

3
npk.py
View File

@ -261,7 +261,8 @@ if __name__=='__main__':
eddsa_private_key = bytes.fromhex(os.environ['CUSTOM_NPK_SIGN_PRIVATE_KEY'])
kcdsa_public_key = bytes.fromhex(os.environ['CUSTOM_LICENSE_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':
print(f'Signing {args.input}')
npk = NovaPackage.load(args.input)

View File

@ -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')
if os.environ['ARCH'] =='':
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':
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} ...")
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")
@ -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}")
npk[NpkPartID.SQUASHFS].data = open(squashfs_file,'rb').read()
run_shell_command(f"rm -f {squashfs_file}")
build_time = os.environ['BUILD_TIME']
build_time = os.environ['BUILD_TIME'] if 'BUILD_TIME' in os.environ else None
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.save(output_file or input_file)