summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2020-05-12 06:05:33 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2021-01-05 22:24:56 -0500
commit51f7a5a6943d209c919237daf653b1ae57310957 (patch)
tree2c687ac5c34d163c197174b9609d6c352b0d9bfb
parent18c0189a926068363c27b5607fd73cdb16354de3 (diff)
[parabola-dependents]: initial script
-rwxr-xr-xsrc/maintenance-tools/parabola-dependents43
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