diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2020-05-12 06:05:33 -0400 |
---|---|---|
committer | Andreas Grapentin <andreas@grapentin.org> | 2022-01-18 17:31:54 +0100 |
commit | 591843d65b12e339a2549afdd6b83702cf00c2e3 (patch) | |
tree | d499a5882bb7238e6472aff0f565a0c99914b97c | |
parent | dd95775f226aa85d72271b154d46e1d040d66bd0 (diff) |
[parabola-dependents]: initial script
-rwxr-xr-x | src/maintenance-tools/parabola-dependents | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/maintenance-tools/parabola-dependents b/src/maintenance-tools/parabola-dependents new file mode 100755 index 0000000..8947dbf --- /dev/null +++ b/src/maintenance-tools/parabola-dependents @@ -0,0 +1,43 @@ +#!/bin/bash + + +IsArchRepo() +{ + local repo=$1 ; [[ "$repo" =~ ^(community|core|extra|multilib|testing)$ ]] +} + +ListParabolaDependents() +{ + readonly BE_VERBOSE=$( [[ "$1" == '-v' ]] && echo 1 || echo 0 ) ; (( $BE_VERBOSE )) && shift ; + readonly DEP_PKG=$1 + readonly CFG_FILE=/etc/pacman-all.conf + readonly CFG="--config=$CFG_FILE" + read -r -d '' USAGE <<-'USAGE_MSG' +USAGE: + parabola-dependents [ -v ] <PACKAGE_NAME> + + list all parabola packages which are dependents of a specified package + by default, only first-order dependents are listed, with counts of higher-order dependents + verbose mode (-v) will itemize all higher-order dependents +USAGE_MSG + + + [[ -z "$DEP_PKG" ]] && echo -e "no dependency package specified\n\n$USAGE" && return 1 + [[ ! -f "$CFG_FILE" ]] && echo "can not find pacman config: $CFG_FILE" && return 1 + + sudo pacman $CFG -Sy ; echo -e "\nsearching ...\n\n" ; + + local dependency_chain pkg repos repo + while read dependency_chain + do pkg=$(sed 's|.*<- ||' <<<$dependency_chain) + repos=$(pacman $CFG -Si $pkg | grep Repository | cut -d ':' -f 2) + for repo in $repos + do IsArchRepo $repo && echo "$repo skip $pkg" && continue + + echo "$repo/$pkg $( (( $BE_VERBOSE )) && echo "[ $dependency_chain ]" )" + done + done < <(/usr/bin/pactree $CFG --sync --reverse --unique --chain $DEP_PKG) | sort +} + + +ListParabolaDependents $@ || exit 1 |