Skip to content

Commit

Permalink
tree: more fixes
Browse files Browse the repository at this point in the history
Signed-off-by: AuxXxilium <[email protected]>
  • Loading branch information
AuxXxilium committed Dec 11, 2024
1 parent 6b0d2da commit 7e48118
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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##*/}"
Expand Down
23 changes: 14 additions & 9 deletions files/initrd/opt/arc/arc-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
36 changes: 0 additions & 36 deletions files/initrd/opt/arc/calc_run_size.sh

This file was deleted.

Binary file modified files/initrd/opt/arc/kpatch
Binary file not shown.
18 changes: 11 additions & 7 deletions files/initrd/opt/arc/ramdisk-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
39 changes: 33 additions & 6 deletions files/initrd/opt/arc/vmlinux-to-bzImage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]...
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Binary file removed kpatch/kpatch
Binary file not shown.
2 changes: 1 addition & 1 deletion kpatch/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,4 +489,4 @@ int main(int argc, char *argv[])
close(fd);
printf("Finish!\n");
return 0;
}
}
13 changes: 11 additions & 2 deletions scripts/func.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
<?xml version="1.0" encoding="UTF-8"?>
<preferences>
<version type="string">2.0</version>
Expand All @@ -456,7 +465,7 @@ function createvmc() {
<location id="0">
<drive_type type="integer">1</drive_type>
<pathname>
<relative type="string">arc.vhd</relative>
<relative type="string">${BLIMAGE}</relative>
</pathname>
</location>
</ide_controller>
Expand Down

0 comments on commit 7e48118

Please sign in to comment.