diff --git a/files/initrd/opt/arc/bzImage-template-v4.gz b/files/initrd/opt/arc/bzImage-template-v4.gz deleted file mode 100755 index cb00ed1..0000000 Binary files a/files/initrd/opt/arc/bzImage-template-v4.gz and /dev/null differ diff --git a/files/initrd/opt/arc/bzImage-template-v5.gz b/files/initrd/opt/arc/bzImage-template-v5.gz deleted file mode 100755 index 7a8d145..0000000 Binary files a/files/initrd/opt/arc/bzImage-template-v5.gz and /dev/null differ diff --git a/files/initrd/opt/arc/bzImage-to-vmlinux.sh b/files/initrd/opt/arc/bzImage-to-vmlinux.sh deleted file mode 100755 index 5241e92..0000000 --- a/files/initrd/opt/arc/bzImage-to-vmlinux.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -read_u8() { - dd if=$1 bs=1 skip=$(($2)) count=1 2>/dev/null | od -An -tu1 | grep -Eo '[0-9]+' -} -read_u32() { - dd if=$1 bs=1 skip=$(($2)) count=4 2>/dev/null | od -An -tu4 | grep -Eo '[0-9]+' -} - -set -x -setup_size=$(read_u8 $1 0x1f1) -payload_offset=$(read_u32 $1 0x248) -payload_length=$(read_u32 $1 0x24c) -inner_pos=$((($setup_size + 1) * 512)) - -tail -c+$(($inner_pos + 1)) $1 | tail -c+$(($payload_offset + 1)) | head -c $(($payload_length)) | head -c $(($payload_length - 4)) | unlzma >$2 \ No newline at end of file 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 e648b83..0000000 --- a/files/initrd/opt/arc/calc_run_size.sh +++ /dev/null @@ -1,42 +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}"'.*/\1\4/p') -if [ -z "$OUT" ]; then - echo "Never found .bss or .brk file offset" >&2 - exit 1 -fi - -OUT=$(echo ${OUT# }) -sizeA=$(printf "%d" 0x${OUT%% *}) -OUT=${OUT#* } -offsetA=$(printf "%d" 0x${OUT%% *}) -OUT=${OUT#* } -sizeB=$(printf "%d" 0x${OUT%% *}) -OUT=${OUT#* } -offsetB=$(printf "%d" 0x${OUT%% *}) - -run_size=$((${offsetA} + ${sizeA} + ${sizeB})) - -# BFD linker shows the same file offset in ELF. -if [ "${offsetA}" -ne "${offsetB}" ]; then - # Gold linker shows them as consecutive. - endB=$((${offsetB} + ${sizeB})) - if [ "$endB" != "$run_size" ]; 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" ${run_size} -exit 0 \ No newline at end of file diff --git a/files/initrd/opt/arc/depmod b/files/initrd/opt/arc/depmod deleted file mode 120000 index 7615828..0000000 --- a/files/initrd/opt/arc/depmod +++ /dev/null @@ -1 +0,0 @@ -kmod \ No newline at end of file diff --git a/files/initrd/opt/arc/fbszie b/files/initrd/opt/arc/fbszie deleted file mode 100755 index 1a6c1e7..0000000 Binary files a/files/initrd/opt/arc/fbszie and /dev/null differ diff --git a/files/initrd/opt/arc/include/consts.sh b/files/initrd/opt/arc/include/consts.sh index a226829..d31db3e 100755 --- a/files/initrd/opt/arc/include/consts.sh +++ b/files/initrd/opt/arc/include/consts.sh @@ -1,38 +1,14 @@ ARC_VERSION="23.1.1" -ARC_TITLE="Arc ${ARC_VERSION}" +ARC_TITLE="Arc-V ${ARC_VERSION}" # Define paths PART1_PATH="/mnt/p1" PART2_PATH="/mnt/p2" PART3_PATH="/mnt/p3" -DSMROOT_PATH="/mnt/dsmroot" TMP_PATH="/tmp" -UPLOAD_PATH="${TMP_PATH}/upload" -UNTAR_PAT_PATH="${TMP_PATH}/DSM" -RAMDISK_PATH="${TMP_PATH}/ramdisk" -LOG_FILE="${TMP_PATH}/log.txt" - -USER_CONFIG_FILE="${PART1_PATH}/user-config.yml" GRUB_PATH="${PART1_PATH}/boot/grub" -ORI_ZIMAGE_FILE="${PART2_PATH}/zImage" -ORI_RDGZ_FILE="${PART2_PATH}/rd.gz" - ARC_BZIMAGE_FILE="${PART3_PATH}/bzImage-arc" -ARC_RAMDISK_FILE="${PART3_PATH}/initrd-arc" -MOD_ZIMAGE_FILE="${PART3_PATH}/zImage-dsm" -MOD_RDGZ_FILE="${PART3_PATH}/initrd-dsm" - -ADDONS_PATH="${PART3_PATH}/addons" -MODULES_PATH="${PART3_PATH}/modules" -MODEL_CONFIG_PATH="${PART3_PATH}/configs" -PATCH_PATH="${PART3_PATH}/patches" -LKM_PATH="${PART3_PATH}/lkms" -USER_UP_PATH="${PART3_PATH}/users" -BACKUPDIR="${PART3_PATH}/backup" -BB_USER_CONFIG_FILE="${BACKUPDIR}/user-config.yml" - -EXTRACTOR_PATH="${PART3_PATH}/extractor" -EXTRACTOR_BIN="syno_extract_system_patch" \ No newline at end of file +ARC_RAMDISK_FILE="${PART3_PATH}/initrd-arc" \ No newline at end of file diff --git a/files/initrd/opt/arc/init.sh b/files/initrd/opt/arc/init.sh index 1c491e8..46885ee 100755 --- a/files/initrd/opt/arc/init.sh +++ b/files/initrd/opt/arc/init.sh @@ -170,22 +170,14 @@ done # Inform user echo -echo -e "Call \033[1;34marc.sh\033[0m to configure loader" +echo -e "Call \033[1;34marc.sh\033[0m to configure Arc-V" echo echo -e "User config is on \033[1;34m${USER_CONFIG_FILE}\033[0m" echo -e "Default SSH Root password is \033[1;34marc\033[0m" echo -mkdir -p "${ADDONS_PATH}" -mkdir -p "${LKM_PATH}" -mkdir -p "${MODULES_PATH}" -mkdir -p "${MODEL_CONFIG_PATH}" -mkdir -p "${PATCH_PATH}" -mkdir -p "${BACKUPDIR}" - -# Load arc -updateAddons -echo -e "\033[1;34mLoading Arc Loader Overlay...\033[0m" +# Load Arc-V +echo -e "\033[1;34mLoading Arc-V Overlay...\033[0m" sleep 2 # Diskcheck @@ -198,7 +190,7 @@ for D in $(lsblk -dpno NAME); do fi done -# Check memory and load Arc +# Check memory and load Arc-V RAM=$(free -m | grep -i mem | awk '{print$2}') if [ ${RAM} -le 3500 ]; then echo -e "\033[1;31mYou have less than 4GB of RAM, if errors occur in loader creation, please increase the amount of RAM.\033[0m\n" diff --git a/files/initrd/opt/arc/kmod b/files/initrd/opt/arc/kmod deleted file mode 100755 index 4bb1fb3..0000000 Binary files a/files/initrd/opt/arc/kmod and /dev/null differ diff --git a/files/initrd/opt/arc/kpatch b/files/initrd/opt/arc/kpatch deleted file mode 100755 index 275c08a..0000000 Binary files a/files/initrd/opt/arc/kpatch and /dev/null differ diff --git a/files/initrd/opt/arc/modinfo b/files/initrd/opt/arc/modinfo deleted file mode 120000 index 7615828..0000000 --- a/files/initrd/opt/arc/modinfo +++ /dev/null @@ -1 +0,0 @@ -kmod \ No newline at end of file diff --git a/files/initrd/opt/arc/ramdisk-patch.sh b/files/initrd/opt/arc/ramdisk-patch.sh deleted file mode 100755 index 3d56d60..0000000 --- a/files/initrd/opt/arc/ramdisk-patch.sh +++ /dev/null @@ -1,237 +0,0 @@ -#!/usr/bin/env bash - -[[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" - -. ${ARC_PATH}/include/functions.sh -. ${ARC_PATH}/include/addons.sh -. ${ARC_PATH}/include/modules.sh - -set -o pipefail # Get exit code from process piped - -# Sanity check -[ -f "${ORI_RDGZ_FILE}" ] || (die "${ORI_RDGZ_FILE} not found!" | tee -a "${LOG_FILE}") - -echo -e "Patching Ramdisk" - -# Remove old rd.gz patched -rm -f "${MOD_RDGZ_FILE}" - -# Unzipping ramdisk -rm -rf "${RAMDISK_PATH}" # Force clean -mkdir -p "${RAMDISK_PATH}" -( - cd "${RAMDISK_PATH}" - xz -dc <"${ORI_RDGZ_FILE}" | cpio -idm -) >/dev/null 2>&1 - -# Read Model Data -MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" -LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")" -SN="$(readConfigKey "arc.sn" "${USER_CONFIG_FILE}")" -LAYOUT="$(readConfigKey "layout" "${USER_CONFIG_FILE}")" -KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")" -PLATFORM="$(readModelKey "${MODEL}" "platform")" -ODP="$(readConfigKey "arc.odp" "${USER_CONFIG_FILE}")" -HDDSORT="$(readConfigKey "arc.hddsort" "${USER_CONFIG_FILE}")" - -# Check if DSM Version changed -. "${RAMDISK_PATH}/etc/VERSION" - -# Read DSM Informations -PRODUCTVERDSM="${majorversion}.${minorversion}" -PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" -KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" -RD_COMPRESSED="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].rd-compressed")" -# Read new PAT Info from Config -PAT_URL="$(readConfigKey "arc.paturl" "${USER_CONFIG_FILE}")" -PAT_HASH="$(readConfigKey "arc.pathash" "${USER_CONFIG_FILE}")" - -if [ "${PRODUCTVERDSM}" != "${PRODUCTVER}" ]; then - # Update new buildnumber - echo -e "Ramdisk Version ${PRODUCTVER} does not match DSM Version ${PRODUCTVERDSM}!" - echo -e "Try to use DSM Version ${PRODUCTVERDSM} for Patch." - writeConfigKey "productver" "${USER_CONFIG_FILE}" - PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" -fi - -# Sanity check -[[ -z "${PLATFORM}" || -z "${KVER}" ]] && (die "ERROR: Configuration for Model ${MODEL} and Version ${PRODUCTVER} not found." | tee -a "${LOG_FILE}") - -# Modify KVER for Epyc7002 -if [ "${PLATFORM}" = "epyc7002" ]; then - KVER="${PRODUCTVER}-${KVER}" -fi - -declare -A SYNOINFO -declare -A ADDONS -declare -A USERMODULES - -# Read synoinfo, addons and extensions from config -while IFS=': ' read -r KEY VALUE; do - [ -n "${KEY}" ] && SYNOINFO["${KEY}"]="${VALUE}" -done < <(readConfigMap "synoinfo" "${USER_CONFIG_FILE}") -while IFS=': ' read -r KEY VALUE; do - [ -n "${KEY}" ] && ADDONS["${KEY}"]="${VALUE}" -done < <(readConfigMap "addons" "${USER_CONFIG_FILE}") - -# Read modules from user config -while IFS=': ' read -r KEY VALUE; do - [ -n "${KEY}" ] && USERMODULES["${KEY}"]="${VALUE}" -done < <(readConfigMap "modules" "${USER_CONFIG_FILE}") - -# Patches (diff -Naru OLDFILE NEWFILE > xxx.patch) -while read -r PE; do - RET=1 - echo "Patching with ${PE}" >"${LOG_FILE}" 2>&1 - for PF in $(ls ${PATCH_PATH}/${PE} 2>/dev/null); do - echo "Patching with ${PF}" >>"${LOG_FILE}" 2>&1 - ( - cd "${RAMDISK_PATH}" - patch -p1 -i "${PF}" >>"${LOG_FILE}" 2>&1 - ) - RET=$? - [ ${RET} -eq 0 ] && break - done - [ ${RET} -ne 0 ] && dieLog -done < <(readModelArray "${MODEL}" "productvers.[${PRODUCTVER}].patch") - -# Patch /etc/synoinfo.conf -for KEY in ${!SYNOINFO[@]}; do - _set_conf_kv "${KEY}" "${SYNOINFO[${KEY}]}" "${RAMDISK_PATH}/etc/synoinfo.conf" >"${LOG_FILE}" 2>&1 || dieLog -done -# Add serial number to synoinfo.conf, to help to recovery a installed DSM -_set_conf_kv "SN" "${SN}" "${RAMDISK_PATH}/etc/synoinfo.conf" >"${LOG_FILE}" 2>&1 || dieLog - -# Patch /sbin/init.post -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" -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 -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" -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" - -# Extract Modules to Ramdisk -rm -rf "${TMP_PATH}/modules" -mkdir -p "${TMP_PATH}/modules" -# Copy Modules to Ramdisk -tar -zxf "${MODULES_PATH}/${PLATFORM}-${KVER}.tgz" -C "${TMP_PATH}/modules" -for F in $(ls "${TMP_PATH}/modules/"*.ko 2>/dev/null); do - M=$(basename ${F}) - [[ "${ODP}" = "true" && -f "${RAMDISK_PATH}/usr/lib/modules/${M}" ]] && continue - if arrayExistItem "${M:0:-3}" "${!USERMODULES[@]}"; then - cp -f "${F}" "${RAMDISK_PATH}/usr/lib/modules/${M}" - else - rm -f "${RAMDISK_PATH}/usr/lib/modules/${M}" - fi -done -mkdir -p "${RAMDISK_PATH}/usr/lib/firmware" -tar -zxf "${MODULES_PATH}/firmware.tgz" -C "${RAMDISK_PATH}/usr/lib/firmware" - -# Copying fake modprobe -cp -f "${PATCH_PATH}/iosched-trampoline.sh" "${RAMDISK_PATH}/usr/sbin/modprobe" -# Copying LKM to /usr/lib/modules -gzip -dc "${LKM_PATH}/rp-${PLATFORM}-${KVER}-${LKM}.ko.gz" >"${TMP_PATH}/modules/rp.ko" -cp -f "${TMP_PATH}/modules/rp.ko" "${RAMDISK_PATH}/usr/lib/modules/rp.ko" -# Clean -rm -rf "${TMP_PATH}/modules" - -# Addons -mkdir -p "${RAMDISK_PATH}/addons" -echo "#!/bin/sh" >"${RAMDISK_PATH}/addons/addons.sh" -echo 'echo "addons.sh called with params ${@}"' >>"${RAMDISK_PATH}/addons/addons.sh" -echo "export LOADERLABEL=ARC" >>"${RAMDISK_PATH}/addons/addons.sh" -echo "export LOADERVERSION=${ARC_VERSION}" >>"${RAMDISK_PATH}/addons/addons.sh" -echo "export PLATFORM=${PLATFORM}" >>"${RAMDISK_PATH}/addons/addons.sh" -echo "export MODEL=${MODEL}" >>"${RAMDISK_PATH}/addons/addons.sh" -echo "export MLINK=${PAT_URL}" >>"${RAMDISK_PATH}/addons/addons.sh" -echo "export MCHECKSUM=${PAT_HASH}" >>"${RAMDISK_PATH}/addons/addons.sh" -echo "export LAYOUT=${LAYOUT}" >>"${RAMDISK_PATH}/addons/addons.sh" -echo "export KEYMAP=${KEYMAP}" >>"${RAMDISK_PATH}/addons/addons.sh" -chmod +x "${RAMDISK_PATH}/addons/addons.sh" - -# Required Addons: revert -installAddon revert -echo "/addons/revert.sh \${1} " >>"${RAMDISK_PATH}/addons/addons.sh" 2>"${LOG_FILE}" || dieLog - -# Install System Addons -installAddon eudev -echo "/addons/eudev.sh \${1} " >>"${RAMDISK_PATH}/addons/addons.sh" 2>"${LOG_FILE}" || dieLog -installAddon disks -echo "/addons/disks.sh \${1} ${HDDSORT} " >>"${RAMDISK_PATH}/addons/addons.sh" 2>"${LOG_FILE}" || dieLog -installAddon localrss -echo "/addons/localrss.sh \${1} " >>"${RAMDISK_PATH}/addons/addons.sh" 2>"${LOG_FILE}" || dieLog -installAddon wol -echo "/addons/wol.sh \${1} " >>"${RAMDISK_PATH}/addons/addons.sh" 2>"${LOG_FILE}" || dieLog -installAddon misc -echo "/addons/misc.sh \${1} " >>"${RAMDISK_PATH}/addons/addons.sh" 2>"${LOG_FILE}" || dieLog - -# User Addons check -for ADDON in ${!ADDONS[@]}; do - PARAMS=${ADDONS[${ADDON}]} - if ! installAddon ${ADDON}; then - echo -n "${ADDON} is not available for this Platform!" | tee -a "${LOG_FILE}" - echo - exit 1 - fi - echo "/addons/${ADDON}.sh \${1} ${PARAMS}" >>"${RAMDISK_PATH}/addons/addons.sh" 2>"${LOG_FILE}" || dieLog -done - -# Enable Telnet -echo "inetd" >>"${RAMDISK_PATH}/addons/addons.sh" 2>"${LOG_FILE}" || dieLog - -[ "2" = "${BUILDNUM:0:1}" ] && sed -i 's/function //g' $(find "${RAMDISK_PATH}/addons/" -type f -name "*.sh") - -# Build modules dependencies -${ARC_PATH}/depmod -a -b ${RAMDISK_PATH} 2>/dev/null -# Copying modulelist -if [ -f "${USER_UP_PATH}/modulelist" ]; then - cp -f "${USER_UP_PATH}/modulelist" "${RAMDISK_PATH}/addons/modulelist" -else - cp -f "${ARC_PATH}/include/modulelist" "${RAMDISK_PATH}/addons/modulelist" -fi - -# Network card configuration file -IPV6="$(readConfigKey "arc.ipv6" "${USER_CONFIG_FILE}")" -if [ "${IPV6}" = "false" ]; then - for N in $(seq 0 7); do - echo -e "DEVICE=eth${N}\nBOOTPROTO=dhcp\nONBOOT=yes\nIPV6INIT=no" >"${RAMDISK_PATH}/etc/sysconfig/network-scripts/ifcfg-eth${N}" - done -elif [ "${IPV6}" = "true" ]; then - for N in $(seq 0 7); do - echo -e "DEVICE=eth${N}\nBOOTPROTO=dhcp\nONBOOT=yes\nIPV6INIT=dhcp\nIPV6_ACCEPT_RA=1" >"${RAMDISK_PATH}/etc/sysconfig/network-scripts/ifcfg-eth${N}" - done -fi - -# SA6400 patches -if [ "${PLATFORM}" = "epyc7002" ]; then - echo -e "Apply Epyc7002 Fixes" - sed -i 's#/dev/console#/var/log/lrc#g' ${RAMDISK_PATH}/usr/bin/busybox - sed -i '/^echo "START/a \\nmknod -m 0666 /dev/console c 1 3' ${RAMDISK_PATH}/linuxrc.syno -fi - -#if [[ "${PLATFORM}" = "kvmx64" || "${PLATFORM}" = "broadwellntbap" ]]; then -# sed -i 's/kvmx64/RRING/g' ${RAMDISK_PATH}/etc/synoinfo.conf ${RAMDISK_PATH}/etc/VERSION -#fi - -# Call user patch scripts -for F in $(ls -1 ${SCRIPTS_PATH}/*.sh 2>/dev/null); do - echo "Calling ${F}" >>"${LOG_FILE}" 2>&1 - . "${F}" >>"${LOG_FILE}" 2>&1 || dieLog -done - -# Reassembly ramdisk -if [ "${RD_COMPRESSED}" == "true" ]; then - (cd "${RAMDISK_PATH}" && find . | cpio -o -H newc -R root:root | xz -9 --format=lzma >"${MOD_RDGZ_FILE}") >"${LOG_FILE}" 2>&1 || dieLog -else - (cd "${RAMDISK_PATH}" && find . | cpio -o -H newc -R root:root >"${MOD_RDGZ_FILE}") >"${LOG_FILE}" 2>&1 || dieLog -fi - -# Clean -rm -rf "${RAMDISK_PATH}" diff --git a/files/initrd/opt/arc/vmlinux-to-bzImage.sh b/files/initrd/opt/arc/vmlinux-to-bzImage.sh deleted file mode 100755 index 3f43552..0000000 --- a/files/initrd/opt/arc/vmlinux-to-bzImage.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env bash -# Based on code and ideas from @jumkey - -[[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" - -. ${ARC_PATH}/include/functions.sh - -MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" -PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" -KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" - -# Adapted from: scripts/Makefile.lib -# Usage: size_append FILE [FILE2] [FILEn]... -# Output: LE HEX with size of file in bytes (to STDOUT) -file_size_le() { - printf $( - dec_size=0 - for F in "${@}"; do - fsize=$(stat -c "%s" ${F}) - dec_size=$((${dec_size} + ${fsize})) - done - printf "%08x\n" ${dec_size} | - sed 's/\(..\)/\1 /g' | { - read -r ch0 ch1 ch2 ch3 - for ch in ${ch3} ${ch2} ${ch1} ${ch0}; do - printf '%s%03o' '\' $((0x${ch})) - done - } - ) -} - -size_le() { - printf $( - printf "%08x\n" "${@}" | - sed 's/\(..\)/\1 /g' | { - read -r ch0 ch1 ch2 ch3 - for ch in ${ch3} ${ch2} ${ch1} ${ch0}; do - printf '%s%03o' '\' $((0x${ch})) - done - } - ) -} -SCRIPT_DIR=$(dirname $0) -VMLINUX_MOD=${1} -ZIMAGE_MOD=${2} -KVER_MAJOR=${KVER:0:1} -if [[ ${KVER_MAJOR} -eq 4 || ${KVER_MAJOR} -eq 3 ]]; then - # Kernel version 4.x or 3.x (bromolow) - #zImage_head 16494 - #payload( - # vmlinux.bin x - # padding 0xf00000-x - # vmlinux.bin size 4 - #) 0xf00004 - #zImage_tail( - # unknown 72 - # run_size 4 - # unknown 30 - # vmlinux.bin size 4 - # unknown 114460 - #) 114570 - #crc32 4 - gzip -dc "${SCRIPT_DIR}/bzImage-template-v4.gz" >"${ZIMAGE_MOD}" - - dd if="${VMLINUX_MOD}" of="${ZIMAGE_MOD}" bs=16494 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog - file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=15745134 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog - file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=15745244 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog - - RUN_SIZE=$(objdump -h ${VMLINUX_MOD} | sh "${SCRIPT_DIR}/calc_run_size.sh") - size_le ${RUN_SIZE} | dd of=${ZIMAGE_MOD} bs=15745210 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog - size_le $(($((16#$(crc32 "${ZIMAGE_MOD}" | awk '{print$1}'))) ^ 0xFFFFFFFF)) | dd of="${ZIMAGE_MOD}" conv=notrunc oflag=append >"${LOG_FILE}" 2>&1 || dieLog -else - # Kernel version 5.x - gzip -dc "${SCRIPT_DIR}/bzImage-template-v5.gz" >"${ZIMAGE_MOD}" - - dd if="${VMLINUX_MOD}" of="${ZIMAGE_MOD}" bs=14561 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog - file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=34463421 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog - file_size_le "${VMLINUX_MOD}" | dd of="${ZIMAGE_MOD}" bs=34479132 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog - # RUN_SIZE=`objdump -h ${VMLINUX_MOD} | sh "${SCRIPT_DIR}/calc_run_size.sh"` - # size_le ${RUN_SIZE} | dd of=${ZIMAGE_MOD} bs=34626904 seek=1 conv=notrunc >"${LOG_FILE}" 2>&1 || dieLog - size_le $(($((16#$(crc32 "${ZIMAGE_MOD}" | awk '{print$1}'))) ^ 0xFFFFFFFF)) | dd of="${ZIMAGE_MOD}" conv=notrunc oflag=append >"${LOG_FILE}" 2>&1 || dieLog -fi \ No newline at end of file diff --git a/files/initrd/opt/arc/zimage-patch.sh b/files/initrd/opt/arc/zimage-patch.sh deleted file mode 100755 index 2034263..0000000 --- a/files/initrd/opt/arc/zimage-patch.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -[[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" - -. ${ARC_PATH}/include/functions.sh - -set -o pipefail # Get exit code from process piped - -# Sanity check -[ -f "${ORI_ZIMAGE_FILE}" ] || (die "${ORI_ZIMAGE_FILE} not found!" | tee -a "${LOG_FILE}") - -echo -e "Patching zImage" - -rm -f "${MOD_ZIMAGE_FILE}" -# Extract vmlinux -${ARC_PATH}/bzImage-to-vmlinux.sh "${ORI_ZIMAGE_FILE}" "${TMP_PATH}/vmlinux" >"${LOG_FILE}" 2>&1 || dieLog -# Patch boot params and ramdisk check -${ARC_PATH}/kpatch "${TMP_PATH}/vmlinux" "${TMP_PATH}/vmlinux-mod" >"${LOG_FILE}" 2>&1 || dieLog -# rebuild zImage -${ARC_PATH}/vmlinux-to-bzImage.sh "${TMP_PATH}/vmlinux-mod" "${MOD_ZIMAGE_FILE}" >"${LOG_FILE}" 2>&1 || dieLog - -# Remove old Files -rm -f "${TMP_PATH}/vmlinux" "${TMP_PATH}/vmlinux-mod" \ No newline at end of file diff --git a/files/p1/boot/grub/grub.cfg b/files/p1/boot/grub/grub.cfg index 8d36791..e2370f1 100644 --- a/files/p1/boot/grub/grub.cfg +++ b/files/p1/boot/grub/grub.cfg @@ -71,25 +71,11 @@ set ARC_CMDLINE="net.ifnames=0" search --set=root --label "ARC3" if [ -s /zImage-dsm -a -s /initrd-dsm ]; then - if [ "${default}" = "direct" ]; then - set timeout="1" - menuentry 'Direct DSM Mode' --id direct { - set_gfxpayload - echo "cmdline:" - echo "${dsm_cmdline}" - echo "Loading DSM Kernel..." - linux /zImage-dsm ${dsm_cmdline} - echo "Loading DSM Initramfs..." - initrd /initrd-dsm - echo "Booting..." - echo "Access http://find.synology.com/ to connect the DSM via web." - } - fi menuentry 'DSM Mode' --id boot { set_gfxpayload - echo "Loading Arc Kernel..." + echo "Loading Arc-V Kernel..." linux /bzImage-arc console=${TERM} ${ARC_CMDLINE} - echo "Loading Arc Initramfs..." + echo "Loading Arc-V Initramfs..." initrd /initrd-arc echo "Booting..." } @@ -97,24 +83,13 @@ fi menuentry 'Config Mode' --id config { set_gfxpayload - echo "Loading Arc Kernel..." + echo "Loading Arc-V Kernel..." linux /bzImage-arc console=${TERM} ${ARC_CMDLINE} force_arc - echo "Loading Arc Initramfs..." + echo "Loading Arc-V Initramfs..." initrd /initrd-arc echo "Booting..." } -if [ -s /zImage-dsm -a -s /initrd-dsm ]; then - menuentry 'DSM force Reinstall' --id junior { - set_gfxpayload - echo "Loading Arc Kernel..." - linux /bzImage-arc console=${TERM} ${ARC_CMDLINE} force_junior - echo "Loading Arc Initramfs..." - initrd /initrd-arc - echo "Booting..." - } -fi - if [ ${vesa_mode} = 1 ]; then menuentry 'Change Vesa to Text Output' --id videomode { set vesa_mode=0 diff --git a/files/p3/configs/.gitkeep b/files/p3/configs/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/files/p3/extractor/libcurl.so.4 b/files/p3/extractor/libcurl.so.4 deleted file mode 100644 index 9a6b7b2..0000000 Binary files a/files/p3/extractor/libcurl.so.4 and /dev/null differ diff --git a/files/p3/extractor/libmbedcrypto.so.5 b/files/p3/extractor/libmbedcrypto.so.5 deleted file mode 100644 index f29e822..0000000 Binary files a/files/p3/extractor/libmbedcrypto.so.5 and /dev/null differ diff --git a/files/p3/extractor/libmbedtls.so.13 b/files/p3/extractor/libmbedtls.so.13 deleted file mode 100644 index 94a7850..0000000 Binary files a/files/p3/extractor/libmbedtls.so.13 and /dev/null differ diff --git a/files/p3/extractor/libmbedx509.so.1 b/files/p3/extractor/libmbedx509.so.1 deleted file mode 100644 index ea8ce16..0000000 Binary files a/files/p3/extractor/libmbedx509.so.1 and /dev/null differ diff --git a/files/p3/extractor/libmsgpackc.so.2 b/files/p3/extractor/libmsgpackc.so.2 deleted file mode 100644 index 66f48e3..0000000 Binary files a/files/p3/extractor/libmsgpackc.so.2 and /dev/null differ diff --git a/files/p3/extractor/libsodium.so b/files/p3/extractor/libsodium.so deleted file mode 100644 index 8cb3f3a..0000000 Binary files a/files/p3/extractor/libsodium.so and /dev/null differ diff --git a/files/p3/extractor/libsynocodesign-ng-virtual-junior-wins.so.7 b/files/p3/extractor/libsynocodesign-ng-virtual-junior-wins.so.7 deleted file mode 100644 index 559677c..0000000 Binary files a/files/p3/extractor/libsynocodesign-ng-virtual-junior-wins.so.7 and /dev/null differ diff --git a/files/p3/extractor/syno_extract_system_patch b/files/p3/extractor/syno_extract_system_patch deleted file mode 100644 index 43a659c..0000000 Binary files a/files/p3/extractor/syno_extract_system_patch and /dev/null differ diff --git a/files/p3/addons/.gitkeep b/files/p3/image/.gitkeep similarity index 100% rename from files/p3/addons/.gitkeep rename to files/p3/image/.gitkeep diff --git a/files/p3/lkms/.gitkeep b/files/p3/lkms/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/files/p3/modules/.gitkeep b/files/p3/modules/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/files/p3/patches/.gitkeep b/files/p3/patches/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/img-gen.sh b/img-gen.sh index 2deb2fd..c24aa28 100755 --- a/img-gen.sh +++ b/img-gen.sh @@ -8,13 +8,7 @@ set -e sudo git clean -fdx sudo git pull -# Get extractor, LKM, addons and Modules -getExtractor "files/p3/extractor" -getLKMs "files/p3/lkms" -getAddons "files/p3/addons" -getModules "files/p3/modules" -getConfigs "files/p3/configs" -getPatches "files/p3/patches" +# Nothing to do here IMAGE_FILE="arc-v.img" gzip -dc "files/grub.img.gz" >"${IMAGE_FILE}" diff --git a/scripts/func.sh b/scripts/func.sh index 8516a07..fc623d9 100755 --- a/scripts/func.sh +++ b/scripts/func.sh @@ -6,175 +6,6 @@ # See /LICENSE for more information. # -# Get Extractor -# $1 path -function getExtractor() { - echo "Getting syno extractor begin" - local DEST_PATH="${1:-extractor}" - local CACHE_DIR="/tmp/pat" - rm -rf "${CACHE_DIR}" - mkdir -p "${CACHE_DIR}" - # Download pat file - # global.synologydownload.com, global.download.synology.com, cndl.synology.cn - local PAT_URL="https://global.synologydownload.com/download/DSM/release/7.0.1/42218/DSM_DS3622xs%2B_42218.pat" - local PAT_FILE="DSM_DS3622xs+_42218.pat" - local STATUS=$(curl -# -w "%{http_code}" -L "${PAT_URL}" -o "${CACHE_DIR}/${PAT_FILE}") - if [ $? -ne 0 ] || [ ${STATUS} -ne 200 ]; then - echo "[E] DSM_DS3622xs%2B_42218.pat download error!" - rm -rf ${CACHE_DIR} - exit 1 - fi - - mkdir -p "${CACHE_DIR}/ramdisk" - tar -C "${CACHE_DIR}/ramdisk/" -xf "${CACHE_DIR}/${PAT_FILE}" rd.gz 2>&1 - if [ $? -ne 0 ]; then - echo "[E] extractor rd.gz error!" - rm -rf ${CACHE_DIR} - exit 1 - fi - ( - cd "${CACHE_DIR}/ramdisk" - xz -dc /dev/null 2>&1 || true - - rm -rf "${DEST_PATH}" - mkdir -p "${DEST_PATH}" - - # Copy only necessary files - for f in libcurl.so.4 libmbedcrypto.so.5 libmbedtls.so.13 libmbedx509.so.1 libmsgpackc.so.2 libsodium.so libsynocodesign-ng-virtual-junior-wins.so.7; do - cp -f "${CACHE_DIR}/ramdisk/usr/lib/${f}" "${DEST_PATH}" - done - cp -f "${CACHE_DIR}/ramdisk/usr/syno/bin/scemd" "${DEST_PATH}/syno_extract_system_patch" - - # Clean up - rm -rf ${CACHE_DIR} - echo "Getting syno extractor end" -} - -# Get latest LKMs -# $1 path -function getLKMs() { - echo "Getting LKMs begin" - local DEST_PATH="${1:-lkms}" - local CACHE_FILE="/tmp/rp-lkms.zip" - rm -f "${CACHE_FILE}" - if [ -n "${LKMTAG}" ]; then - TAG="${LKMTAG}" - else - TAG="$(curl -s "https://api.github.com/repos/AuxXxilium/redpill-lkm/releases/latest" | grep -oP '"tag_name": "\K(.*)(?=")')" - fi - STATUS=$(curl -w "%{http_code}" -L "https://github.com/AuxXxilium/redpill-lkm/releases/download/${TAG}/rp-lkms.zip" -o "${CACHE_FILE}") - echo "TAG=${TAG}; Status=${STATUS}" - [ ${STATUS} -ne 200 ] && exit 1 - # Unzip LKMs - rm -rf "${DEST_PATH}" - mkdir -p "${DEST_PATH}" - unzip "${CACHE_FILE}" -d "${DEST_PATH}" - rm -f "${CACHE_FILE}" - echo "Getting LKMs end - ${TAG}" -} - -# Get latest Addons -# $1 path -function getAddons() { - echo "Getting Addons begin" - local DEST_PATH="${1:-addons}" - local CACHE_DIR="/tmp/addons" - local CACHE_FILE="/tmp/addons.zip" - if [ -n "${ADDONSTAG}" ]; then - TAG="${ADDONSTAG}" - else - TAG="$(curl -s https://api.github.com/repos/AuxXxilium/arc-addons/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" - fi - STATUS=$(curl -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/addons.zip" -o "${CACHE_FILE}") - echo "TAG=${TAG}; Status=${STATUS}" - [ ${STATUS} -ne 200 ] && exit 1 - rm -rf "${DEST_PATH}" - mkdir -p "${DEST_PATH}" - # Install Addons - rm -rf "${CACHE_DIR}" - mkdir -p "${CACHE_DIR}" - unzip "${CACHE_FILE}" -d "${CACHE_DIR}" - echo "Installing Addons to ${DEST_PATH}" - [ -f /tmp/addons/VERSION ] && cp -f /tmp/addons/VERSION ${DEST_PATH}/ - for PKG in $(ls ${CACHE_DIR}/*.addon); do - ADDON=$(basename "${PKG}" .addon) - mkdir -p "${DEST_PATH}/${ADDON}" - echo "Extracting ${PKG} to ${DEST_PATH}/${ADDON}" - tar -xaf "${PKG}" -C "${DEST_PATH}/${ADDON}" - done - echo "Getting Addons end - ${TAG}" -} - -# Get latest Modules -# $1 path -function getModules() { - echo "Getting Modules begin" - local DEST_PATH="${1:-modules}" - local CACHE_FILE="/tmp/modules.zip" - rm -f "${CACHE_FILE}" - if [ -n "${MODULESTAG}" ]; then - TAG="${MODULESTAG}" - else - TAG="$(curl -s https://api.github.com/repos/AuxXxilium/arc-modules/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" - fi - STATUS=$(curl -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules.zip" -o "${CACHE_FILE}") - echo "TAG=${TAG}; Status=${STATUS}" - [ ${STATUS} -ne 200 ] && exit 1 - # Unzip Modules - rm -rf "${DEST_PATH}" - mkdir -p "${DEST_PATH}" - unzip "${CACHE_FILE}" -d "${DEST_PATH}" - rm -f "${CACHE_FILE}" - echo "Getting Modules end - ${TAG}" -} - -# Get latest Configs -# $1 path -function getConfigs() { - echo "Getting Configs begin" - local DEST_PATH="${1:-configs}" - local CACHE_FILE="/tmp/configs.zip" - rm -f "${CACHE_FILE}" - if [ -n "${CONFIGSTAG}" ]; then - TAG="${CONFIGSTAG}" - else - TAG="$(curl -s https://api.github.com/repos/AuxXxilium/arc-configs/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" - fi - STATUS=$(curl -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs.zip" -o "${CACHE_FILE}") - echo "TAG=${TAG}; Status=${STATUS}" - [ ${STATUS} -ne 200 ] && exit 1 - # Unzip Modules - rm -rf "${DEST_PATH}" - mkdir -p "${DEST_PATH}" - unzip "${CACHE_FILE}" -d "${DEST_PATH}" - rm -f "${CACHE_FILE}" - echo "Getting Configs end - ${TAG}" -} - -# Get latest Patches -# $1 path -function getPatches() { - echo "Getting Patches begin" - local DEST_PATH="${1:-patches}" - local CACHE_FILE="/tmp/patches.zip" - rm -f "${CACHE_FILE}" - if [ -n "${PATCHESTAG}" ]; then - TAG="${PATCHESTAG}" - else - TAG="$(curl -s https://api.github.com/repos/AuxXxilium/arc-patches/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')" - fi - STATUS=$(curl -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches.zip" -o "${CACHE_FILE}") - echo "TAG=${TAG}; Status=${STATUS}" - [ ${STATUS} -ne 200 ] && exit 1 - # Unzip Modules - rm -rf "${DEST_PATH}" - mkdir -p "${DEST_PATH}" - unzip "${CACHE_FILE}" -d "${DEST_PATH}" - rm -f "${CACHE_FILE}" - echo "Getting Patches end - ${TAG}" -} - # Get latest Buildroot # $1 TAG # $2 path