From cd283ae9d997d8d3161275e1380b73ff27904b09 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 11 Jun 2023 20:01:01 +0800 Subject: [PATCH] update 2023-06-11 20:01:01 --- luci-app-amlogic/Makefile | 2 +- .../share/amlogic/amlogic_check_firmware.sh | 71 ++++++++++++++----- .../usr/share/amlogic/amlogic_check_plugin.sh | 62 ++++++++++++---- 3 files changed, 104 insertions(+), 31 deletions(-) diff --git a/luci-app-amlogic/Makefile b/luci-app-amlogic/Makefile index faa283f4..51f99ada 100644 --- a/luci-app-amlogic/Makefile +++ b/luci-app-amlogic/Makefile @@ -16,7 +16,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-amlogic -PKG_VERSION:=3.1.184 +PKG_VERSION:=3.1.186 PKG_RELEASE:=1 PKG_LICENSE:=GPL-2.0 License diff --git a/luci-app-amlogic/root/usr/share/amlogic/amlogic_check_firmware.sh b/luci-app-amlogic/root/usr/share/amlogic/amlogic_check_firmware.sh index 8bdf7a3c..78ae2fa5 100755 --- a/luci-app-amlogic/root/usr/share/amlogic/amlogic_check_firmware.sh +++ b/luci-app-amlogic/root/usr/share/amlogic/amlogic_check_firmware.sh @@ -133,25 +133,60 @@ fi check_updated() { tolog "02. Start checking for the latest version..." - # Query the latest version - latest_version="$( - curl -s \ - -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${server_firmware_url}/releases | - jq '.[]' | - jq -s --arg RTK "${releases_tag_keywords}" '.[] | select(.tag_name | contains($RTK))' | - jq -s '.[].assets[] | {data:.updated_at, url:.browser_download_url}' | - jq -s --arg BOARD "_${BOARD}_" --arg MLV "${main_line_version}." --arg FSX "${firmware_suffix}" \ - '.[] | select((.url | contains($BOARD)) and (.url | contains($MLV)) and (.url | endswith($FSX)))' | - jq -s 'sort_by(.data)|reverse[]' | - jq -s '.[0]' -c - )" - [[ "${latest_version}" == "null" ]] && tolog "02.01 Invalid OpenWrt download address." "1" - latest_updated_at="$(echo ${latest_version} | jq -r '.data')" - latest_url="$(echo ${latest_version} | jq -r '.url')" + # Set github API default value + github_page="1" + github_per_page="100" + github_releases_results=() - # Convert to readable date format - date_display_format="$(echo ${latest_updated_at} | tr 'T' '(' | tr 'Z' ')')" + # Get the release list + while true; do + response=$(curl -s -L \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/${server_firmware_url}/releases?per_page=${github_per_page}&page=${github_page}") + + # Check if the response is empty or an error occurred + if [ -z "${response}" ] || [[ "${response}" == *"Not Found"* ]]; then + break + fi + + # Append the current page's results to the overall results array + github_releases_results+=("${response}") + + # Check if the current page has fewer results than the per_page limit + if [ "$(echo "${response}" | jq '. | length')" -lt "${github_per_page}" ]; then + break + fi + + ((github_page++)) + done + + # Get the latest version + if [[ "${#github_releases_results[*]}" -ne "0" ]]; then + # Concatenate all the results into a single JSON array + all_results=$(echo "${github_releases_results[*]}" | jq -s 'add') + + # Sort the results + latest_version="$( + echo "${all_results[*]}" | + jq '.[]' | + jq -s --arg RTK "${releases_tag_keywords}" '.[] | select(.tag_name | contains($RTK))' | + jq -s '.[].assets[] | {data:.updated_at, url:.browser_download_url}' | + jq -s --arg BOARD "_${BOARD}_" --arg MLV "${main_line_version}." --arg FSX "${firmware_suffix}" \ + '.[] | select((.url | contains($BOARD)) and (.url | contains($MLV)) and (.url | endswith($FSX)))' | + jq -s 'sort_by(.data) | reverse | .[0]' -c + )" + [[ "${latest_version}" == "null" ]] && tolog "02.01 Invalid OpenWrt download address." "1" + + # Get the latest version + latest_updated_at="$(echo ${latest_version} | jq -r '.data')" + latest_url="$(echo ${latest_version} | jq -r '.url')" + + # Convert to readable date format + date_display_format="$(echo ${latest_updated_at} | tr 'T' '(' | tr 'Z' ')')" + else + tolog "02.02 The search results for releases are empty." "1" + fi # Check the firmware update code down_check_code="${latest_updated_at}.${main_line_version}" diff --git a/luci-app-amlogic/root/usr/share/amlogic/amlogic_check_plugin.sh b/luci-app-amlogic/root/usr/share/amlogic/amlogic_check_plugin.sh index 10738bee..521f0f14 100755 --- a/luci-app-amlogic/root/usr/share/amlogic/amlogic_check_plugin.sh +++ b/luci-app-amlogic/root/usr/share/amlogic/amlogic_check_plugin.sh @@ -98,18 +98,56 @@ sleep 2 # 02. Check the version on the server tolog "02. Start querying plugin version..." -# Query the latest version -latest_version="$( - curl -s \ - -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/ophub/luci-app-amlogic/releases | - jq -r '.[].tag_name' | - sort -rV | head -n 1 -)" -[[ -n "${latest_version}" ]] || tolog "02.01 Query failed, please try again." "1" -tolog "02.01 current version: ${current_plugin_v}, Latest version: ${latest_version}" -sleep 2 +# Set github API default value +github_page="1" +github_per_page="100" +github_releases_results=() +# Get the release list +while true; do + response=$(curl -s -L \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/ophub/luci-app-amlogic/releases?per_page=${github_per_page}&page=${github_page}") + + # Check if the response is empty or an error occurred + if [ -z "${response}" ] || [[ "${response}" == *"Not Found"* ]]; then + break + fi + + # Append the current page's results to the overall results array + github_releases_results+=("${response}") + + # Check if the current page has fewer results than the per_page limit + if [ "$(echo "${response}" | jq '. | length')" -lt "${github_per_page}" ]; then + break + fi + + ((github_page++)) +done + +# Get the latest version +if [[ "${#github_releases_results[*]}" -ne "0" ]]; then + # Concatenate all the results into a single JSON array + all_results=$(echo "${github_releases_results[*]}" | jq -s 'add') + + # Sort the results + latest_version="$( + echo "${all_results[*]}" | + jq -r '.[].tag_name' | + sort -rV | head -n 1 + )" + if [[ "${latest_version}" == "null" ]]; then + tolog "02.01 Query failed, please try again." "1" + else + tolog "02.01 current version: ${current_plugin_v}, Latest version: ${latest_version}" + sleep 2 + fi +else + tolog "02.01 The search results for releases are empty." "1" +fi + +# Compare the version and download the latest version if [[ "${current_plugin_v}" == "${latest_version}" ]]; then tolog "02.02 Already the latest version, no need to update." "1" else @@ -143,6 +181,6 @@ tolog "03. The plug is ready, you can update." sleep 2 #echo 'Update' >$START_LOG -tolog ' Latest version: '${server_plugin_version}'' "1" +tolog ' Latest version: '${latest_version}'' "1" exit 0