diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index e6d23edb..eeae6b37 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -157,6 +157,13 @@ jobs: [ "${RESULT}" == "null" ] && echo "" || echo "${RESULT}" } + function mergeConfigStr() { + local JF=$(mktemp) + echo "${2}" | yq -p ${1} -o y > "${JF}" + yq eval-all --inplace '. as $item ireduce ({}; . * $item)' --inplace "${3}" "${JF}" 2>/dev/null + rm -f "${JF}" + } + REPO="${{ github.server_url }}/${{ github.repository }}" MODEL="${{ env.model }}" VERSION="${{ env.version }}" @@ -200,10 +207,9 @@ jobs: fi if [ -n "${{ env.kernel }}" ]; then - echo -en "set kernel" + echo "set kernel" USER_CONFIG_FILE="rr/ws/mnt/p1/user-config.yml" writeConfigKey "kernel" "${{ env.kernel }}" "${USER_CONFIG_FILE}" - echo "" fi sudo ./localbuild.sh config "${MODEL}" "${VERSION}" @@ -213,29 +219,20 @@ jobs: fi if [ -n "${{ env.addons }}" ]; then - echo -en "set addons" + echo "set addons: ${{ env.addons }}" USER_CONFIG_FILE="rr/ws/mnt/p1/user-config.yml" writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}" - echo -en ': ' - for A in $(echo "${{ env.addons }}" | tr ',' ' '); do - echo -en "${A} " - VALUE="" - writeConfigKey "addons.\"${A}\"" "${VALUE}" "${USER_CONFIG_FILE}" + for A in $(echo "${{ env.addons }}" | sed 's/,/ /g'); do + writeConfigKey "addons.\"${A}\"" "" "${USER_CONFIG_FILE}" done - echo "" fi if [ ! "custom" = "${{ env.kernel }}" ] && [ -n "${{ env.modules }}" ]; then - echo -en "set modules" + echo "set modules: ${{ env.modules }}" USER_CONFIG_FILE="rr/ws/mnt/p1/user-config.yml" writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - echo -en ': ' - for M in $(echo "${{ env.modules }}" | tr ',' ' '); do - echo -en "${M} " - VALUE="" - writeConfigKey "modules.\"${M}\"" "${VALUE}" "${USER_CONFIG_FILE}" - done - echo "" + L="$(for I in $(echo "${{ env.modules }}" | sed 's/,/ /g'); do echo "modules.${I}:"; done)" + mergeConfigStr p "${L}" "${USER_CONFIG_FILE}" fi sudo ./localbuild.sh build diff --git a/files/initrd/opt/rr/include/configFile.sh b/files/initrd/opt/rr/include/configFile.sh index 1aa459bf..d1b72d38 100755 --- a/files/initrd/opt/rr/include/configFile.sh +++ b/files/initrd/opt/rr/include/configFile.sh @@ -25,6 +25,17 @@ function readConfigKey() { [ "${RESULT}" == "null" ] && echo "" || echo "${RESULT}" } +# Write to yaml config file +# 1 - format +# 2 - string +# 3 - Path of yaml config file +function mergeConfigStr() { + local JF=$(mktemp) + echo "${2}" | yq -p ${1} -o y > "${JF}" + yq eval-all --inplace '. as $item ireduce ({}; . * $item)' --inplace "${3}" "${JF}" 2>/dev/null + rm -f "${JF}" +} + ############################################################################### # Write to yaml config file if key not exists # 1 - Path of Key diff --git a/files/initrd/opt/rr/menu.sh b/files/initrd/opt/rr/menu.sh index 9045757b..64df4490 100755 --- a/files/initrd/opt/rr/menu.sh +++ b/files/initrd/opt/rr/menu.sh @@ -346,9 +346,8 @@ function productversMenu() { done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}") # Rewrite modules writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - while read ID DESC; do - writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" - done <<<$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}") + L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')" + mergeConfigStr p "${L}" "${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 @@ -424,9 +423,8 @@ function setConfigFromDSM() { done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}") # Rebuild modules writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - while read ID DESC; do - writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" - done <<<$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}") + L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')" + mergeConfigStr p "${L}" "${USER_CONFIG_FILE}" touch ${PART1_PATH}/.build return 0 } @@ -702,19 +700,16 @@ function moduleMenu() { RET=$? case ${RET} in 0) # ok-button - resp=$(cat ${TMP_PATH}/resp) writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - for ID in ${resp}; do - writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" - done + L="$(for I in $(cat ${TMP_PATH}/resp 2>/dev/null); do echo "modules.${I}:"; done)" + mergeConfigStr p "${L}" "${USER_CONFIG_FILE}" touch ${PART1_PATH}/.build break ;; 3) # extra-button writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - while read ID DESC; do - writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" - done <<<${ALLMODULES} + L="$(echo "${ALLMODULES}" | awk '{print "modules."$1":"}')" + mergeConfigStr p "${L}" "${USER_CONFIG_FILE}" touch ${PART1_PATH}/.build ;; 2) # help-button @@ -3012,9 +3007,8 @@ function updateRR() { KPRE="$(readConfigKey "platforms.${PLATFORM}.productvers.\"${PRODUCTVER}\".kpre" "${WORK_PATH}/platforms.yml")" if [ -n "${PLATFORM}" -a -n "${KVER}" ]; then writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - while read ID DESC; do - writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" - done <<<$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}") + L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')" + mergeConfigStr p "${L}" "${USER_CONFIG_FILE}" fi fi fi @@ -3149,9 +3143,8 @@ function updateModules() { KPRE="$(readConfigKey "platforms.${PLATFORM}.productvers.\"${PRODUCTVER}\".kpre" "${WORK_PATH}/platforms.yml")" if [ -n "${PLATFORM}" -a -n "${KVER}" ]; then writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - while read ID DESC; do - writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" - done <<<$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}") + L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')" + mergeConfigStr p "${L}" "${USER_CONFIG_FILE}" fi fi rm -rf "${TMP_PATH}/update" @@ -3271,9 +3264,8 @@ function updateCKs() { KPRE="$(readConfigKey "platforms.${PLATFORM}.productvers.\"${PRODUCTVER}\".kpre" "${WORK_PATH}/platforms.yml")" if [ -n "${PLATFORM}" -a -n "${KVER}" ]; then writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - while read ID DESC; do - writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" - done <<<$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}") + L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')" + mergeConfigStr p "${L}" "${USER_CONFIG_FILE}" fi fi rm -rf "${TMP_PATH}/update" @@ -3552,9 +3544,8 @@ else fi if [ -n "${PLATFORM}" -a -n "${KVER}" ]; then writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - while read ID DESC; do - writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" - done <<<$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}") + L="$(echo "$(getAllModules "${PLATFORM}" "$([ -n "${KPRE}" ] && echo "${KPRE}-")${KVER}")" | awk '{print "modules."$1":"}')" + mergeConfigStr p "${L}" "${USER_CONFIG_FILE}" fi touch ${PART1_PATH}/.build