aboutsummaryrefslogtreecommitdiffstats
path: root/mkhint
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-06-13 17:04:52 +0200
committerDanilo M. <danix@danix.xyz>2026-06-13 17:04:52 +0200
commitb235e770962f6959c015c6fde66059338801634c (patch)
tree1d63a35c05e2fc3051ddf8de9084d435c9d56017 /mkhint
parent55aca0ef4aece09bdfa85f2f96749dfcb601034c (diff)
downloadmkhintfile-b235e770962f6959c015c6fde66059338801634c.tar.gz
mkhintfile-b235e770962f6959c015c6fde66059338801634c.zip
feat: add nvchecker_latest keyfile reader
Diffstat (limited to 'mkhint')
-rwxr-xr-xmkhint28
1 files changed, 28 insertions, 0 deletions
diff --git a/mkhint b/mkhint
index 0eac057..3d19a8e 100755
--- a/mkhint
+++ b/mkhint
@@ -142,6 +142,34 @@ check_nvchecker() {
fi
}
+# Echo the newver-keyfile path declared in [__config__] of NVCHECKER_CONFIG
+_nvchecker_newver_path() {
+ # Grab the `newver = "..."` value; tolerate spaces around =
+ local line
+ line=$(grep -E '^[[:space:]]*newver[[:space:]]*=' "$NVCHECKER_CONFIG" | head -1)
+ [[ -z "$line" ]] && return 1
+ # extract the quoted path
+ local path
+ path=$(printf '%s\n' "$line" | sed -E 's/^[^"]*"([^"]*)".*/\1/')
+ [[ -z "$path" ]] && return 1
+ # expand a leading ~ to $HOME
+ path="${path/#\~/$HOME}"
+ printf '%s\n' "$path"
+}
+
+# Echo the latest version nvchecker found for a package, or return non-zero
+# Usage: latest=$(nvchecker_latest pkg) || handle "no version"
+nvchecker_latest() {
+ local pkg="$1"
+ local keyfile
+ keyfile=$(_nvchecker_newver_path) || return 1
+ [[ -f "$keyfile" ]] || return 1
+ local ver
+ ver=$(jq -r --arg p "$pkg" '.data[$p].version // empty' "$keyfile" 2>/dev/null)
+ [[ -z "$ver" ]] && return 1
+ printf '%s\n' "$ver"
+}
+
# download files
download_file() {
local url="$1"