diff --git a/.github/workflows/data.yml b/.github/workflows/data.yml index 6166a8e0..a195835b 100644 --- a/.github/workflows/data.yml +++ b/.github/workflows/data.yml @@ -43,7 +43,7 @@ jobs: TAG="" if [ "${PRERELEASE}" = "true" ]; then - TAG="$(curl -skL --connect-timeout 10 "${REPO}/tags" | grep /refs/tags/.*\.zip | sed -r 's/.*\/refs\/tags\/(.*)\.zip.*$/\1/' | sort -rV | head -1)" + TAG="$(curl -skL --connect-timeout 10 "${REPO}/tags" | grep /refs/tags/.*\.zip | sed -E 's/.*\/refs\/tags\/(.*)\.zip.*$/\1/' | sort -rV | head -1)" else LATESTURL="$(curl -skL --connect-timeout 10 -w %{url_effective} -o /dev/null "${REPO}/releases/latest")" TAG="${LATESTURL##*/}" diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 85cd9e8a..65dbdf48 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -1658,12 +1658,14 @@ function loaderPassword() { # Change Arc Loader Password function loaderPorts() { MSG="Modify Ports (0-65535) (Leave empty for default):" - HTTPPORT=$(grep -i '^HTTP_PORT=' /etc/arc.conf 2>/dev/null | cut -d'=' -f2) - DUFSPORT=$(grep -i '^DUFS_PORT=' /etc/arc.conf 2>/dev/null | cut -d'=' -f2) - TTYDPORT=$(grep -i '^TTYD_PORT=' /etc/arc.conf 2>/dev/null | cut -d'=' -f2) + unset HTTP_PORT DUFS_PORT TTYD_PORT + [ -f "/etc/arc.conf" ] && source "/etc/arc.conf" 2>/dev/null + local HTTP=${HTTP_PORT:-7080} + local DUFS=${DUFS_PORT:-7304} + local TTYD=${TTYD_PORT:-7681} while true; do dialog --backtitle "$(backtitle)" --title "Loader Ports" \ - --form "${MSG}" 11 70 3 "HTTP" 1 1 "${HTTPPORT:-8080}" 1 10 55 0 "DUFS" 2 1 "${DUFSPORT:-7304}" 2 10 55 0 "TTYD" 3 1 "${TTYDPORT:-7681}" 3 10 55 0 \ + --form "${MSG}" 11 70 3 "HTTP" 1 1 "${HTTPPORT}" 1 10 55 0 "DUFS" 2 1 "${DUFSPORT}" 2 10 55 0 "TTYD" 3 1 "${TTYDPORT}" 3 10 55 0 \ 2>"${TMP_PATH}/resp" RET=$? case ${RET} in @@ -1729,14 +1731,17 @@ function loaderPorts() { rm -f "${ARC_RAMDISK_USER_FILE}" fi rm -rf "${RDXZ_PATH}" - { - [ "${HTTP:-8080}" != "8080" ] && /etc/init.d/S90thttpd restart - [ "${DUFS:-7304}" != "7304" ] && /etc/init.d/S99dufs restart - [ "${TTYD:-7681}" != "7681" ] && /etc/init.d/S99ttyd restart - } >/dev/null 2>&1 & [ ! -f "/etc/arc.conf" ] && MSG="Ports for TTYD/DUFS/HTTP restored." || MSG="Ports for TTYD/DUFS/HTTP changed." dialog --backtitle "$(backtitle)" --title "Loader Ports" \ --msgbox "${MSG}" 0 0 + rm -f "${TMP_PATH}/restartS.sh" + { + [ ! "${HTTP:-8080}" = "${HTTP_PORT:-8080}" ] && echo "/etc/init.d/S90thttpd restart" + [ ! "${DUFS:-7304}" = "${DUFS_PORT:-7304}" ] && echo "/etc/init.d/S99dufs restart" + [ ! "${TTYD:-7681}" = "${TTYD_PORT:-7681}" ] && echo "/etc/init.d/S99ttyd restart" + } >"${TMP_PATH}/restartS.sh" + chmod +x "${TMP_PATH}/restartS.sh" + nohup "${TMP_PATH}/restartS.sh" >/dev/null 2>&1 break ;; 1) # cancel-button diff --git a/files/initrd/opt/arc/calc_run_size.sh b/files/initrd/opt/arc/calc_run_size.sh deleted file mode 100755 index dc5a3f4b..00000000 --- a/files/initrd/opt/arc/calc_run_size.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# Calculate the amount of space needed to run the kernel, including room for -# the .bss and .brk sections. -# -# Usage: -# objdump -h a.out | sh calc_run_size.sh - -NUM='\([0-9a-fA-F]*[ \t]*\)' -OUT=$(sed -n 's/^[ \t0-9]*.b[sr][sk][ \t]*'"${NUM}${NUM}${NUM}${NUM}"'.*/0x\1 0x\4/p') - -if [ -z "${OUT}" ]; then - echo "Never found .bss or .brk file offset" >&2 - exit 1 -fi - -read -r sizeA offsetA sizeB offsetB <<<$(echo ${OUT} | awk '{printf "%d %d %d %d", strtonum($1), strtonum($2), strtonum($3), strtonum($4)}') - -runSize=$((offsetA + sizeA + sizeB)) - -# BFD linker shows the same file offset in ELF. -if [ "${offsetA}" -ne "${offsetB}" ]; then - # Gold linker shows them as consecutive. - endSize=$((offsetB + sizeB)) - if [ "${endSize}" -ne "${runSize}" ]; then - printf "sizeA: 0x%x\n" ${sizeA} >&2 - printf "offsetA: 0x%x\n" ${offsetA} >&2 - printf "sizeB: 0x%x\n" ${sizeB} >&2 - printf "offsetB: 0x%x\n" ${offsetB} >&2 - echo ".bss and .brk are non-contiguous" >&2 - exit 1 - fi -fi - -printf "%d\n" ${runSize} -exit 0 \ No newline at end of file diff --git a/files/initrd/opt/arc/kpatch b/files/initrd/opt/arc/kpatch index 275c08ad..730f1dac 100755 Binary files a/files/initrd/opt/arc/kpatch and b/files/initrd/opt/arc/kpatch differ diff --git a/files/initrd/opt/arc/ramdisk-patch.sh b/files/initrd/opt/arc/ramdisk-patch.sh index 64736d17..a6e33415 100755 --- a/files/initrd/opt/arc/ramdisk-patch.sh +++ b/files/initrd/opt/arc/ramdisk-patch.sh @@ -128,13 +128,17 @@ done grep -v -e '^[\t ]*#' -e '^$' "${PATCH_PATH}/config-manipulators.sh" >"${TMP_PATH}/rp.txt" sed -e "/@@@CONFIG-MANIPULATORS-TOOLS@@@/ {" -e "r ${TMP_PATH}/rp.txt" -e 'd' -e '}' -i "${RAMDISK_PATH}/sbin/init.post" rm -f "${TMP_PATH}/rp.txt" -touch "${TMP_PATH}/rp.txt" -echo "_set_conf_kv 'SN' '${SN}' '/tmpRoot/etc/synoinfo.conf'" >>"${TMP_PATH}/rp.txt" -echo "_set_conf_kv 'SN' '${SN}' '/tmpRoot/etc.defaults/synoinfo.conf'" >>"${TMP_PATH}/rp.txt" -for KEY in ${!SYNOINFO[@]}; do - echo "_set_conf_kv '${KEY}' '${SYNOINFO[${KEY}]}' '/tmpRoot/etc/synoinfo.conf'" >>"${TMP_PATH}/rp.txt" - echo "_set_conf_kv '${KEY}' '${SYNOINFO[${KEY}]}' '/tmpRoot/etc.defaults/synoinfo.conf'" >>"${TMP_PATH}/rp.txt" -done + +# Generate synoinfo configurations +{ + echo "_set_conf_kv 'SN' '${SN}' '/tmpRoot/etc/synoinfo.conf'" + echo "_set_conf_kv 'SN' '${SN}' '/tmpRoot/etc.defaults/synoinfo.conf'" + for KEY in "${!SYNOINFO[@]}"; do + echo "_set_conf_kv '${KEY}' '${SYNOINFO[${KEY}]}' '/tmpRoot/etc/synoinfo.conf'" + echo "_set_conf_kv '${KEY}' '${SYNOINFO[${KEY}]}' '/tmpRoot/etc.defaults/synoinfo.conf'" + done +} >"${TMP_PATH}/rp.txt" + sed -e "/@@@CONFIG-GENERATED@@@/ {" -e "r ${TMP_PATH}/rp.txt" -e 'd' -e '}' -i "${RAMDISK_PATH}/sbin/init.post" rm -f "${TMP_PATH}/rp.txt" diff --git a/files/initrd/opt/arc/vmlinux-to-bzImage.sh b/files/initrd/opt/arc/vmlinux-to-bzImage.sh index 5019bb0d..b4c392c3 100755 --- a/files/initrd/opt/arc/vmlinux-to-bzImage.sh +++ b/files/initrd/opt/arc/vmlinux-to-bzImage.sh @@ -3,11 +3,36 @@ [[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)" -. "${ARC_PATH}/include/functions.sh" +calculate_run_size() { + NUM='\([0-9a-fA-F]*[ \t]*\)' + OUT=$(sed -n 's/^[ \t0-9]*.b[sr][sk][ \t]*'"${NUM}${NUM}${NUM}${NUM}"'.*/0x\1 0x\4/p') -PLATFORM="$(readConfigKey "platform" "${USER_CONFIG_FILE}")" -PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" -KVER="$(readConfigKey "platforms.${PLATFORM}.productvers.\"${PRODUCTVER}\".kver" "${P_FILE}")" + if [ -z "${OUT}" ]; then + echo "Never found .bss or .brk file offset" >&2 + return 1 + fi + + read -r sizeA offsetA sizeB offsetB <<<$(echo ${OUT} | awk '{printf "%d %d %d %d", strtonum($1), strtonum($2), strtonum($3), strtonum($4)}') + + runSize=$((offsetA + sizeA + sizeB)) + + # BFD linker shows the same file offset in ELF. + if [ "${offsetA}" -ne "${offsetB}" ]; then + # Gold linker shows them as consecutive. + endSize=$((offsetB + sizeB)) + if [ "${endSize}" -ne "${runSize}" ]; then + printf "sizeA: 0x%x\n" ${sizeA} >&2 + printf "offsetA: 0x%x\n" ${offsetA} >&2 + printf "sizeB: 0x%x\n" ${sizeB} >&2 + printf "offsetB: 0x%x\n" ${offsetB} >&2 + echo ".bss and .brk are non-contiguous" >&2 + return 1 + fi + fi + + printf "%d\n" ${runSize} + return 0 +} # Adapted from: scripts/Makefile.lib # Usage: size_append FILE [FILE2] [FILEn]... @@ -34,6 +59,8 @@ size_le() { VMLINUX_MOD=${1} ZIMAGE_MOD=${2} + +KVER=$(strings "${VMLINUX_MOD}" | grep -Eo "Linux version [0-9]+\.[0-9]+\.[0-9]+" | head -1 | awk '{print $3}') if [ "$(echo "${KVER:-4}" | cut -d'.' -f1)" -lt 5 ]; then # Kernel version 4.x or 3.x (bromolow) # zImage_head 16494 @@ -56,7 +83,7 @@ if [ "$(echo "${KVER:-4}" | cut -d'.' -f1)" -lt 5 ]; then file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=15745134 seek=1 conv=notrunc || exit 1 file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=15745244 seek=1 conv=notrunc || exit 1 - RUN_SIZE=$(objdump -h "${VMLINUX_MOD}" | sh "${ARC_PATH}/calc_run_size.sh") + RUN_SIZE=$(objdump -h "${VMLINUX_MOD}" | calc_run_size) size_le "${RUN_SIZE}" | dd of="${ZIMAGE_MOD}" bs=15745210 seek=1 conv=notrunc || exit 1 size_le "$((16#$(crc32 "${ZIMAGE_MOD}" | awk '{print $1}') ^ 0xFFFFFFFF))" | dd of="${ZIMAGE_MOD}" conv=notrunc oflag=append || exit 1 else @@ -66,7 +93,7 @@ else dd if="${VMLINUX_MOD}" of="${ZIMAGE_MOD}" bs=14561 seek=1 conv=notrunc || exit 1 file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=34463421 seek=1 conv=notrunc || exit 1 file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=34479132 seek=1 conv=notrunc || exit 1 - # RUN_SIZE=$(objdump -h "${VMLINUX_MOD}" | sh "${ARC_PATH}/calc_run_size.sh") + # RUN_SIZE=$(objdump -h "${VMLINUX_MOD}" | calc_run_size) # size_le "${RUN_SIZE}" | dd of="${ZIMAGE_MOD}" bs=34626904 seek=1 conv=notrunc || exit 1 size_le "$((16#$(crc32 "${ZIMAGE_MOD}" | awk '{print $1}') ^ 0xFFFFFFFF))" | dd of="${ZIMAGE_MOD}" conv=notrunc oflag=append || exit 1 fi \ No newline at end of file diff --git a/kpatch/kpatch b/kpatch/kpatch deleted file mode 100755 index 275c08ad..00000000 Binary files a/kpatch/kpatch and /dev/null differ diff --git a/kpatch/main.c b/kpatch/main.c index 200f82e3..cc02d29f 100644 --- a/kpatch/main.c +++ b/kpatch/main.c @@ -489,4 +489,4 @@ int main(int argc, char *argv[]) close(fd); printf("Finish!\n"); return 0; -} \ No newline at end of file +} diff --git a/scripts/func.sh b/scripts/func.sh index 51c8917f..cc9a702b 100755 --- a/scripts/func.sh +++ b/scripts/func.sh @@ -441,8 +441,17 @@ function convertova() { rm -rf "VMX_${VMNAME}" } +# createvmc +# $1 vhd file +# $2 vmc file function createvmc() { - cat <<_EOF_ >"${1:-arc.vmc}" + local BLIMAGE=${1:-arc.vhd} + local VMCPATH=${2:-arc.vmc} + + BLIMAGE="$(basename "${BLIMAGE}")" + VMCPATH="$(realpath "${VMCPATH}")" + + cat <<_EOF_ >"${VMCPATH}" 2.0 @@ -456,7 +465,7 @@ function createvmc() { 1 - arc.vhd + ${BLIMAGE}