From e84901061eb7421a78930cd27acba480420fbd49 Mon Sep 17 00:00:00 2001 From: Rudi Heitbaum Date: Sun, 16 Jul 2023 12:39:30 +0000 Subject: [PATCH] tools/update-scan: always check github for version if pkg_version is a githash examples of before and after: before change: Package | LE git master | upstream location -------------------------------------------------------------------------------------------------------------------------------------------- connman | 9971144ae862e83f1f5d8cb84c0b62f2542dcdec | 1.41 crossguid | ca1bf4b810e2d188d04cb6286f957008ee1b7681 | 0.2.2 dbussy | 691a8a8a1914416b7ea1545fb931d74f2e381f09 | 1.3 dvblast | 4270dcae7b754b25ad27332bb1c55b6b23b85b0d | 3.4 dvbsnoop | 72a64d59b6b00272fbfbeebdc9da9d6e8ace67da | 1.4.50 enet | 8d69c5abe4b699e7077395e01927bd102b3ba597 | 1.3.17 heimdal | f4faaeaba371fff3f8d1bc14389f5e6d70ca8e17 | 7.8.0 after change: Package | LE git master | upstream location -------------------------------------------------------------------------------------------------------------------------------------------- connman | 24180d1243bf005c721be6f9d8d6da67bb669c55 | 1.41 dvblast | 4270dcae7b754b25ad27332bb1c55b6b23b85b0d | 3.4 enet | Commit date: 2021-06-12 | 1.3.17 | GitHead: 2023-07-08 | TAG: v1.3.17 (2020-11-15) heimdal | Commit date: 2022-11-17 | 7.8.0 | GitHead: 2023-06-24 | TAG: upstream-1.4.0+git20110220.dfsg.1 (2011-02-12) notes: connman, dbussy, dvbsnoop - not listed as they are at the latest githash on github enet, heimdal - showing the LE git master date | the release-monitoring version | the github default branch date | the github latest tag --- tools/update-scan | 62 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/tools/update-scan b/tools/update-scan index 1e5829f42b..5f92e6116d 100755 --- a/tools/update-scan +++ b/tools/update-scan @@ -71,42 +71,40 @@ check_for_update() { ;; esac - # look for alternative versions if necessary - if [ "${upstream_version}" = "null" ]; then - if [[ $(echo "${RMO_API_RESPONSE}" | jq -r '.error') =~ "No package" ]]; then - # pkg is on github, uses githash for version, and github api available - if [[ ${PKG_URL} =~ ^.*(github\.com).*$ ]] && \ - [[ ${PKG_VERSION} =~ ^[a-z0-9]{40} ]] && \ - [[ "${github_api}" = "yes" ]]; then + # if pkg_version is a githash on github and github api available - always check against latest + if [[ ${PKG_VERSION} =~ ^[a-z0-9]{40} ]] && \ + [[ ${PKG_URL} =~ ^.*(github\.com).*$ ]] && \ + [[ "${github_api}" = "yes" ]]; then - github_repos=$(echo "${PKG_URL}" | grep -oP '(?<=https:\/\/github.com\/)?[0-9A-Za-z._-]+\/[0-9A-Za-z._-]+(?=/archive|/tags|/releases)') - le_master_version_date="Commit date: $(curl -sL ${github_api_token} https://api.github.com/repos/${github_repos}/git/commits/${PKG_VERSION} | jq -r '.committer.date')" - upstream_default_branch=$(curl -sL "${github_api_token}" "https://api.github.com/repos/${github_repos}" | jq -r '.default_branch') - upstream_latest_commit=$(curl -sL "${github_api_token}" "https://api.github.com/repos/${github_repos}/git/refs/heads/${upstream_default_branch}" | jq -r '.object.url') - upstream_latest_commit_date=$(curl -sL "${github_api_token}" "${upstream_latest_commit}" | jq -r '.committer.date') - GH_API_TAG=$(curl -sL "${github_api_token}" "https://api.github.com/repos/${github_repos}/tags") - upstream_latest_tag=$(echo "${GH_API_TAG}" | jq -r '.[0].name') - upstream_latest_tag_url=$(echo "${GH_API_TAG}" | jq -r '.[0].commit.url') - upstream_latest_tag_date=$(curl -sL "${github_api_token}" "${upstream_latest_tag_url}" | jq -r '.commit.committer.date') + github_repos=$(echo "${PKG_URL}" | grep -oP '(?<=https:\/\/github.com\/)?[0-9A-Za-z._-]+\/[0-9A-Za-z._-]+(?=/archive|/tags|/releases)') + le_master_version_date="Commit date: $(curl -sL ${github_api_token} https://api.github.com/repos/${github_repos}/git/commits/${PKG_VERSION} | jq -r '.committer.date')" + upstream_default_branch=$(curl -sL "${github_api_token}" "https://api.github.com/repos/${github_repos}" | jq -r '.default_branch') + upstream_latest_commit=$(curl -sL "${github_api_token}" "https://api.github.com/repos/${github_repos}/git/refs/heads/${upstream_default_branch}" | jq -r '.object.url') + upstream_latest_commit_date=$(curl -sL "${github_api_token}" "${upstream_latest_commit}" | jq -r '.committer.date') + GH_API_TAG=$(curl -sL "${github_api_token}" "https://api.github.com/repos/${github_repos}/tags") + upstream_latest_tag=$(echo "${GH_API_TAG}" | jq -r '.[0].name') + upstream_latest_tag_url=$(echo "${GH_API_TAG}" | jq -r '.[0].commit.url') + upstream_latest_tag_date=$(curl -sL "${github_api_token}" "${upstream_latest_tag_url}" | jq -r '.commit.committer.date') - # compare upstream with local version - if [ "${PKG_VERSION}" != "${upstream_latest_commit##*/}" ]; then - # get upstream tag informations - if [ "${upstream_latest_tag}" != "null" ]; then - tag=" | TAG: ${upstream_latest_tag} (${upstream_latest_tag_date%T*})" - else - tag=" | TAG: no tags" - fi - upstream_version="Master: ${upstream_latest_commit_date%T*}${tag}" - PKG_VERSION="${le_master_version_date%T*}" - else - upstream_version="${upstream_latest_commit##*/}" - fi + # compare upstream with local version + if [ "${PKG_VERSION}" != "${upstream_latest_commit##*/}" ]; then + # get upstream tag informations + if [ "${upstream_latest_tag}" != "null" ]; then + tag=" | TAG: ${upstream_latest_tag} (${upstream_latest_tag_date%T*})" else - # package is not on tracker or github - PACKAGES_NOT_REGISTERED+="${PKG_NAME} " - return + tag=" | TAG: no tags" fi + [[ "${upstream_version}" = "null" ]] && upstream_version="" || upstream_version+=" | " + upstream_version="${upstream_version}GitHead: ${upstream_latest_commit_date%T*}${tag}" + PKG_VERSION="${le_master_version_date%T*}" + else + upstream_version="${upstream_latest_commit##*/}" + fi + elif [ "${upstream_version}" = "null" ]; then + if [[ $(echo "${RMO_API_RESPONSE}" | jq -r '.error') =~ "No package" ]]; then + # package is not on tracker or github + PACKAGES_NOT_REGISTERED+="${PKG_NAME} " + return else # package exist at tracker but has no version upstream_version="! broken at release tracker !"