Skip to content

Get package sizes on Debian-based distros

License

Notifications You must be signed in to change notification settings

slavos1/pkg-info.old

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package size as reported by dpkg

This repo has been archived, see pkg-info instead.

I wanted to see packages that took most space on my Debian. Hence this simple script. It essentially runs:

for each package P returned from "dpkg -L" run
    for each file that is not a symlink from "dpkg -l $P" run
        get the file size
    sum the file sizes as a size of the package

dpkg -l invocations are run in parallel (currently hard-coded to 10 threads) so it should be reasonably fast.

Usage

Clone the repo locally, then run once:

python -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install loguru==0.7.0

To gather each installed package’s files' sizes into info.txt file, run:

sudo ./pkg-info > info.txt

# or if you do not mind some files/folders not being read due to insufficient permissions
./pkg-info > info.txt
Note
If you used a different name for your venv than .venv (say, myenv), you would need to update the wrapper script (pkg-info) or pass the name via the environment variable VENV, for example: VENV=myenv ./pkg-info.

Resulting info.txt file looks similar to this:

0.66 MiB        adduser         3.118           add and remove users and groups
2.19 MiB        apparmor        2.13.6-10       user-space parser utility for AppArmor
0.23 MiB        apt-listchanges 3.24            package change history notification tool
... snip ...
4172.98 MiB     total # (1)
  1. 'total' is always the last line

Tip

To help you choose which package to uninstall based on its size, you may want to use fzf with info.txt file like this:

sudo apt remove $(sort -nr info.txt | fzf | awk '{print $3}')

Todo

  • ❏ add command line parameters for:

    • filtering package names

    • debug/quiet logging

    • number of threads (currently hard-coded to 10)