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>2023-12-14 17:00:28 -0500
commit10f76e3335dfda4298f0ce701183ff4d10f156a4 (patch)
tree133f4ce2517db5b23bde877c31b942a662063925
parentaf67f013e03215c3d8a9a977d90b9750882e38a3 (diff)
[parabola-dependents]: initial script
-rwxr-xr-xparabola-dependents43
1 files changed, 43 insertions, 0 deletions
diff --git a/parabola-dependents b/parabola-dependents
new file mode 100755
index 0000000..8947dbf
--- /dev/null
+++ b/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