mirror of
https://github.com/RROrg/rr.git
synced 2025-06-21 05:51:05 +08:00
重构配置模块合并函数
This commit is contained in:
parent
002c6417e3
commit
e1ebf309e9
18
.github/workflows/issues.yml
vendored
18
.github/workflows/issues.yml
vendored
@ -149,6 +149,10 @@ jobs:
|
||||
# 累了, 毁灭吧!
|
||||
|
||||
# yq need sudo !!!
|
||||
function deleteConfigKey() {
|
||||
sudo yq eval "del(.${1})" --inplace "${2}" 2>/dev/null
|
||||
}
|
||||
|
||||
function writeConfigKey() {
|
||||
local value="${2}"
|
||||
[ "${value}" = "{}" ] && sudo yq eval ".${1} = {}" --inplace "${3}" 2>/dev/null || sudo yq eval ".${1} = \"${value}\"" --inplace "${3}" 2>/dev/null
|
||||
@ -159,10 +163,15 @@ jobs:
|
||||
[ "${result}" = "null" ] && echo "" || echo "${result}"
|
||||
}
|
||||
|
||||
function mergeConfigStr() {
|
||||
function mergeConfigModules() {
|
||||
# Error: bad file '-': cannot index array with '8139cp' (strconv.ParseInt: parsing "8139cp": invalid syntax)
|
||||
# When the first key is a pure number, yq will not process it as a string by default. The current solution is to insert a placeholder key.
|
||||
local MS="RRORG\n${1// /\\n}"
|
||||
local L="$(echo -en "${MS}" | awk '{print "modules."$1":"}')"
|
||||
local xmlfile=$(mktemp)
|
||||
echo "${2}" | sudo yq -p "${1}" -o y >"${xmlfile}"
|
||||
sudo yq eval-all --inplace '. as $item ireduce ({}; . * $item)' --inplace "${3}" "${xmlfile}" 2>/dev/null
|
||||
echo -en "${L}" | sudo yq -p p -o y >"${xmlfile}"
|
||||
deleteConfigKey "modules.\"RRORG\"" "${xmlfile}"
|
||||
sudo yq eval-all --inplace '. as $item ireduce ({}; . * $item)' --inplace "${2}" "${xmlfile}" 2>/dev/null
|
||||
rm -f "${xmlfile}"
|
||||
}
|
||||
|
||||
@ -233,8 +242,7 @@ jobs:
|
||||
echo "set modules: ${{ env.modules }}"
|
||||
USER_CONFIG_FILE="rr/ws/mnt/p1/user-config.yml"
|
||||
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
|
||||
L="$(for I in $(echo "${{ env.modules }}" | sed 's/,/ /g'); do echo "modules.${I}:"; done)"
|
||||
mergeConfigStr p "${L}" "${USER_CONFIG_FILE}"
|
||||
mergeConfigModules "$(echo "${{ env.modules }}" | sed 's/,/\n/g')" "${USER_CONFIG_FILE}"
|
||||
# for M in $(echo "${{ env.modules }}" | sed 's/,/ /g'); do
|
||||
# writeConfigKey "modules.\"${M}\"" "" "${USER_CONFIG_FILE}"
|
||||
# done
|
||||
|
@ -174,7 +174,7 @@ CMDLINE['log_buf_len']="32M"
|
||||
CMDLINE['rootwait']=""
|
||||
CMDLINE['panic']="${KERNELPANIC:-0}"
|
||||
# CMDLINE['nointremap']="" # no need
|
||||
# CMDLINE['split_lock_detect']="off" # no need
|
||||
# CMDLINE['split_lock_detect']="off" # check KVER
|
||||
CMDLINE['pcie_aspm']="off"
|
||||
# CMDLINE['intel_pstate']="disable"
|
||||
# CMDLINE['nox2apic']="" # check platform
|
||||
|
@ -28,13 +28,17 @@ function readConfigKey() {
|
||||
|
||||
###############################################################################
|
||||
# Write to yaml config file
|
||||
# 1 - format
|
||||
# 2 - string
|
||||
# 3 - Path of yaml config file
|
||||
function mergeConfigStr() {
|
||||
# 1 - Modules
|
||||
# 2 - Path of yaml config file
|
||||
function mergeConfigModules() {
|
||||
# Error: bad file '-': cannot index array with '8139cp' (strconv.ParseInt: parsing "8139cp": invalid syntax)
|
||||
# When the first key is a pure number, yq will not process it as a string by default. The current solution is to insert a placeholder key.
|
||||
local MS="RRORG\n${1// /\\n}"
|
||||
local L="$(echo -en "${MS}" | awk '{print "modules."$1":"}')"
|
||||
local xmlfile=$(mktemp)
|
||||
echo "${2}" | yq -p "${1}" -o y >"${xmlfile}"
|
||||
yq eval-all --inplace '. as $item ireduce ({}; . * $item)' --inplace "${3}" "${xmlfile}" 2>/dev/null
|
||||
echo -en "${L}" | yq -p p -o y >"${xmlfile}"
|
||||
deleteConfigKey "modules.\"RRORG\"" "${xmlfile}"
|
||||
yq eval-all --inplace '. as $item ireduce ({}; . * $item)' --inplace "${2}" "${xmlfile}" 2>/dev/null
|
||||
rm -f "${xmlfile}"
|
||||
}
|
||||
|
||||
|
@ -329,8 +329,7 @@ function productversMenu() {
|
||||
done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}")
|
||||
# Rewrite modules
|
||||
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
|
||||
L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')"
|
||||
mergeConfigStr p "${L}" "${USER_CONFIG_FILE}"
|
||||
mergeConfigModules "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}" | awk '{print $1}')" "${USER_CONFIG_FILE}"
|
||||
# Remove old files
|
||||
rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" >/dev/null 2>&1 || true
|
||||
rm -f "${PART1_PATH}/grub_cksum.syno" "${PART1_PATH}/GRUB_VER" "${PART2_PATH}/"* >/dev/null 2>&1 || true
|
||||
@ -409,8 +408,7 @@ function setConfigFromDSM() {
|
||||
done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}")
|
||||
# Rebuild modules
|
||||
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
|
||||
L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')"
|
||||
mergeConfigStr p "${L}" "${USER_CONFIG_FILE}"
|
||||
mergeConfigModules "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}" | awk '{print $1}')" "${USER_CONFIG_FILE}"
|
||||
touch ${PART1_PATH}/.build
|
||||
return 0
|
||||
}
|
||||
@ -692,16 +690,14 @@ function moduleMenu() {
|
||||
0)
|
||||
# ok-button
|
||||
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
|
||||
L="$(for I in $(cat ${TMP_PATH}/resp 2>/dev/null); do echo "modules.${I}:"; done)"
|
||||
mergeConfigStr p "${L}" "${USER_CONFIG_FILE}"
|
||||
mergeConfigModules "$(cat "${TMP_PATH}/resp" 2>/dev/null)" "${USER_CONFIG_FILE}"
|
||||
touch ${PART1_PATH}/.build
|
||||
break
|
||||
;;
|
||||
3)
|
||||
# extra-button
|
||||
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
|
||||
L="$(echo "${ALLMODULES}" | awk '{print "modules."$1":"}')"
|
||||
mergeConfigStr p "${L}" "${USER_CONFIG_FILE}"
|
||||
mergeConfigModules "$(echo "${ALLMODULES}" | awk '{print $1}')" "${USER_CONFIG_FILE}"
|
||||
touch ${PART1_PATH}/.build
|
||||
;;
|
||||
2)
|
||||
@ -3450,8 +3446,7 @@ function updateRR() {
|
||||
KPRE="$(readConfigKey "platforms.${PLATFORM}.productvers.\"${PRODUCTVER}\".kpre" "${WORK_PATH}/platforms.yml")"
|
||||
if [ -n "${PLATFORM}" ] && [ -n "${KVER}" ]; then
|
||||
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
|
||||
L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')"
|
||||
mergeConfigStr p "${L}" "${USER_CONFIG_FILE}"
|
||||
mergeConfigModules "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}" | awk '{print $1}')" "${USER_CONFIG_FILE}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@ -3588,8 +3583,7 @@ function updateModules() {
|
||||
KPRE="$(readConfigKey "platforms.${PLATFORM}.productvers.\"${PRODUCTVER}\".kpre" "${WORK_PATH}/platforms.yml")"
|
||||
if [ -n "${PLATFORM}" ] && [ -n "${KVER}" ]; then
|
||||
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
|
||||
L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')"
|
||||
mergeConfigStr p "${L}" "${USER_CONFIG_FILE}"
|
||||
mergeConfigModules "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}" | awk '{print $1}')" "${USER_CONFIG_FILE}"
|
||||
fi
|
||||
fi
|
||||
rm -rf "${TMP_PATH}/update"
|
||||
@ -3711,8 +3705,7 @@ function updateCKs() {
|
||||
KPRE="$(readConfigKey "platforms.${PLATFORM}.productvers.\"${PRODUCTVER}\".kpre" "${WORK_PATH}/platforms.yml")"
|
||||
if [ -n "${PLATFORM}" ] && [ -n "${KVER}" ]; then
|
||||
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
|
||||
L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')"
|
||||
mergeConfigStr p "${L}" "${USER_CONFIG_FILE}"
|
||||
mergeConfigModules "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}" | awk '{print $1}')" "${USER_CONFIG_FILE}"
|
||||
fi
|
||||
fi
|
||||
rm -rf "${TMP_PATH}/update"
|
||||
@ -4005,8 +3998,7 @@ else
|
||||
fi
|
||||
if [ -n "${PLATFORM}" ] && [ -n "${KVER}" ]; then
|
||||
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
|
||||
L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')"
|
||||
mergeConfigStr p "${L}" "${USER_CONFIG_FILE}"
|
||||
mergeConfigModules "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}" | awk '{print $1}')" "${USER_CONFIG_FILE}"
|
||||
fi
|
||||
touch ${PART1_PATH}/.build
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user