From 94d3c0ebafc693b3f95d70ae28a024e46a60937d Mon Sep 17 00:00:00 2001 From: rain Date: Tue, 23 Jun 2026 16:47:11 -0400 Subject: [PATCH] Gentoo user-packages: use qlist for missing-detect (handles non-binary pkgs) The previous missing-detect used 'command -v ' which fails for packages that don't ship a binary of the same name (zsh-completions installs /usr/share/zsh files, not /usr/bin/zsh-completions). After the previous run installed these packages, the next apply falsely reported them as missing and tried to re-install them. Switch to qlist -I which correctly reports whether a package is in the installed-db. qlist is from app-portage/gentoolkit which is already installed on gentoo. Fall back to equery, then to the basename check, in case qlist is missing. --- ...ce_20-install-user-packages-gentoo.sh.tmpl | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/run_once_20-install-user-packages-gentoo.sh.tmpl b/run_once_20-install-user-packages-gentoo.sh.tmpl index dfc9bd3..66dd265 100644 --- a/run_once_20-install-user-packages-gentoo.sh.tmpl +++ b/run_once_20-install-user-packages-gentoo.sh.tmpl @@ -88,15 +88,29 @@ GENTOO_PKGS=( ) # Step 3: Determine what's missing -# gentoo's emerge has a "is it installed?" check via `qlist` or `equery`. -# Simpler: check if the binary is on PATH. +# Many gentoo packages don't ship a binary of the same name as the +# package (zsh-completions, zsh-syntax-highlighting install files into +# /usr/share/zsh, not /usr/bin). The simplest "is it installed?" +# check for our purposes is `qlist -I ` — returns 0 if the +# package is in the installed-db, 1 if not. But qlist is from +# gentoolkit and may not be available. Fall back to `equery`. MISSING_PKGS=() for p in "${GENTOO_PKGS[@]}"; do - # Use the package basename as a proxy for "is the binary installed" - bin_name=$(basename "$p") - # Strip the category for the binary lookup (e.g. app-shells/zsh -> zsh) - if ! command -v "$bin_name" >/dev/null 2>&1; then - MISSING_PKGS+=("$p") + if command -v qlist >/dev/null 2>&1; then + if ! qlist -I "$p" >/dev/null 2>&1; then + MISSING_PKGS+=("$p") + fi + elif command -v equery >/dev/null 2>&1; then + if ! equery -q list "$p" 2>/dev/null | grep -q "^$p"; then + MISSING_PKGS+=("$p") + fi + else + # Last resort: try a few common binary names per package + # (most have one matching the basename) + bin_name=$(basename "$p") + if ! command -v "$bin_name" >/dev/null 2>&1; then + MISSING_PKGS+=("$p") + fi fi done