From 50b062e44dc3df1e418d791f07196e64eafa1b7d Mon Sep 17 00:00:00 2001 From: Ing Date: Fri, 3 May 2024 15:19:12 +0800 Subject: [PATCH] fix something --- files/initrd/opt/rr/boot.sh | 4 ++-- files/initrd/opt/rr/include/functions.sh | 8 ++++---- files/initrd/opt/rr/init.sh | 3 +-- files/initrd/opt/rr/menu.sh | 6 +++--- files/initrd/opt/rr/model-configs/SA6400.yml | 1 - .../opt/rr/patch/ramdisk-init-script-v4-00000.patch | 10 ++++++---- .../opt/rr/patch/ramdisk-init-script-v4-64216.patch | 13 ++++++++----- .../opt/rr/patch/ramdisk-init-script-v4-69057.patch | 13 ++++++++----- files/initrd/opt/rr/vmlinux-to-bzImage.sh | 3 +-- scripts/func.sh | 2 +- 10 files changed, 34 insertions(+), 29 deletions(-) diff --git a/files/initrd/opt/rr/boot.sh b/files/initrd/opt/rr/boot.sh index c0f3bbd8..2391836c 100755 --- a/files/initrd/opt/rr/boot.sh +++ b/files/initrd/opt/rr/boot.sh @@ -127,7 +127,7 @@ fi if [ ! "${BUS}" = "usb" ]; then SZ=$(blockdev --getsz ${LOADER_DISK} 2>/dev/null) # SZ=$(cat /sys/block/${LOADER_DISK/\/dev\//}/size) SS=$(blockdev --getss ${LOADER_DISK} 2>/dev/null) # SS=$(cat /sys/block/${LOADER_DISK/\/dev\//}/queue/hw_sector_size) - SIZE=$((${SZ} * ${SS} / 1024 / 1024 + 10)) + SIZE=$((${SZ:-0} * ${SS:-0} / 1024 / 1024 + 10)) # Read SATADoM type DOM="$(readModelKey "${MODEL}" "dom")" CMDLINE['synoboot_satadom']="${DOM}" @@ -271,7 +271,7 @@ else # Executes DSM kernel via KEXEC KEXECARGS="" KVER=$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver") - if [ "${KVER:0:1}" = "3" -a ${EFI} -eq 1 ]; then + if [ $(echo "${KVER:-4}" | cut -d'.' -f1) -lt 4 ] && [ ${EFI} -eq 1 ]; then echo -e "\033[1;33m$(TEXT "Warning, running kexec with --noefi param, strange things will happen!!")\033[0m" KEXECARGS="--noefi" fi diff --git a/files/initrd/opt/rr/include/functions.sh b/files/initrd/opt/rr/include/functions.sh index d9b7d881..ba4d5453 100755 --- a/files/initrd/opt/rr/include/functions.sh +++ b/files/initrd/opt/rr/include/functions.sh @@ -223,15 +223,15 @@ function _get_fastest() { # @1 -mac1,mac2,mac3... function _sort_netif() { ETHLIST="" - ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) # real network cards list + ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" # real network cards list for ETH in ${ETHX}; do MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')" - BUS=$(ethtool -i ${ETH} 2>/dev/null | grep bus-info | awk '{print $2}') + BUS="$(ethtool -i ${ETH} 2>/dev/null | grep bus-info | cut -d' ' -f2)" ETHLIST="${ETHLIST}${BUS} ${MAC} ${ETH}\n" done if [ -n "${1}" ]; then - MACS=$(echo "${1}" | sed 's/://g' | tr '[:upper:]' '[:lower:]' | tr ',' ' ') + MACS="$(echo "${1}" | sed 's/://g' | tr '[:upper:]' '[:lower:]' | tr ',' ' ')" ETHLISTTMPC="" ETHLISTTMPF="" @@ -260,7 +260,7 @@ EOF while true; do # cat ${TMP_PATH}/ethlist [ ${IDX} -ge $(wc -l <${TMP_PATH}/ethlist) ] && break - ETH=$(cat ${TMP_PATH}/ethlist | sed -n "$((${IDX} + 1))p" | awk '{print $3}') + ETH="$(cat ${TMP_PATH}/ethlist | sed -n "$((${IDX} + 1))p" | cut -d' ' -f3)" # echo "ETH: ${ETH}" if [ -n "${ETH}" ] && [ ! "${ETH}" = "eth${IDX}" ]; then # echo "change ${ETH} <=> eth${IDX}" diff --git a/files/initrd/opt/rr/init.sh b/files/initrd/opt/rr/init.sh index db50d373..bfb5bf4c 100755 --- a/files/initrd/opt/rr/init.sh +++ b/files/initrd/opt/rr/init.sh @@ -48,7 +48,6 @@ initConfigKey "patsum" "" "${USER_CONFIG_FILE}" initConfigKey "sn" "" "${USER_CONFIG_FILE}" initConfigKey "mac1" "" "${USER_CONFIG_FILE}" initConfigKey "mac2" "" "${USER_CONFIG_FILE}" -# initConfigKey "maxdisks" "" "${USER_CONFIG_FILE}" initConfigKey "layout" "qwerty" "${USER_CONFIG_FILE}" initConfigKey "keymap" "" "${USER_CONFIG_FILE}" initConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}" @@ -62,7 +61,7 @@ initConfigKey "addons.reboottoloader" "" "${USER_CONFIG_FILE}" initConfigKey "modules" "{}" "${USER_CONFIG_FILE}" if [ ! "LOCALBUILD" = "${LOADER_DISK}" ]; then - # _sort_netif "$(readConfigKey "addons.sortnetif" "${USER_CONFIG_FILE}")" + _sort_netif "$(readConfigKey "addons.sortnetif" "${USER_CONFIG_FILE}")" for ETH in ${ETHX}; do [ "${ETH::4}" = "wlan" ] && connectwlanif "${ETH}" && sleep 1 diff --git a/files/initrd/opt/rr/menu.sh b/files/initrd/opt/rr/menu.sh index 5701280a..c8ff9fd0 100755 --- a/files/initrd/opt/rr/menu.sh +++ b/files/initrd/opt/rr/menu.sh @@ -252,14 +252,14 @@ function productversMenu() { fi local KVER=$(readModelKey "${MODEL}" "productvers.[${resp}].kver") - if [ -d "/sys/firmware/efi" -a "${KVER:0:1}" = "3" ]; then + if [ $(echo "${KVER:-4}" | cut -d'.' -f1) -lt 4 ] && [ -d "/sys/firmware/efi" ]; then if [ -z "${1}" ]; then DIALOG --title "$(TEXT "Product Version")" \ --msgbox "$(TEXT "This version does not support UEFI startup, Please select another version or switch the startup mode.")" 0 0 fi return 1 fi - # if [ ! "usb" = "$(getBus "${LOADER_DISK}")" -a "${KVER:0:1}" = "5" ]; then + # if [ ! "usb" = "$(getBus "${LOADER_DISK}")" ] && [ $(echo "${KVER:-4}" | cut -d'.' -f1) -gt 4 ]; then # if [ -z "${1}" ]; then # DIALOG --title "$(TEXT "Product Version")" \ # --msgbox "$(TEXT "This version only support usb startup, Please select another version or switch the startup mode.")" 0 0 @@ -2614,7 +2614,7 @@ function advancedMenu() { cp -Rf "$(dirname ${WORK_PATH})" "${RDXZ_PATH}/" ( cd "${RDXZ_PATH}" - find . 2>/dev/null | cpio -o -H newc -R root:root | xz --check=crc32 >"${RR_RAMDISK_FILE}" + find . 2>/dev/null | cpio -o -H newc -R root:root | xz -9 --check=crc32 >"${RR_RAMDISK_FILE}" ) || true rm -rf "${RDXZ_PATH}" DIALOG --title "$(TEXT "Advanced")" \ diff --git a/files/initrd/opt/rr/model-configs/SA6400.yml b/files/initrd/opt/rr/model-configs/SA6400.yml index dadee52c..f213651f 100644 --- a/files/initrd/opt/rr/model-configs/SA6400.yml +++ b/files/initrd/opt/rr/model-configs/SA6400.yml @@ -33,7 +33,6 @@ serial: middle: "UMR" suffix: "alpha" macpre: 9009d0 -dom: -1 dt: true beta: false productvers: diff --git a/files/initrd/opt/rr/patch/ramdisk-init-script-v4-00000.patch b/files/initrd/opt/rr/patch/ramdisk-init-script-v4-00000.patch index 85513b0e..c84fc33f 100644 --- a/files/initrd/opt/rr/patch/ramdisk-init-script-v4-00000.patch +++ b/files/initrd/opt/rr/patch/ramdisk-init-script-v4-00000.patch @@ -1,17 +1,19 @@ --- a/linuxrc.syno.impl +++ b/linuxrc.syno.impl -@@ -38,6 +38,8 @@ +@@ -38,6 +38,9 @@ UnknownSynoPartitionMigrationFlag="/.unknown_syno_partition_migrate" IncompatibleRootDevice="/.incompatible_root_device" ++ +/addons/addons.sh early + UmountRoot() { grep "^${RootDevice}" /proc/mounts && /bin/umount -f ${Mnt} -@@ -59,5 +61,6 @@ +@@ -59,5 +61,7 @@ fi ++ + /addons/addons.sh jrExit UmountRoot @@ -21,9 +23,9 @@ # insert basic USB modules for detect f401/FDT echo "Insert basic USB modules..." SYNOLoadModules $USB_MODULES -+ + +/addons/addons.sh modules - ++ # insert Etron USB3.0 drivers @@ -209,6 +214,8 @@ diff --git a/files/initrd/opt/rr/patch/ramdisk-init-script-v4-64216.patch b/files/initrd/opt/rr/patch/ramdisk-init-script-v4-64216.patch index c3e1ab6e..9daef4ee 100644 --- a/files/initrd/opt/rr/patch/ramdisk-init-script-v4-64216.patch +++ b/files/initrd/opt/rr/patch/ramdisk-init-script-v4-64216.patch @@ -1,18 +1,20 @@ --- a/linuxrc.syno.impl +++ b/linuxrc.syno.impl -@@ -51,6 +51,8 @@ +@@ -51,6 +51,9 @@ UnknownSynoPartitionMigrationFlag="/.unknown_syno_partition_migrate" IncompatibleRootDevice="/.incompatible_root_device" ++ +/addons/addons.sh early + UmountRoot() { grep "^${RootDevice}" /proc/mounts && /bin/umount -f ${Mnt} -@@ -67,6 +69,7 @@ +@@ -67,6 +69,8 @@ # show date for login info date ++ + /addons/addons.sh jrExit UmountRoot @@ -20,17 +22,18 @@ @@ -176,6 +179,8 @@ echo "Insert basic USB modules..." SYNOLoadModules $USB_MODULES -+ + +/addons/addons.sh modules - ++ # insert Etron USB3.0 drivers if [ $KERNEL_VCODE -ge "$(KernelVersionCode "3.10")" ]; then -@@ -224,6 +229,7 @@ +@@ -224,6 +229,8 @@ fi fi +/addons/addons.sh patches ++ LoadBrmModules #################################################### diff --git a/files/initrd/opt/rr/patch/ramdisk-init-script-v4-69057.patch b/files/initrd/opt/rr/patch/ramdisk-init-script-v4-69057.patch index 6c82f632..18b20f4f 100644 --- a/files/initrd/opt/rr/patch/ramdisk-init-script-v4-69057.patch +++ b/files/initrd/opt/rr/patch/ramdisk-init-script-v4-69057.patch @@ -1,18 +1,20 @@ --- a/linuxrc.syno.impl +++ b/linuxrc.syno.impl -@@ -51,6 +51,8 @@ +@@ -51,6 +51,9 @@ UnknownSynoPartitionMigrationFlag="/.unknown_syno_partition_migrate" IncompatibleRootDevice="/.incompatible_root_device" ++ +/addons/addons.sh early + UmountRoot() { grep "^${RootDevice}" /proc/mounts && /bin/umount -f ${Mnt} -@@ -67,6 +69,7 @@ +@@ -67,6 +69,8 @@ # show date for login info date ++ + /addons/addons.sh jrExit if [ "$1" -eq 0 ]; then TryRestoringDeviceBackToSwapRaid @@ -20,17 +22,18 @@ @@ -176,6 +179,8 @@ echo "Insert basic USB modules..." SYNOLoadModules $USB_MODULES -+ + +/addons/addons.sh modules - ++ # insert Etron USB3.0 drivers if [ $KERNEL_VCODE -ge "$(KernelVersionCode "3.10")" ]; then -@@ -224,6 +229,7 @@ +@@ -224,6 +229,8 @@ fi fi +/addons/addons.sh patches ++ LoadBrmModules if [ "$KERNEL_VCODE" -ge "$(KernelVersionCode "5.10")" ]; then diff --git a/files/initrd/opt/rr/vmlinux-to-bzImage.sh b/files/initrd/opt/rr/vmlinux-to-bzImage.sh index 3385a64e..f52030d5 100755 --- a/files/initrd/opt/rr/vmlinux-to-bzImage.sh +++ b/files/initrd/opt/rr/vmlinux-to-bzImage.sh @@ -43,8 +43,7 @@ size_le() { VMLINUX_MOD=${1} ZIMAGE_MOD=${2} -KVER_MAJOR=${KVER:0:1} -if [ ${KVER_MAJOR} -eq 4 ] || [ ${KVER_MAJOR} -eq 3 ]; then +if [ $(echo "${KVER:-4}" | cut -d'.' -f1) -lt 5 ]; then # Kernel version 4.x or 3.x (bromolow) #zImage_head 16494 #payload( diff --git a/scripts/func.sh b/scripts/func.sh index 4f776a37..4e942abf 100755 --- a/scripts/func.sh +++ b/scripts/func.sh @@ -252,7 +252,7 @@ function repackInitrd() { [ -f "${OUTPUT_PATH}" ] && rm -rf "${OUTPUT_PATH}" ( cd "${RDXZ_PATH}" - sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | xz --check=crc32 >"${OUTPUT_PATH}" + sudo find . 2>/dev/null | sudo cpio -o -H newc -R root:root | xz -9 --check=crc32 >"${OUTPUT_PATH}" ) || true sudo rm -rf "${RDXZ_PATH}" }