| 1 |
#!/bin/bash |
| 2 |
# convenience script to show information about debian |
| 3 |
# packages in a nice, colourful, human-readable way |
| 4 |
|
| 5 |
{ type dpkg-query && type apt-cache; } >/dev/null || { echo "This mechanism needs dpkg and apt. Are you even on Debian?"; exit 1; } |
| 6 |
{ type ccze && type sed && type du && type less; } >/dev/null || { echo "This mechanism needs ccze, sed, coreutils and less."; exit 1; } |
| 7 |
|
| 8 |
dpkg-info() |
| 9 |
{ |
| 10 |
for pkg in ${@}; |
| 11 |
do |
| 12 |
{ |
| 13 |
{ |
| 14 |
apt-cache policy ${pkg} 2>&1 && echo |
| 15 |
dpkg-query -s ${pkg} 2>/dev/null && echo |
| 16 |
} | ccze -A -o nolookups && { |
| 17 |
IFS=${IFS/ /} |
| 18 |
list=($(dpkg -L ${pkg} 3>/dev/null | sed "s|^[^/]*||"|tail --lines=+2)) && |
| 19 |
[ ${#list[*]} -gt 0 ] && |
| 20 |
for item in ${list[@]}; |
| 21 |
do |
| 22 |
{ |
| 23 |
[ -L "${item}" ] && [ ! -d $(realpath "${item}" 2>/dev/null) ] && |
| 24 |
links=("${links[@]}" "${item}") || |
| 25 |
[ -f "${item}" ] && |
| 26 |
files=("${files[@]}" "${item}") || |
| 27 |
dirs=("${dirs[@]}" "${item}") |
| 28 |
} |
| 29 |
done |
| 30 |
[ ${#files[@]} -gt 0 ] && |
| 31 |
echo -ne "package ${pkg} contains:\t " && |
| 32 |
{ echo -n "$(LANG=C du -hc ${files[@]} | sed -nr "s/(.*)\s+total/\1iB/p") in ${#files[@]} $(ngettext 'file' 'files' ${#files[@]})" && |
| 33 |
{ [ ${#links[@]} -eq 0 ] || echo -n " and ${#links[@]} $(ngettext 'symbolic link' 'symbolic links' ${#links[@]})"; } && |
| 34 |
echo " within ${#dirs[@]} $(ngettext 'directory' 'directories' ${#dirs[@]})"; } | ccze -A -o nolookups && echo && |
| 35 |
ls --color=always -lahd --time-style=+" %^a %F %R" "${list[@]}" |
| 36 |
debsums -s ${pkg} |
| 37 |
} 2>&1 |
| 38 |
echo |
| 39 |
{ |
| 40 |
apt-cache show ${pkg} |
| 41 |
apt-cache showsrc ${pkg} |
| 42 |
} | ccze -A -o nolookups |
| 43 |
} | less -SRiM~ --shift 1 -PM"debian package info\: ${pkg}, ?ltlines %lt-%lb?L/%L.:byte %bB?s/%s. .?e(END)" |
| 44 |
done |
| 45 |
} |
| 46 |
|
| 47 |
dpkg-info ${@} |