Last active
March 14, 2019 05:33
-
-
Save d630/1855b2dae2b31828c825197300625d5d to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
declare -A Pack | |
function callback { | |
Pack[$2]= | |
} | |
mapfile -t -c 1 -C callback < "${1?error: file missing}" | |
suite=${2?error: chroot of suite missing} | |
for i in "${MAPFILE[@]}" | |
do | |
arr=($( | |
sudo apt-rdepends \ | |
-r \ | |
-o Dir::Cache="$suite"/var/cache/apt \ | |
-o Dir::State="$suite"/var/lib/apt "$i" 2>/dev/null | | |
grep -o -e '^[^ ]*' | |
) | |
) | |
unset -v arr[0] | |
is_dep=false | |
for j in "${arr[@]}" | |
do | |
[[ -v Pack[$j] ]] && is_dep=true && break | |
done | |
$is_dep || keep+=("$i") | |
done | |
printf '%s\n' "${keep[@]}" | |
# vim: set ft=sh |
Author
d630
commented
Mar 14, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment