Skip to content

Instantly share code, notes, and snippets.

@shundhammer
Last active May 11, 2019 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shundhammer/0c1d097922950ddfe29d2a347f9ce0e4 to your computer and use it in GitHub Desktop.
Save shundhammer/0c1d097922950ddfe29d2a347f9ce0e4 to your computer and use it in GitHub Desktop.
Pkg View for QDirStat

Pkg View for QDirStat

Idea

New view to display information about installed packages from the package manager. Very much like the normal tree view and treemap, but the top level would be packages.

foo.deb
  usr
    bin
      foo
    share
      lib
        foo
          foo-list.dat
          foo-users.dat
bar_i386.deb
  usr
    lib32
      libbar.so.42
      libbar.so.42.1.0
bar_amd64.deb
  usr
    lib
      libbar.so.42
      libbar.so.42.1.0

Implementation

class PkgInfo: public DirInfo
class PkgReadJob: public DirReadJob
  • Get a list of all installed packages from the system's package manager
  • Iterate over all those packages: For each one
    • Put it into a DirTree
    • Get a file list for that package; for each entry
      • create the directory nodes under the package node
        • lstat() for the entry
        • create a FileInfo for the entry

Dpkg Commands

Get a list of all installed packages

dpkg -l

(Poor formatting)

Better:

dpkg-query --show --showformat='${Package}\n'
dpkg-query --show --showformat='${Package} ${Architecture} ${Version}\n'

Get the file list for a package

dpkg -L <pkg-name>
dpkg --listfiles <pkg-name>

Rpm Commands

Get a list of installed packages

rpm -qa --queryformat ...

Get the file list for a package

rpm -ql <pkg-name>

Other Commands

Get current architecture

uname -m

(Supported on Ubuntu, SUSE, BSD)

@shundhammer
Copy link
Author

Faster file lists for RPM:

rpm -qal --queryformat '\nPkg:/%{name} %{version}-%{release} %{arch}\n\n'

Pkg:/libproxy1-32bit 0.4.15-5.2 x86_64

/usr/lib/libproxy.so.1
/usr/lib/libproxy.so.1.0.0

Pkg:/libmtp-udev 1.1.16-2.2 x86_64

/usr/lib/udev
/usr/lib/udev/hwdb.d
/usr/lib/udev/hwdb.d/69-libmtp.hwdb
/usr/lib/udev/mtp-probe
/usr/lib/udev/rules.d
/usr/lib/udev/rules.d/69-libmtp.rules

@shundhammer
Copy link
Author

Maybe even

rpm -qalv --queryformat '\nPkg:/%{name} %{version}-%{release} %{arch}\n\n'
Pkg:/libproxy1-32bit 0.4.15-5.2 x86_64

lrwxrwxrwx    1 root    root                       17 Jan 30 05:36 /usr/lib/libproxy.so.1 -> libproxy.so.1.0.0
-rwxr-xr-x    1 root    root                   133292 Jan 30 05:36 /usr/lib/libproxy.so.1.0.0

Pkg:/libmtp-udev 1.1.16-2.2 x86_64

drwxr-xr-x    2 root    root                        0 Jan 30 05:29 /usr/lib/udev
drwxr-xr-x    2 root    root                        0 Jan 30 05:29 /usr/lib/udev/hwdb.d
-rw-r--r--    1 root    root                    98408 Jan 30 05:29 /usr/lib/udev/hwdb.d/69-libmtp.hwdb
-rwxr-xr-x    1 root    root                    14648 Jan 30 05:29 /usr/lib/udev/mtp-probe
drwxr-xr-x    2 root    root                        0 Jan 30 05:29 /usr/lib/udev/rules.d
-rw-r--r--    1 root    root                   183864 Jan 30 05:29 /usr/lib/udev/rules.d/69-libmtp.rules

@shundhammer
Copy link
Author

 rpm -qa --qf '[%{=NAME} | %{FILENAMES} \n]'

@shundhammer
Copy link
Author

Faster file lists for dpkg:

dpkg -S "*"

@shundhammer
Copy link
Author

shundhammer commented May 11, 2019

rpm -qa --qf '[%{=NAME}-%{=VERSION}-%{=RELEASE}.%{=ARCH} | %{FILENAMES} \n]'
kernel-default-4.12.14-lp151.26.4.x86_64 | /boot/.vmlinuz-4.12.14-lp151.26-default.hmac 
kernel-default-4.12.14-lp151.26.4.x86_64 | /boot/System.map-4.12.14-lp151.26-default 
kernel-default-4.12.14-lp151.26.4.x86_64 | /boot/config-4.12.14-lp151.26-default 
kernel-default-4.12.14-lp151.26.4.x86_64 | /boot/initrd 
kernel-default-4.12.14-lp151.26.4.x86_64 | /boot/initrd-4.12.14-lp151.26-default 
kernel-default-4.12.14-lp151.26.4.x86_64 | /boot/initrd-4.12.14-lp151.26-default-kdump 
kernel-default-4.12.14-lp151.26.4.x86_64 | /boot/symvers-4.12.14-lp151.26-default.gz 
kernel-default-4.12.14-lp151.26.4.x86_64 | /boot/sysctl.conf-4.12.14-lp151.26-default 
kernel-default-4.12.14-lp151.26.4.x86_64 | /boot/vmlinux-4.12.14-lp151.26-default 
kernel-default-4.12.14-lp151.26.4.x86_64 | /boot/vmlinux-4.12.14-lp151.26-default.gz 

...

zsh-5.6-lp151.1.3.x86_64 | /bin/zsh 
zsh-5.6-lp151.1.3.x86_64 | /etc/zprofile 
zsh-5.6-lp151.1.3.x86_64 | /etc/zsh_completion.d 
zsh-5.6-lp151.1.3.x86_64 | /etc/zshenv 
zsh-5.6-lp151.1.3.x86_64 | /etc/zshrc 
zsh-5.6-lp151.1.3.x86_64 | /usr/bin/zsh 
zsh-5.6-lp151.1.3.x86_64 | /usr/lib64/zsh 
zsh-5.6-lp151.1.3.x86_64 | /usr/lib64/zsh/5.6 
zsh-5.6-lp151.1.3.x86_64 | /usr/lib64/zsh/5.6/zsh 
zsh-5.6-lp151.1.3.x86_64 | /usr/lib64/zsh/5.6/zsh/attr.so 
zsh-5.6-lp151.1.3.x86_64 | /usr/lib64/zsh/5.6/zsh/cap.so 
zsh-5.6-lp151.1.3.x86_64 | /usr/lib64/zsh/5.6/zsh/clone.so 
zsh-5.6-lp151.1.3.x86_64 | /usr/lib64/zsh/5.6/zsh/compctl.so 
zsh-5.6-lp151.1.3.x86_64 | /usr/lib64/zsh/5.6/zsh/complete.so 
zsh-5.6-lp151.1.3.x86_64 | /usr/lib64/zsh/5.6/zsh/complist.so 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment