Forward Dependencies (Use to identify large libraries you don't need)
Code: Select all
for z in $(dpkg -l | awk '/^[hi]i/{print $2}' | grep -E '^lib'); do \
printf "\n$z:" && \
aptitude show $z | grep -E 'Uncompressed Size' && \
printf "\n" && \
apt show 2>/dev/null $(aptitude search '!~i?reverse-depends("^'$z'$")' -F "%p" | \
sed 's/:i386$//') | grep -E 'Package|Installed-Size' | sed '/APT/d;s/^.*Package:/\t&/;N;s/\n/ /' &>> DistroAnalysis.txt; done
Code: Select all
for z in $(dpkg -l | awk '/^[hi]i/{print $2}' | grep -v '^lib'); do \
pkg_size=$(apt show 2>/dev/null $z| grep -E 'Installed-Size:' | sed "s/Installed-Size://;s/ kB/K/g;s/ mB/M/g")
let desc_resize=207-${#z}
description=$(apt show 2>/dev/null $z | grep -A3 -E 'Description' | sed "s/Description://;:a;N;$!ba;s/\n/ /g" | tr -d '\n' | colrm $desc_resize )
package=$(printf "\n$z$pkg_size D: $description\n")
rdependslist=$(apt-rdepends 2>/dev/null $z | grep -v "Depends" | sed -e "s/$z//g")
rdepends=$(apt show 2>/dev/null $rdependslist | grep -E "Package:|Installed-Size" | sed -e "s/Package: //g;/APT/d;s/Installed-Size: //;s/ kB/K/g;s/ MB/M/g")
echo $package &>> DistroAnalysis.txt
if [[ (${#rdepends} -le 700) ]]; then echo $rdepends &>> DistroAnalysis.txt; else :; fi
printf "\n" &>> DistroAnalysis.txt; done
That last script took a lot of work. Let me interpret for you starting from the for loop. Input list of all packages, exclude some useless text, exclude libraries. Print a new line and the package name. Count the characters in the package name. To fit the description on two lines in geany with monospace regular 8 font, the maximum characters over two lines is 206, but the program colrm you need to add + 1 for some reason. Apt show without error, grep the package size and format it nicely and store into variable package_size. Now grab the description without error and put into one continuous stream of characters, then cut to resize with colrm; store into variable description. N.B. the -A3 means the first 3 lines of description, which is why the description is in a separate function then the former; because you can't grep -e 'x' -A3 -e 'x' that is illegal and if you A3 both that opens up another can of worms. Now print variables package_size and description. Get rdepends list and store it into result. Look the name and size of each rdepends stored in result, and store this in final. If rdpends is not ridiculously long i.e., whole OS, then and only then output it; name and size, otherwise just output main package, size and description. &>> Output without fail; freaking work.