From 8559ce21005606e5be682b6d2dfa75d90601eaa2 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 13 Jun 2026 17:01:11 +0200 Subject: feat: add NVCHECKER_CONFIG constant and help text for nvchecker features Co-Authored-By: Claude Opus 4.8 --- mkhint | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mkhint') diff --git a/mkhint b/mkhint index 3fa58f0..fad50fd 100755 --- a/mkhint +++ b/mkhint @@ -19,6 +19,7 @@ set -e REPO_DIR="/var/lib/sbopkg/SBo-danix/" HINT_DIR="/etc/slackrepo/SBo-danix/hintfiles/" TMP_DIR="/tmp/mkhint" +NVCHECKER_CONFIG="$HOME/.config/nvchecker/nvchecker.toml" # create the temp dir if not existing if [[ ! -d $TMP_DIR ]]; then @@ -42,6 +43,8 @@ Usage: ./mkhint --version VERSION --hintfile FILE Update existing hint file ./mkhint --version VERSION --new FILE Create new hint file ./mkhint --new FILE Create new hint file (no version) + ./mkhint --hintfile FILE Update hint, suggest latest version via nvchecker + ./mkhint --check [FILE...] Check all (or named) hints for upstream updates ./mkhint --list List hint files ./mkhint --clean Remove .bak files from HINT_DIR ./mkhint --no-dl --hintfile FILE Update hint, skip downloads, add NODOWNLOAD=yes @@ -54,6 +57,7 @@ Options: --new, -n FILE Create new hint file (required with --version or standalone) --list, -l List all hint files in the default directory --clean, -c Remove all .bak files from HINT_DIR + --check, -C [FILE...] Check hints for upstream updates via nvchecker, update interactively --delete, -d FILE Delete a hint file (and .bak if present) --no-dl, -N Skip downloads; add NODOWNLOAD=yes to hint file (use with -f or -n) --help, -h Show this help message @@ -69,7 +73,7 @@ Exit codes: 1 - Invalid arguments or missing required options 2 - File not found 3 - File already exists - 4 - wget not available + 4 - required tool not available (wget / nvchecker / nvtake / jq) EOF } -- cgit v1.2.3 From 55aca0ef4aece09bdfa85f2f96749dfcb601034c Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 13 Jun 2026 17:03:27 +0200 Subject: feat: add check_nvchecker tool-availability guard --- mkhint | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'mkhint') diff --git a/mkhint b/mkhint index fad50fd..0eac057 100755 --- a/mkhint +++ b/mkhint @@ -125,6 +125,23 @@ check_wget() { fi } +# Validate nvchecker toolchain availability +check_nvchecker() { + local missing=() + command -v nvchecker &> /dev/null || missing+=("nvchecker") + command -v nvtake &> /dev/null || missing+=("nvtake") + command -v jq &> /dev/null || missing+=("jq") + if [[ ${#missing[@]} -gt 0 ]]; then + echo "Error: required tool(s) not installed: ${missing[*]}" >&2 + echo "Install nvchecker (provides nvchecker + nvtake) and jq." >&2 + exit 4 + fi + if [[ ! -f "$NVCHECKER_CONFIG" ]]; then + echo "Error: nvchecker config not found: $NVCHECKER_CONFIG" >&2 + exit 2 + fi +} + # download files download_file() { local url="$1" -- cgit v1.2.3 From b235e770962f6959c015c6fde66059338801634c Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 13 Jun 2026 17:04:52 +0200 Subject: feat: add nvchecker_latest keyfile reader --- mkhint | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'mkhint') 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" -- cgit v1.2.3 From e040431c8da43d7479e0583a72eb8764f521a5c7 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 13 Jun 2026 17:06:31 +0200 Subject: feat: add add_nvchecker_section with github/pypi autodetect --- mkhint | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'mkhint') diff --git a/mkhint b/mkhint index 3d19a8e..2eb21d3 100755 --- a/mkhint +++ b/mkhint @@ -259,6 +259,67 @@ EOF fi } +# Append an nvchecker [pkg] section to NVCHECKER_CONFIG, auto-detecting the +# source from the package's .info DOWNLOAD/HOMEPAGE. No-op if section exists. +add_nvchecker_section() { + local pkg="$1" + local info_file="$2" + + # Ensure config dir/file exist (do not create __config__; user owns that) + mkdir -p "$(dirname "$NVCHECKER_CONFIG")" + touch "$NVCHECKER_CONFIG" + + # Skip if section already present + if grep -qE "^\[${pkg}\][[:space:]]*$" "$NVCHECKER_CONFIG"; then + echo "nvchecker: [${pkg}] already present in $NVCHECKER_CONFIG" + return 0 + fi + + local download="" homepage="" + if [[ -f "$info_file" ]]; then + download=$(grep -E '^(DOWNLOAD|DOWNLOAD_x86_64)=' "$info_file" | head -1) + homepage=$(grep -E '^HOMEPAGE=' "$info_file" | head -1) + fi + local haystack="${download} ${homepage}" + + local section="" + if [[ "$haystack" =~ github\.com/([A-Za-z0-9._-]+)/([A-Za-z0-9._-]+) ]]; then + local owner="${BASH_REMATCH[1]}" + local repo="${BASH_REMATCH[2]}" + repo="${repo%.git}" + section=$(cat <> "$NVCHECKER_CONFIG" + echo "nvchecker: review/fill [${pkg}] section in $NVCHECKER_CONFIG" +} + # Add NODOWNLOAD=yes after MD5SUM_x86_64 line if not already present add_nodownload() { local file="$1" -- cgit v1.2.3 From d7a0fe4ae2618ffb936ac5132be9be6a70f58942 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 13 Jun 2026 17:09:18 +0200 Subject: feat: write nvchecker section on --new from .info --- mkhint | 1 + 1 file changed, 1 insertion(+) (limited to 'mkhint') diff --git a/mkhint b/mkhint index 2eb21d3..fb3858f 100755 --- a/mkhint +++ b/mkhint @@ -236,6 +236,7 @@ create_new_hint_file() { echo "generated $normalized_file from $(basename $info)." echo "Check variables before using." + add_nvchecker_section "${normalized_file%.hint}" "$info" fi else echo "Hint file exists: $normalized_file" >&2 -- cgit v1.2.3 From f77b5a5f32a8c7084c085967d8c97fd613496e30 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 13 Jun 2026 17:12:46 +0200 Subject: feat: suggest nvchecker version on --hintfile without -v --- mkhint | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'mkhint') diff --git a/mkhint b/mkhint index fb3858f..ac21d50 100755 --- a/mkhint +++ b/mkhint @@ -400,6 +400,36 @@ build_multiline_value() { printf '"\n' } +# Query nvchecker for a package's latest version and let the user accept or +# override it. Echoes the chosen version on stdout. Returns non-zero if the +# user declines or no version is available (caller decides what to do). +suggest_version() { + local pkg="$1" + + # Refresh nvchecker results (stderr only; keep stdout clean for the echo) + nvchecker -c "$NVCHECKER_CONFIG" >&2 || true + + local latest + latest=$(nvchecker_latest "$pkg") || { + echo "Error: no nvchecker result for '$pkg'. Add/fix its [${pkg}] section in $NVCHECKER_CONFIG" >&2 + return 1 + } + + # Read current version from the hint file (best effort, for display) + local hintpath="${HINT_DIR%/}/${pkg}.hint" + local current="" + [[ -f "$hintpath" ]] && current=$(grep '^VERSION=' "$hintpath" | sed 's/VERSION="//;s/"$//') + + local answer + read -r -p "current ${current:-?}, latest ${latest}. Use ${latest}? [Y/n] (or type a version) " answer >&2 + answer="${answer:-Y}" + case "$answer" in + [Yy]) printf '%s\n' "$latest" ;; + [Nn]) return 1 ;; + *) printf '%s\n' "$answer" ;; + esac +} + # Download files and update MD5SUM/MD5SUM_x86_64 in hint file update_checksums() { local file="$1" @@ -632,7 +662,7 @@ main() { if [[ -z "$COMMAND" ]]; then # Default to update hint file if VERSION and HINT_FILE are provided - if [[ -n "$VERSION" && -n "$HINT_FILE" ]]; then + if [[ -n "$HINT_FILE" ]]; then COMMAND="update" elif [[ -n "$NEW_HINT_FILE" ]]; then COMMAND="new" @@ -658,7 +688,15 @@ main() { ;; update) check_wget + if [[ -z "$VERSION" ]]; then + check_nvchecker + VERSION=$(suggest_version "$HINT_FILE") || { echo "Aborted." >&2; exit 0; } + check_nvchecker_take=1 + fi update_hint_file "$HINT_FILE" "$VERSION" + if [[ "${check_nvchecker_take:-0}" -eq 1 ]]; then + nvtake -c "$NVCHECKER_CONFIG" "$HINT_FILE" >&2 || true + fi prompt_slackrepo "$HINT_FILE" ;; new) -- cgit v1.2.3 From 5ef74c07e6a61a1473fe1898a706fb073001a147 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 13 Jun 2026 17:17:38 +0200 Subject: feat: add --check/-C bulk update command --- mkhint | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 2 deletions(-) (limited to 'mkhint') diff --git a/mkhint b/mkhint index ac21d50..a41921c 100755 --- a/mkhint +++ b/mkhint @@ -600,11 +600,98 @@ clean_bak_files() { echo "Removed $count .bak file(s) from $HINT_DIR" } +# Bulk-check hint files for upstream updates and apply interactively. +# Usage: check_updates [pkg...] (no args = all *.hint in HINT_DIR) +check_updates() { + check_nvchecker + + if [[ ! -d "$HINT_DIR" ]]; then + echo "Error: Hint directory does not exist: $HINT_DIR" >&2 + exit 2 + fi + + # Build the target package list + local targets=() + if [[ $# -gt 0 ]]; then + targets=("$@") + else + local f + for f in "$HINT_DIR"/*.hint; do + [[ -f "$f" ]] || continue + local b; b=$(basename "$f"); targets+=("${b%.hint}") + done + fi + + # Refresh nvchecker results once for everything + echo "Running nvchecker..." + nvchecker -c "$NVCHECKER_CONFIG" >&2 || true + + # Classify each target + local outdated_pkgs=() outdated_old=() outdated_new=() outdated_flag=() + local pkg + for pkg in "${targets[@]}"; do + local hintpath="${HINT_DIR%/}/${pkg}.hint" + [[ -f "$hintpath" ]] || { echo "skip ${pkg}: no hint file"; continue; } + local current; current=$(grep '^VERSION=' "$hintpath" | sed 's/VERSION="//;s/"$//') + local latest + latest=$(nvchecker_latest "$pkg") || { echo "skip ${pkg}: no nvchecker source"; continue; } + [[ "$current" == "$latest" ]] && continue # up to date + # determine direction with sort -V + local newest; newest=$(printf '%s\n%s\n' "$current" "$latest" | sort -V | tail -1) + local flag="update" + [[ "$newest" == "$current" ]] && flag="?downgrade" + outdated_pkgs+=("$pkg") + outdated_old+=("$current") + outdated_new+=("$latest") + outdated_flag+=("$flag") + done + + if [[ ${#outdated_pkgs[@]} -eq 0 ]]; then + echo "all up to date" + return 0 + fi + + # Report + echo "" + echo "Updates available:" + local i + for (( i=0; i<${#outdated_pkgs[@]}; i++ )); do + local note=""; [[ "${outdated_flag[$i]}" == "?downgrade" ]] && note=" (?downgrade)" + printf " %-30s %s -> %s%s\n" "${outdated_pkgs[$i]}" "${outdated_old[$i]}" "${outdated_new[$i]}" "$note" + done + echo "" + + # Per-package confirm + update + local updated=() + for (( i=0; i<${#outdated_pkgs[@]}; i++ )); do + local p="${outdated_pkgs[$i]}" + local note=""; [[ "${outdated_flag[$i]}" == "?downgrade" ]] && note=" (?downgrade)" + local answer + read -r -p "${p} ${outdated_old[$i]} -> ${outdated_new[$i]}${note}. Update? [Y/n] " answer + answer="${answer:-Y}" + if [[ "$answer" =~ ^[Yy]$ ]]; then + update_hint_file "$p" "${outdated_new[$i]}" + nvtake -c "$NVCHECKER_CONFIG" "$p" >&2 || true + updated+=("$p") + fi + done + + # Single slackrepo prompt for everything updated + if [[ ${#updated[@]} -gt 0 ]]; then + local answer + read -r -p "Run 'slackrepo update ${updated[*]}'? [Y/n] " answer + answer="${answer:-Y}" + if [[ "$answer" =~ ^[Yy]$ ]]; then + slackrepo update "${updated[@]}" + fi + fi +} + # Main function main() { local parsed - parsed=$(getopt -o v:f:n:lcdNh \ - --long version:,hintfile:,new:,list,clean,delete,no-dl,help \ + parsed=$(getopt -o v:f:n:lcCdNh \ + --long version:,hintfile:,new:,list,clean,check,delete,no-dl,help \ -n 'mkhint' -- "$@") || { show_help; exit 1; } eval set -- "$parsed" @@ -630,6 +717,10 @@ main() { COMMAND="clean" shift ;; + --check|-C) + COMMAND="check" + shift + ;; --delete|-d) COMMAND="delete" shift @@ -676,6 +767,11 @@ main() { exit 1 fi + if [[ "$COMMAND" == "check" && ( -n "$VERSION" || -n "$HINT_FILE" || -n "$NEW_HINT_FILE" ) ]]; then + echo "Error: --check cannot be combined with --version/--hintfile/--new" >&2 + exit 1 + fi + case "$COMMAND" in help) show_help @@ -686,6 +782,9 @@ main() { clean) clean_bak_files ;; + check) + check_updates "${DELETE_HINT_FILES[@]}" + ;; update) check_wget if [[ -z "$VERSION" ]]; then -- cgit v1.2.3 From aadbfb4f261c4ab5c69548c4f317dcfa724a4341 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 13 Jun 2026 17:56:26 +0200 Subject: refactor: extract _has_nvchecker_section helper Co-Authored-By: Claude Opus 4.8 --- mkhint | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'mkhint') diff --git a/mkhint b/mkhint index a41921c..45a123b 100755 --- a/mkhint +++ b/mkhint @@ -6,9 +6,10 @@ # ./mkhint --version VERSION --hintfile FILE Update existing hint file # ./mkhint --version VERSION --new FILE Create new hint file # ./mkhint --new FILE Create new hint file (no version) +# ./mkhint --hintfile FILE Update hint, suggest latest version via nvchecker +# ./mkhint --check [FILE...] Check all (or named) hints for upstream updates # ./mkhint --list List hint files # ./mkhint --clean Remove .bak files from HINT_DIR -# ./mkhint --delete FILE Delete a hint file (and .bak if present) # ./mkhint --no-dl --hintfile FILE Update hint, skip downloads, add NODOWNLOAD=yes # ./mkhint --no-dl --new FILE Create hint with NODOWNLOAD=yes # ./mkhint --help Show this help @@ -260,6 +261,13 @@ EOF fi } +# Return 0 if NVCHECKER_CONFIG already has a [pkg] section +_has_nvchecker_section() { + local pkg="$1" + [[ -f "$NVCHECKER_CONFIG" ]] || return 1 + grep -qE "^\[${pkg}\][[:space:]]*$" "$NVCHECKER_CONFIG" +} + # Append an nvchecker [pkg] section to NVCHECKER_CONFIG, auto-detecting the # source from the package's .info DOWNLOAD/HOMEPAGE. No-op if section exists. add_nvchecker_section() { @@ -271,7 +279,7 @@ add_nvchecker_section() { touch "$NVCHECKER_CONFIG" # Skip if section already present - if grep -qE "^\[${pkg}\][[:space:]]*$" "$NVCHECKER_CONFIG"; then + if _has_nvchecker_section "$pkg"; then echo "nvchecker: [${pkg}] already present in $NVCHECKER_CONFIG" return 0 fi -- cgit v1.2.3 From bd881dbcfba6bfd1b49100cfb1282db990232ea2 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 13 Jun 2026 17:57:05 +0200 Subject: feat: --check offers to populate missing nvchecker sections Co-Authored-By: Claude Opus 4.8 --- mkhint | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'mkhint') diff --git a/mkhint b/mkhint index 45a123b..e266609 100755 --- a/mkhint +++ b/mkhint @@ -636,13 +636,22 @@ check_updates() { # Classify each target local outdated_pkgs=() outdated_old=() outdated_new=() outdated_flag=() + local missing_sections=() local pkg for pkg in "${targets[@]}"; do local hintpath="${HINT_DIR%/}/${pkg}.hint" [[ -f "$hintpath" ]] || { echo "skip ${pkg}: no hint file"; continue; } local current; current=$(grep '^VERSION=' "$hintpath" | sed 's/VERSION="//;s/"$//') local latest - latest=$(nvchecker_latest "$pkg") || { echo "skip ${pkg}: no nvchecker source"; continue; } + if ! latest=$(nvchecker_latest "$pkg"); then + if _has_nvchecker_section "$pkg"; then + echo "skip ${pkg}: no nvchecker result" + else + echo "skip ${pkg}: no nvchecker section" + missing_sections+=("$pkg") + fi + continue + fi [[ "$current" == "$latest" ]] && continue # up to date # determine direction with sort -V local newest; newest=$(printf '%s\n%s\n' "$current" "$latest" | sort -V | tail -1) @@ -654,6 +663,29 @@ check_updates() { outdated_flag+=("$flag") done + # Offer to populate nvchecker.toml for packages with no section + if [[ ${#missing_sections[@]} -gt 0 ]]; then + echo "" + echo "${#missing_sections[@]} package(s) have no nvchecker section: ${missing_sections[*]}" + local answer + read -r -p "Populate ${NVCHECKER_CONFIG} now? [Y/n] " answer + answer="${answer:-Y}" + if [[ "$answer" =~ ^[Yy]$ ]]; then + local mp info + for mp in "${missing_sections[@]}"; do + info=$(find "$REPO_DIR" -mindepth 2 -name "${mp}.info" 2>/dev/null | head -1) + if [[ -z "$info" ]]; then + echo "skip ${mp}: no .info found in $REPO_DIR" + continue + fi + add_nvchecker_section "$mp" "$info" + done + echo "" + echo "Sections added. Review $NVCHECKER_CONFIG (fill any stubs), then re-run 'mkhint -C'." + return 0 + fi + fi + if [[ ${#outdated_pkgs[@]} -eq 0 ]]; then echo "all up to date" return 0 -- cgit v1.2.3 From 1be322b71ef7ff19cff6e35551c1a1cc240ca52d Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sat, 13 Jun 2026 18:26:19 +0200 Subject: fix: quote nvchecker section names containing non-bare-key chars Section names with '.', '-', etc. must be TOML-quoted (e.g. ["yt-dlp"]), otherwise nvchecker fails to parse them. add_nvchecker_section wrote bare [pkg] headers, so such names had to be hand-quoted. Worse, _has_nvchecker_section only matched the bare form, so already-present quoted sections were reported as missing and re-flagged for populate on every 'mkhint -C' run. Add _nvchecker_label helper as the single source of truth for the written label (bare iff name matches ^[A-Za-z0-9_]+$, else double-quoted), used by both the write side (3 section headers + messages) and the read side (_has_nvchecker_section grep, with regex metachars escaped so '.' is literal). Tests T32-T34 cover quoted-header write, no-duplicate on re---new, and --check recognizing an existing quoted section. Co-Authored-By: Claude Opus 4.8 --- mkhint | 31 ++++++++++++++++++++++------- tests/mkhint_test.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 7 deletions(-) (limited to 'mkhint') diff --git a/mkhint b/mkhint index e266609..05094e9 100755 --- a/mkhint +++ b/mkhint @@ -261,11 +261,26 @@ EOF fi } -# Return 0 if NVCHECKER_CONFIG already has a [pkg] section +# Emit the TOML section label for a package: bare if the name is a valid +# bare key ([A-Za-z0-9_] only), otherwise double-quoted. nvchecker (and TOML) +# require quoting for names containing '.', '-', etc. +_nvchecker_label() { + local pkg="$1" + if [[ "$pkg" =~ ^[A-Za-z0-9_]+$ ]]; then + printf '[%s]' "$pkg" + else + printf '["%s"]' "$pkg" + fi +} + +# Return 0 if NVCHECKER_CONFIG already has a section for pkg (bare or quoted) _has_nvchecker_section() { local pkg="$1" [[ -f "$NVCHECKER_CONFIG" ]] || return 1 - grep -qE "^\[${pkg}\][[:space:]]*$" "$NVCHECKER_CONFIG" + local label; label=$(_nvchecker_label "$pkg") + # fixed-string match of the exact label at line start, trailing space allowed + grep -qE "^$(printf '%s' "$label" | sed 's/[][\.*^$/]/\\&/g')[[:space:]]*$" \ + "$NVCHECKER_CONFIG" } # Append an nvchecker [pkg] section to NVCHECKER_CONFIG, auto-detecting the @@ -278,9 +293,11 @@ add_nvchecker_section() { mkdir -p "$(dirname "$NVCHECKER_CONFIG")" touch "$NVCHECKER_CONFIG" + local label; label=$(_nvchecker_label "$pkg") + # Skip if section already present if _has_nvchecker_section "$pkg"; then - echo "nvchecker: [${pkg}] already present in $NVCHECKER_CONFIG" + echo "nvchecker: ${label} already present in $NVCHECKER_CONFIG" return 0 fi @@ -298,7 +315,7 @@ add_nvchecker_section() { repo="${repo%.git}" section=$(cat <> "$NVCHECKER_CONFIG" - echo "nvchecker: review/fill [${pkg}] section in $NVCHECKER_CONFIG" + echo "nvchecker: review/fill ${label} section in $NVCHECKER_CONFIG" } # Add NODOWNLOAD=yes after MD5SUM_x86_64 line if not already present diff --git a/tests/mkhint_test.sh b/tests/mkhint_test.sh index c2c8fb7..2a17f32 100755 --- a/tests/mkhint_test.sh +++ b/tests/mkhint_test.sh @@ -17,6 +17,7 @@ setup() { "$MOCK_REPO/development/clion" \ "$MOCK_REPO/development/ghpkg" \ "$MOCK_REPO/python/pypkg" \ + "$MOCK_REPO/multimedia/yt-dlp" \ "$MOCK_HINT" \ "$MOCK_TMP" @@ -88,6 +89,20 @@ MD5SUM_x86_64="" REQUIRES="" MAINTAINER="Test" EMAIL="test@test.com" +EOF + + # github .info with a dash in the package name (needs TOML quoting) + cat > "$MOCK_REPO/multimedia/yt-dlp/yt-dlp.info" << 'EOF' +PRGNAM="yt-dlp" +VERSION="2024.1.1" +HOMEPAGE="https://github.com/yt-dlp/yt-dlp" +DOWNLOAD="https://github.com/yt-dlp/yt-dlp/archive/2024.1.1/yt-dlp-2024.1.1.tar.gz" +MD5SUM="55555555555555555555555555555555" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +REQUIRES="" +MAINTAINER="Test" +EMAIL="test@test.com" EOF # nvchecker config + keyfile for tests @@ -662,6 +677,47 @@ echo "$out" | grep -q "no .info found" \ || { echo " FAIL: 'no .info found' not in output"; echo "$out" | sed 's/^/ /'; (( FAIL++ )); ERRORS+=("T31 no info"); } assert_not_contains "no orphanpkg section added" "$MOCK_BASE/nvchecker.toml" '\[orphanpkg\]' +# ── T32: --new with dash in name → section header is TOML-quoted ─────────────── +echo "" +echo "T32: --new yt-dlp → [\"yt-dlp\"] quoted header written" +cat > "$MOCK_BASE/nvchecker.toml" << EOF +[__config__] +oldver = "$MOCK_BASE/old_ver.json" +newver = "$MOCK_BASE/new_ver.json" +EOF +rm -f "$MOCK_HINT"/*.hint "$MOCK_HINT"/*.bak 2>/dev/null +run_mkhint -n yt-dlp +assert_contains "quoted section header" "$MOCK_BASE/nvchecker.toml" '^\["yt-dlp"\]' +assert_not_contains "no bare header" "$MOCK_BASE/nvchecker.toml" '^\[yt-dlp\]' +assert_contains "github source" "$MOCK_BASE/nvchecker.toml" 'github = "yt-dlp/yt-dlp"' + +# ── T33: _has_nvchecker_section matches quoted header → no duplicate on re---new +echo "" +echo "T33: --new yt-dlp again → quoted section not duplicated" +run_mkhint -n yt-dlp # section already exists from T32 (quoted) +dup_count=$(grep -cE '^\["yt-dlp"\]' "$MOCK_BASE/nvchecker.toml") +assert_exit_code "quoted yt-dlp appears once" 1 "$dup_count" + +# ── T34: --check sees quoted section as present, not "no section" ────────────── +echo "" +echo "T34: --check with existing quoted section → not flagged missing" +# yt-dlp quoted section present (from T32); not in keyfile → 'no nvchecker result', NOT 'no section' +cat > "$MOCK_HINT/yt-dlp.hint" << 'EOF' +VERSION="2024.1.1" +ARCH="x86_64" +DOWNLOAD="https://github.com/yt-dlp/yt-dlp/archive/2024.1.1/yt-dlp-2024.1.1.tar.gz" +MD5SUM="55555555555555555555555555555555" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +EOF +out=$(run_mkhint -C yt-dlp < <(printf 'n\n') 2>&1) +echo "$out" | grep -q "yt-dlp: no nvchecker result" \ + && { echo " PASS: quoted section recognized (no result, not no section)"; (( PASS++ )); } \ + || { echo " FAIL: quoted section not recognized"; echo "$out" | sed 's/^/ /'; (( FAIL++ )); ERRORS+=("T34 quoted recognized"); } +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++ )); } + # ─── SUMMARY ────────────────────────────────────────────────────────────────── teardown -- cgit v1.2.3 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(+) (limited to 'mkhint') 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