modified: .gitignore

new file:   keygen/keygen_aarch64
	renamed:    keygen.bin -> keygen/keygen_x86_64
	modified:   patch.py
This commit is contained in:
zyb 2024-07-12 06:02:48 +08:00
parent f16c5dabd0
commit 045228b212
4 changed files with 6 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,5 +1,4 @@
__pycache__/ __pycache__/
venv/ venv/
keygen/
app/ app/
test_*.py test_*.py

BIN
keygen/keygen_aarch64 Normal file

Binary file not shown.

Binary file not shown.

View File

@ -131,15 +131,19 @@ def patch_npk_file(key_dict,kcdsa_private_key,eddsa_private_key,input_file,outpu
npk[NpkPartID.FILE_CONTAINER].data = file_container.serialize() npk[NpkPartID.FILE_CONTAINER].data = file_container.serialize()
try: try:
squashfs_file = 'squashfs.sfs' squashfs_file = 'squashfs-root.sfs'
extract_dir = 'squashfs-root' extract_dir = 'squashfs-root'
open(squashfs_file,'wb').write(npk[NpkPartID.SQUASHFS].data) open(squashfs_file,'wb').write(npk[NpkPartID.SQUASHFS].data)
print(f"extract {squashfs_file} ...") print(f"extract {squashfs_file} ...")
_, stderr = run_shell_command(f"unsquashfs -d {extract_dir} {squashfs_file}") _, stderr = run_shell_command(f"unsquashfs -d {extract_dir} {squashfs_file}")
print(stderr.decode()) print(stderr.decode())
patch_squashfs(extract_dir,key_dict) patch_squashfs(extract_dir,key_dict)
stdout, stderr = run_shell_command(f"file {os.path.join(extract_dir,'sbin/sysinit')}")
keygen = os.path.join(extract_dir,'bin/keygen') keygen = os.path.join(extract_dir,'bin/keygen')
run_shell_command(f"sudo cp keygen.bin {keygen}") if 'x86-64' in stdout.decode():
run_shell_command(f"sudo cp keygen/keygen_x86_64 {keygen}")
elif 'aarch64' in stdout.decode():
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}")