Created
January 30, 2015 17:45
-
-
Save idlemoor/6cfeffc883deff091065 to your computer and use it in GitHub Desktop.
Script to count the number of direct and indirect dependers for each item in the SlackBuilds.org repository. Optional deps are not counted (obviously).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Count the number of direct and indirect dependers for each item in the SBo repo | |
# | |
declare -a pkglist deplist | |
declare -A req votes | |
function list_deps_of | |
{ | |
local pkg=$1 | |
local dep | |
for dep in ${req[$pkg]}; do | |
[ "$dep" = '%README%' ] && continue | |
newdep='y' | |
for olddep in "${deplist[@]}"; do | |
if [ "$olddep" = "$dep" ]; then | |
newdep='n' | |
break | |
fi | |
done | |
if [ "$newdep" = 'y' ]; then | |
deplist+=( "$dep" ) | |
list_deps_of "$dep" | |
fi | |
done | |
return 0 | |
} | |
pkglist=() | |
for pkgdir in */*; do | |
pkgnam=${pkgdir##*/} | |
. "${pkgdir}/${pkgnam}.info" | |
if [ -n "$REQUIRES" ]; then | |
req[$pkgnam]="$REQUIRES" | |
pkglist+=($pkgnam) | |
fi | |
done | |
for pkgnam in "${pkglist[@]}"; do | |
deplist=() | |
list_deps_of $pkgnam | |
for dep in "${deplist[@]}"; do | |
votes[$dep]=$(( ${votes[$dep]:-0} + 1 )) | |
done | |
done | |
for pkgnam in "${!votes[@]}"; do | |
echo "${votes[$pkgnam]}" "$pkgnam" | |
done | sort -n -r | nl | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment