From 591843d65b12e339a2549afdd6b83702cf00c2e3 Mon Sep 17 00:00:00 2001 From: bill-auger Date: Tue, 12 May 2020 06:05:33 -0400 Subject: [parabola-dependents]: initial script --- src/maintenance-tools/parabola-dependents | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 src/maintenance-tools/parabola-dependents 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 ] + + 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 -- cgit v1.2.2