diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-25 11:22:34 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-25 11:22:34 +0200 |
| commit | 7c53c8113b53c3be157ba5df77b34a78d665c200 (patch) | |
| tree | 26e9aa24a28c7dd0b49f7b755959278d9abb63ca | |
| parent | daa73c48a7282c9b21757626b4eb141e47bdbd5c (diff) | |
| download | danix-nvchecker-master.tar.gz danix-nvchecker-master.zip | |
Packages in none of my repos are looked up in the local SlackBuilds.org
clone (NVTABLE_SBO overrides the path) and labelled [SBo]. SBo lagging
upstream is not flagged repo-behind; upstream is still appended.
With no SlackBuild anywhere, the label says how it is installed
([AppImage] or [flatpak]); [--] means neither.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | README.md | 10 | ||||
| -rwxr-xr-x | nvtable | 46 |
2 files changed, 38 insertions, 18 deletions
@@ -21,10 +21,12 @@ the version shipped by the SlackBuild repo that packages it. Each row reads `[repo] package installed -> repo`, then the markers. The upstream version is appended only when the repo column does not already show -it: the repo is behind, or the package is not in any of my repos (`[SBo]`, -built straight from SlackBuilds.org). Repo labels: `personal` = -my-slackbuilds, `my-sbo` = sbo-slackbuilds, `pentesting` = -Slackware-Pentesting-Suite. +it. A package in none of my repos is looked up in a local SlackBuilds.org +clone (`[SBo]`, `NVTABLE_SBO` overrides its path); SBo lagging upstream is +not flagged 🟡, since that bump is not mine to make. With no SlackBuild +anywhere, the label says how it is installed (`[AppImage]`, `[flatpak]`); +`[--]` means neither. Repo labels: `personal` = my-slackbuilds, `my-sbo` = +sbo-slackbuilds, `pentesting` = Slackware-Pentesting-Suite. | marker | meaning | |--------|---------| @@ -36,6 +36,9 @@ REPOS=( "my:$SUPER/my-slackbuilds" "sps:$SUPER/Slackware-Pentesting-Suite" ) +# Upstream SlackBuilds.org clone, the fallback for packages none of my repos +# ship. Looked up per tracked name rather than scanned: it holds ~9000 .info. +SBO="${NVTABLE_SBO:-/var/lib/sbopkg/SBo-git}" # Stanza name -> installed package name(s), space separated for one-to-many. # Only for names that differ; everything else joins directly. @@ -106,7 +109,7 @@ while IFS= read -r f; do [[ -n $rest ]] && PKGREST[$rest]=1 done < <(/bin/ls -1 /var/log/packages 2>/dev/null) -declare -A INST +declare -A INST ISRC # ISRC: how a non-package install got here for rest in "${!PKGREST[@]}"; do # Default split: last dash. Correct for the common case, fixed up below for # any name that a tracked stanza claims explicitly. @@ -133,7 +136,7 @@ pkg_version() { # AppImages tracked by appimage-updater (its state is authoritative for those). if [[ -r $AI_STATE ]]; then while IFS=$'\t' read -r k v; do - [[ -n $k ]] && INST[$k]=$v + [[ -n $k ]] && { INST[$k]=$v; ISRC[$k]=AppImage; } done < <(jq -r 'to_entries[]|"\(.key)\t\(.value.version)"' "$AI_STATE" 2>/dev/null) fi @@ -141,18 +144,18 @@ fi if command -v flatpak >/dev/null 2>&1; then while IFS=$'\t' read -r app v; do [[ -n $app ]] || continue - INST[${app##*.}]=$v + INST[${app##*.}]=$v; ISRC[${app##*.}]=flatpak done < <(flatpak list --app --columns=application,version 2>/dev/null) fi -installed_of() { # echoes "version" or "" ; handles alias + case-insensitive +installed_of() { # echoes "version|source" or "" ; handles alias + case-insensitive local n=$1 cand v for cand in ${ALIAS[$n]:-$n}; do # Anchored lookup first: correct even when VERSION contains a dash. - v=$(pkg_version "$cand") && { echo "$v"; return; } - [[ -n ${INST[$cand]:-} ]] && { echo "${INST[$cand]}"; return; } + v=$(pkg_version "$cand") && { echo "$v|"; return; } + [[ -n ${INST[$cand]:-} ]] && { echo "${INST[$cand]}|${ISRC[$cand]:-}"; return; } for k in "${!INST[@]}"; do - [[ ${k,,} == "${cand,,}" ]] && { echo "${INST[$k]}"; return; } + [[ ${k,,} == "${cand,,}" ]] && { echo "${INST[$k]}|${ISRC[$k]:-}"; return; } done done } @@ -193,7 +196,7 @@ vers_equal() { rows=(); take=(); n_up=0; n_repo=0; n_ok=0; n_na=0 while IFS=$'\t' read -r name uver; do [[ -n $name ]] || continue - iver=$(installed_of "$name") + iver=$(installed_of "$name"); isrc=${iver#*|}; iver=${iver%|*} rkey=$name if [[ -z ${RVER[$rkey]:-} ]]; then for cand in ${REPO_ALIAS[$name]:-} ${ALIAS[$name]:-}; do @@ -201,9 +204,23 @@ while IFS=$'\t' read -r name uver; do done fi rver=${RVER[$rkey]:-}; rwhich=${RWHICH[$rkey]:-} + if [[ -z $rver ]]; then + for cand in $name ${REPO_ALIAS[$name]:-} ${ALIAS[$name]:-}; do + for inf in "$SBO"/*/"$cand"/"$cand".info; do + [[ -r $inf ]] || continue + rver=$(sed -n 's/^VERSION="\(.*\)"$/\1/p' "$inf" | head -1) + rwhich=SBo; break 2 + done + done + fi + # No SlackBuild anywhere: label by how it is installed, if not a package. + [[ -z $rwhich ]] && rwhich=$isrc same_inst=0; [[ -n $iver ]] && vers_equal "$uver" "$iver" && same_inst=1 - same_repo=1; [[ -n $rver ]] && { vers_equal "$uver" "$rver" || same_repo=0; } + # SBo lagging upstream is not my packaging work, so it never marks the row + # repo-behind; the display still appends upstream when the two differ. + same_repo=1 + [[ -n $rver && $rwhich != SBo ]] && { vers_equal "$uver" "$rver" || same_repo=0; } if (( same_inst )) && (( same_repo )); then (( n_ok++ )); take+=("$name") @@ -227,13 +244,13 @@ done < <(jq -r '.data|to_entries[]|"\(.key)\t\(.value.version // .value)"' "$NEW if ((${#rows[@]})); then # Pad every column to its widest value before adding color (printf would # count the escape bytes as width). Upstream is appended only when the repo - # column does not already show it: repo behind, or nothing packaged. + # column does not already show it. wl=0 wn=0 wi=0 wr=0 for i in "${!rows[@]}"; do IFS='|' read -r name uver iver rver rwhich si sr <<<"${rows[i]}" lbl= for t in ${rwhich//,/ }; do lbl+=${lbl:+,}${REPO_LABEL[$t]:-$t}; done - lbl="[${lbl:-SBo}]" # not in my repos: built straight from SBo + lbl="[${lbl:---}]" rows[i]="${rows[i]}|$lbl" (( ${#lbl} > wl )) && wl=${#lbl} (( ${#name} > wn )) && wn=${#name} @@ -248,8 +265,9 @@ if ((${#rows[@]})); then else ic="$RED" fi if [[ -z $rver ]]; then rc="$DIM"; rver="--" - elif (( sr )); then rc="$GRN" - else rc="$YEL" + elif (( ! sr )); then rc="$YEL" + elif vers_equal "$uver" "$rver"; then rc="$GRN" + else rc="" # SBo behind upstream: not mine to bump fi # Installed-behind and repo-behind are independent, and a row can be both # (upstream moved, and neither the system nor the .info has caught up), so @@ -259,7 +277,7 @@ if ((${#rows[@]})); then else mark="$E_UP" fi (( sr )) || mark+=" $E_REPO" - utxt=; [[ $rver == -- ]] || (( ! sr )) && utxt=" $CYA$uver$R" + utxt=; vers_equal "$uver" "$rver" || utxt=" $CYA$uver$R" printf ' %s%-*s%s %s%-*s%s %s%*s%s -> %s%-*s%s %s%s\n' \ "$DIM" "$wl" "$lbl" "$R" "$WHT" "$wn" "$name" "$R" \ "$ic" "$wi" "$iver" "$R" "$rc" "$wr" "$rver" "$R" "$mark" "$utxt" |
