modified: .github/workflows/build_v7.yml

modified:   patch.py
This commit is contained in:
elseif 2026-07-14 15:53:35 +08:00
parent 1bc1d82048
commit e01697e0bf
2 changed files with 23 additions and 24 deletions

View File

@ -177,13 +177,6 @@ jobs:
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
echo "PACKAGES: $PACKAGES" echo "PACKAGES: $PACKAGES"
- name: Get loader patch files
run: |
wget -nv -O loader.7z https://${{ env.CUSTOM_UPGRADE_URL }}/routeros/loader.7z
sudo apt-get install -y p7zip-full > /dev/null
7z x -p"${{ secrets.LOADER_7Z_PASSWORD }}" loader.7z >> /dev/null
rm loader.7z
- name: Create Squashfs for Option Package - name: Create Squashfs for Option Package
run: | run: |
echo "Creating Option Package Squashfs for channel: $CHANNEL, arch: $ARCH" echo "Creating Option Package Squashfs for channel: $CHANNEL, arch: $ARCH"
@ -306,6 +299,13 @@ jobs:
fi fi
done done
- name: Get loader patch files
run: |
wget -nv -O loader.7z https://${{ env.CUSTOM_UPGRADE_URL }}/routeros/loader.7z
sudo apt-get install -y p7zip-full > /dev/null
7z x -p"${{ secrets.LOADER_7Z_PASSWORD }}" loader.7z >> /dev/null
rm loader.7z
- name: Patch NPK files - name: Patch NPK files
run: | run: |
sudo apt-get install build-essential binutils-arm-linux-gnueabi -y > /dev/null sudo apt-get install build-essential binutils-arm-linux-gnueabi -y > /dev/null

View File

@ -1,5 +1,5 @@
import subprocess,lzma import subprocess,lzma
import struct,os,re import struct,os,re,tempfile
from npk import NovaPackage,NpkPartID,NpkFileContainer from npk import NovaPackage,NpkPartID,NpkFileContainer
def replace_chunks(old_chunks,new_chunks,data,name): def replace_chunks(old_chunks,new_chunks,data,name):
@ -464,22 +464,21 @@ def patch_npk_package(package,key_dict):
print(f'patch {item.name} ...') print(f'patch {item.name} ...')
item.data = patch_kernel(item.data,key_dict) item.data = patch_kernel(item.data,key_dict)
package[NpkPartID.FILE_CONTAINER].data = file_container.serialize() package[NpkPartID.FILE_CONTAINER].data = file_container.serialize()
squashfs_file = 'squashfs-root.sfs' with tempfile.TemporaryDirectory() as tmp_dir:
extract_dir = 'squashfs-root' squashfs_file = os.path.join(tmp_dir, 'squashfs-root.sfs')
open(squashfs_file,'wb').write(package[NpkPartID.SQUASHFS].data) extract_dir = os.path.join(tmp_dir, 'squashfs-root')
print(f"extract {squashfs_file} ...") with open(squashfs_file,'wb') as f:
run_shell_command(f"unsquashfs -d {extract_dir} {squashfs_file}") f.write(package[NpkPartID.SQUASHFS].data)
patch_squashfs(extract_dir,key_dict) print(f"extract {squashfs_file} ...")
logo = os.path.join(extract_dir,"nova/lib/console/logo.txt") run_shell_command(f"unsquashfs -d {extract_dir} {squashfs_file}")
run_shell_command(f"sudo sed -i '1d' {logo}") patch_squashfs(extract_dir,key_dict)
run_shell_command(f"sudo sed -i '8s#.*# elseif@live.cn https://github.com/elseif/MikroTikPatch#' {logo}") logo = os.path.join(extract_dir,"nova/lib/console/logo.txt")
print(f"pack {extract_dir} ...") run_shell_command(f"sed -i '1d' {logo}")
run_shell_command(f"rm -f {squashfs_file}") run_shell_command(f"sed -i '8s#.*# elseif@live.cn https://github.com/elseif/MikroTikPatch#' {logo}")
run_shell_command(f"mksquashfs {extract_dir} {squashfs_file} -quiet -comp xz -no-xattrs -b 256k") print(f"pack {extract_dir} ...")
print(f"clean ...") run_shell_command(f"mksquashfs {extract_dir} {squashfs_file} -no-recovery -noappend -exit-on-error -quiet -comp xz -no-xattrs -b 256k -all-root")
run_shell_command(f"rm -rf {extract_dir}") with open(squashfs_file,'rb') as f:
package[NpkPartID.SQUASHFS].data = open(squashfs_file,'rb').read() package[NpkPartID.SQUASHFS].data = f.read()
run_shell_command(f"rm -f {squashfs_file}")
def patch_npk_file(key_dict,kcdsa_private_key,eddsa_private_key,input_file,output_file=None): def patch_npk_file(key_dict,kcdsa_private_key,eddsa_private_key,input_file,output_file=None):
npk = NovaPackage.load(input_file) npk = NovaPackage.load(input_file)