blob: 54cd585dfbd4e58173e3b1aebfe00adce28b645a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#!/usr/bin/env bash
# vim:ts=4
# This is just a replacement - for quite a while, while already abandoning aptitude, I still kept
# aptitude installed just for typing "aptitude why $package". This script just does this.
# Converting because we need ${ARGARR[*]}
ARGARR=( "$@" )
MYERR="\\033[1;31mE:\\033[0m"
function myhelp {
printf "USAGE: %b ( why PACKAGE [PACKAGE ..] | help )\\n\\n" "$(basename "$0")"
(
printf "why:;Lists the recursive depends of a package, i.e. why it is installed.\\n"
printf " ;Wrapper to 'apt[-cache] rdepends --installed PACKAGE'\\n"
printf "help:;This help"
)|column -ts\;
printf "\\n"
}
if [ -z "$1" ];then
printf "%b No parameter supplied.\\n" "$MYERR" >&2
exit 10
fi
case "$1" in
help|"-h"|"--help")
myhelp
exit 0
;;
why)
if [ -z "$2" ];then
printf "%b No package name(s) supplied.\\n" "$MYERR" >&2
exit 12
fi
for i in "${@:2}";do
IFS=$'\n'
# shellcheck disable=SC2207
WHYARR=( $(apt rdepends --installed "$i" 2>/dev/null) )
if [ "$?" -ne 0 ];then
apt rdepends --installed "$i" >/dev/null
exit 2
fi
unset IFS
WHYDEPS="$(printf "%b\\n" "${WHYARR[@]}"|grep -P "^[\ \t]*Depends:")"
WHYBREAKS="$(printf "%b\\n" "${WHYARR[@]}"|grep -P "^[\ \t]*Breaks:")"
#WHYARCHS="$(printf "%b\\n" "${WHYARR[@]}"|grep -P "^[\ \t]*$i:")"
printf "%b\\n" "$i"
for (( j=0;j<${#i};++j ));do printf "=";done;printf "\\n"
printf "Installed packages with dependencies:\\n"
if [ -n "$WHYDEPS" ];then
printf "%b\\n" "$WHYDEPS"
else
printf " NO INSTALLED DEPENDENCIES\\n"
fi
if [ -n "$WHYBREAKS" ];then
printf "Supplemental information:\\n"
printf "%b\\n" "$WHYBREAKS"
fi
printf "\\n"
done
;;
*)
printf "%b Arguments not understood: %b\\n" "$MYERR" "${ARGARR[*]}" >&2
exit 11
;;
esac
|