From 8e6531764b00b29259fc59bd4e1f16e019bc3f2a Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 13 Jun 2026 18:33:34 +0200 Subject: fix: resolve relative nvchecker keyfile path against config dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nvchecker resolves a relative oldver/newver/keyfile path against the config file's directory, not the CWD. _nvchecker_newver_path returned the raw relative string (e.g. "new_ver.json"), so nvchecker_latest's [[ -f ]] check ran against whatever CWD 'mkhint -C' was launched from — almost never the config dir. Result: every package reported 'no nvchecker result' and the run said 'all up to date' despite nvchecker having found updates. Resolve non-absolute keyfile paths against dirname(NVCHECKER_CONFIG). T35 covers a relative newver path with the keyfile beside the config. Co-Authored-By: Claude Opus 4.8 --- mkhint | 5 +++++ tests/mkhint_test.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/mkhint b/mkhint index 05094e9..7311ffe 100755 --- a/mkhint +++ b/mkhint @@ -155,6 +155,11 @@ _nvchecker_newver_path() { [[ -z "$path" ]] && return 1 # expand a leading ~ to $HOME path="${path/#\~/$HOME}" + # nvchecker resolves a relative keyfile path against the config file's + # directory (not the CWD), so do the same here. + if [[ "$path" != /* ]]; then + path="$(dirname "$NVCHECKER_CONFIG")/$path" + fi printf '%s\n' "$path" } diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh index 2a17f32..dd88c05 100755 --- a/tests/mkhint_test.sh +++ b/tests/mkhint_test.sh @@ -718,6 +718,32 @@ echo "$out" | grep -q "yt-dlp: no nvchecker section" \ && { echo " FAIL: quoted section wrongly flagged missing"; (( FAIL++ )); ERRORS+=("T34 false missing"); } \ || { echo " PASS: not flagged as missing section"; (( PASS++ )); } +# ── T35: relative newver path resolved against config dir, not CWD ───────────── +echo "" +echo "T35: relative newver path in config → resolved against config dir" +# config uses a RELATIVE newver path (as nvchecker writes by default). +# keyfile lives beside the config in $MOCK_BASE. The run happens with CWD +# elsewhere (the repo dir), so a CWD-relative read would fail to find it. +cat > "$MOCK_BASE/nvchecker.toml" << EOF +[__config__] +oldver = "old_ver.json" +newver = "new_ver.json" +EOF +cat > "$MOCK_BASE/new_ver.json" << 'EOF' +{ "version": 2, "data": { "curl": { "version": "8.9.0" } } } +EOF +rm -f "$MOCK_HINT"/*.hint "$MOCK_HINT"/*.bak 2>/dev/null +cat > "$MOCK_HINT/curl.hint" << 'EOF' +VERSION="8.5.0" +ARCH="x86_64" +DOWNLOAD="https://curl.se/download/curl-8.5.0.tar.gz" +MD5SUM="abc123def456abc123def456abc123de" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +EOF +run_mkhint -C curl < <(printf 'Y\nn\n') +assert_contains "relative-path keyfile found → curl updated" "$MOCK_HINT/curl.hint" 'VERSION="8.9.0"' + # ─── SUMMARY ────────────────────────────────────────────────────────────────── teardown -- cgit v1.2.3