git.lirion.de

Of git, get, and gud

aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authormail_redacted_for_web 2021-10-03 15:12:22 +0200
committermail_redacted_for_web 2021-10-03 15:12:22 +0200
commit29550c62bcd527c6ae1a74e3534db51b1e5deec7 (patch)
tree42dc0b84a1075c24aae8fe8f628e1a4d6f2c298c /bin
parent5d7320202acfcef26e7d5a7742a039fd1789a62a (diff)
downloaddebian-scripts-29550c62bcd527c6ae1a74e3534db51b1e5deec7.tar.bz2
+aptitude "replacement"HEADmaster
Diffstat (limited to 'bin')
-rwxr-xr-xbin/aptitude67
1 files changed, 67 insertions, 0 deletions
diff --git a/bin/aptitude b/bin/aptitude
new file mode 100755
index 0000000..54cd585
--- /dev/null
+++ b/bin/aptitude
@@ -0,0 +1,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