Gentoo user-packages: use qlist for missing-detect (handles non-binary pkgs)
The previous missing-detect used 'command -v <basename>' 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.
This commit is contained in:
parent
1d88429b14
commit
94d3c0ebaf
1 changed files with 21 additions and 7 deletions
|
|
@ -88,16 +88,30 @@ 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 <pkg>` — 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"
|
||||
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")
|
||||
# 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")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Step 4: Install
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue