mirror of
https://github.com/elseif/MikroTikPatch.git
synced 2026-10-05 16:39:36 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c91013d697 | ||
|
|
40f2886e62 | ||
|
|
b0f87cf35d | ||
|
|
32f1724bc4 | ||
|
|
17271e5e09 | ||
|
|
b53b7b1b1a | ||
|
|
d7b19d51a6 | ||
|
|
b9621532de |
@@ -252,7 +252,7 @@ jobs:
|
||||
with:
|
||||
version: ${{ matrix.target.version }}
|
||||
channels: ${{ toJson(matrix.target.channels) }}
|
||||
archs: ${{ needs.Prepare_Patch.outputs.archs }}
|
||||
archs: '["x86"]'
|
||||
buildtime: ${{ inputs.buildtime }}
|
||||
release: ${{ github.event_name != 'workflow_dispatch' || inputs.release }}
|
||||
secrets: inherit
|
||||
|
||||
@@ -417,9 +417,9 @@ jobs:
|
||||
ARCH_TEXT="\`$ARCH\`"
|
||||
|
||||
cat > "$RELEASE_BODY" << EOF
|
||||
**Build Time**: $BUILD_TIME_UTC ($BUILD_TIME)
|
||||
**Architecture**: $ARCH_TEXT
|
||||
**Channel**: $CHANNELS_TEXT
|
||||
**Build Time**: $BUILD_TIME_UTC ($BUILD_TIME)
|
||||
|
||||
<details open><summary><strong>RouterOS</strong></summary>
|
||||
|
||||
@@ -453,13 +453,12 @@ jobs:
|
||||
for fmt in "${formats[@]}"; do
|
||||
platform="${FORMAT_PLATFORM[$fmt]}"
|
||||
link=$(link_file "$PUBLISH_DIR/chr-$VERSION$ARCH_EXT.$fmt.zip")
|
||||
echo "| $platform | $link |" >> "$RELEASE_BODY"
|
||||
fi
|
||||
echo "| $platform | $link |" >> "$RELEASE_BODY"
|
||||
done
|
||||
echo "</details>" >> "$RELEASE_BODY"
|
||||
echo "" >> "$RELEASE_BODY"
|
||||
|
||||
echo "<details><summary><strong>Changelog</strong></summary>" >> "$RELEASE_BODY"
|
||||
echo "<details><summary><strong>Changelog</strong> (click to expand)</summary>" >> "$RELEASE_BODY"
|
||||
echo "" >> "$RELEASE_BODY"
|
||||
echo "<pre>" >> "$RELEASE_BODY"
|
||||
cat "$PUBLISH_DIR/CHANGELOG" >> "$RELEASE_BODY"
|
||||
@@ -565,12 +564,12 @@ jobs:
|
||||
PASS=${{ secrets.SSH_PASSWORD }}
|
||||
PORT=${{ secrets.SSH_PORT }}
|
||||
|
||||
REMOTE_CMD="
|
||||
REMOTE_CMD=""
|
||||
|
||||
while read -r CHANNEL
|
||||
do
|
||||
REMOTE_CMD="$REMOTE_CMD
|
||||
ln -sfn /root/$REMOTE_PATH/$VERSION/info /rw/disk/$REMOTE_PATH/NEWEST6.$CHANNEL"
|
||||
ln -sfn /root/$REMOTE_PATH/$VERSION/info /rw/disk/$REMOTE_PATH/NEWEST6.$CHANNEL
|
||||
ln -sfn /root/$REMOTE_PATH/$VERSION/info /rw/disk/$REMOTE_PATH/NEWESTa6.$CHANNEL"
|
||||
done < <(echo "$CHANNELS" | jq -r '.[]')
|
||||
|
||||
|
||||
@@ -855,9 +855,9 @@ jobs:
|
||||
ARCH_TEXT="\`$ARCH\`"
|
||||
|
||||
cat > "$RELEASE_BODY" << EOF
|
||||
**Build Time**: $BUILD_TIME_UTC ($BUILD_TIME)
|
||||
**Architecture**: $ARCH_TEXT
|
||||
**Channel**: $CHANNELS_TEXT
|
||||
**Build Time**: $BUILD_TIME_UTC ($BUILD_TIME)
|
||||
|
||||
<details open><summary><strong>RouterOS</strong></summary>
|
||||
|
||||
@@ -912,7 +912,7 @@ jobs:
|
||||
echo "</details>" >> "$RELEASE_BODY"
|
||||
echo "" >> "$RELEASE_BODY"
|
||||
fi
|
||||
echo "<details><summary><strong>Changelog</strong></summary>" >> "$RELEASE_BODY"
|
||||
echo "<details><summary><strong>Changelog</strong> (click to expand)</summary>" >> "$RELEASE_BODY"
|
||||
echo "" >> "$RELEASE_BODY"
|
||||
echo "<pre>" >> "$RELEASE_BODY"
|
||||
cat "$PUBLISH_DIR/CHANGELOG" >> "$RELEASE_BODY"
|
||||
|
||||
@@ -133,7 +133,8 @@ show_system_info() {
|
||||
}
|
||||
|
||||
confirm_storage() {
|
||||
STORAGE=$(lsblk | grep disk | head -1 | awk '{print $1}')
|
||||
# STORAGE=$(lsblk | grep disk | head -1 | awk '{print $1}')
|
||||
STORAGE=$(ls /sys/block | grep -vE '^(zram|loop|ram|sr|fd|dm-)' | head -1)
|
||||
ask_until "$MSG_STORAGE_DEVICE" "$STORAGE"
|
||||
STORAGE=$resp
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import pefile
|
||||
from elftools.elf.elffile import ELFFile
|
||||
from npk import NovaPackage,NpkPartID,NpkFileContainer
|
||||
|
||||
def replace_chunks(old_chunks,new_chunks,data,name):
|
||||
pattern_parts = [re.escape(chunk) + b'(.{0,6})' for chunk in old_chunks[:-1]]
|
||||
def replace_chunks(old_chunks,new_chunks,data,name,gap_size=8):
|
||||
pattern_parts = [re.escape(chunk) + f'(.{{0,{gap_size}}})'.encode() for chunk in old_chunks[:-1]]
|
||||
pattern_parts.append(re.escape(old_chunks[-1]))
|
||||
pattern_bytes = b''.join(pattern_parts)
|
||||
pattern = re.compile(pattern_bytes, flags=re.DOTALL)
|
||||
@@ -24,6 +24,12 @@ def replace_key(old,new,data,name=''):
|
||||
old_chunks = [bytes([old[i]]) for i in key_map]
|
||||
new_chunks = [bytes([new[i]]) for i in key_map]
|
||||
data = replace_chunks(old_chunks, new_chunks, data,name)
|
||||
key_map = [0, 1, 2, 3, 4, 6, 5, 7]
|
||||
_old_chunks = [old[i:i+4] for i in range(0, len(old), 4)]
|
||||
old_chunks = [_old_chunks[i] for i in key_map]
|
||||
_new_chunks = [new[i:i+4] for i in range(0, len(new), 4)]
|
||||
new_chunks = [_new_chunks[i] for i in key_map]
|
||||
data = replace_chunks(old_chunks, new_chunks, data,name,20)
|
||||
arch = os.getenv('ARCH') or 'x86'
|
||||
arch = arch.replace('-', '')
|
||||
if arch in ['arm64','arm']:
|
||||
@@ -115,22 +121,30 @@ def patch_initrd_xz(initrd_xz:bytes,key_dict:dict,ljust=True):
|
||||
new_initrd = initrd
|
||||
for old_public_key,new_public_key in key_dict.items():
|
||||
new_initrd = replace_key(old_public_key,new_public_key,new_initrd,'initrd')
|
||||
|
||||
|
||||
preset = 6
|
||||
new_initrd_xz = lzma.compress(new_initrd,check=lzma.CHECK_CRC32,filters=[{"id": lzma.FILTER_LZMA2, "preset": preset }] )
|
||||
while len(new_initrd_xz) > len(initrd_xz) and preset < 9:
|
||||
print(f'preset:{preset}')
|
||||
print(f'new initrd xz size:{len(new_initrd_xz)}')
|
||||
print(f'old initrd xz size:{len(initrd_xz)}')
|
||||
while True:
|
||||
new_initrd_xz = lzma.compress(new_initrd,check=lzma.CHECK_CRC32,filters= [{"id": lzma.FILTER_LZMA2,"preset": preset }] )
|
||||
print(f'preset:{preset},initrd xz new size:{len(new_initrd_xz)},old size:{len(initrd_xz)}')
|
||||
preset += 1
|
||||
new_initrd_xz = lzma.compress(new_initrd,check=lzma.CHECK_CRC32,filters=[{"id": lzma.FILTER_LZMA2, "preset": preset }] )
|
||||
if len(new_initrd_xz) <= len(initrd_xz) or preset > 9:
|
||||
break
|
||||
if len(new_initrd_xz) > len(initrd_xz):
|
||||
new_initrd_xz = lzma.compress(new_initrd,check=lzma.CHECK_CRC32,filters=[{"id": lzma.FILTER_LZMA2, "preset": 9 | lzma.PRESET_EXTREME,'dict_size': 32*1024*1024,"lc": 4,"lp": 0, "pb": 0,}] )
|
||||
new_initrd_xz=lzma.compress(
|
||||
new_initrd,
|
||||
check=lzma.CHECK_CRC32,
|
||||
filters=[{
|
||||
"id":lzma.FILTER_LZMA2,
|
||||
"lc": 2,
|
||||
"lp": 2,
|
||||
"pb": 3,
|
||||
"mf":lzma.MF_BT4,
|
||||
}])
|
||||
print(f'initrd xz new size:{len(new_initrd_xz)},old size:{len(initrd_xz)}')
|
||||
assert len(new_initrd_xz) <= len(initrd_xz),'new initrd xz size is too big'
|
||||
if ljust:
|
||||
print(f'preset:{preset}')
|
||||
print(f'new initrd xz size:{len(new_initrd_xz)}')
|
||||
print(f'old initrd xz size:{len(initrd_xz)}')
|
||||
print(f'ljust size:{len(initrd_xz)-len(new_initrd_xz)}')
|
||||
assert len(new_initrd_xz) <= len(initrd_xz),'new initrd xz size is too big'
|
||||
new_initrd_xz = new_initrd_xz.ljust(len(initrd_xz),b'\0')
|
||||
return new_initrd_xz
|
||||
|
||||
|
||||
Reference in New Issue
Block a user