Search code examples
linuxbashubuntudpkg

How does dpkg -L package_name works?


I am curious about how exactly dpkg -L package_name works.

Here is what man says:

         -L, --listfiles package-name...
              List files installed to your system from package-name.

Here is the output of a dpkg -L bash executed as root :

/.
/usr
/usr/share
/usr/share/info
/usr/share/menu
/usr/share/menu/bash
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/bash
/usr/share/man
/usr/share/man/man7
/usr/share/man/man7/bash-builtins.7.gz
/usr/share/man/man1
/usr/share/man/man1/bash.1.gz
/usr/share/man/man1/rbash.1.gz
/usr/share/man/man1/clear_console.1.gz
/usr/share/man/man1/bashbug.1.gz
/usr/share/doc
/usr/share/doc/bash
/usr/share/doc/bash/RBASH
/usr/share/doc/bash/changelog.Debian.gz
/usr/share/doc/bash/copyright
/usr/share/doc/bash/README.abs-guide
/usr/share/doc/bash/POSIX.gz
/usr/share/doc/bash/inputrc.arrows
/usr/share/doc/bash/INTRO.gz
/usr/share/doc/bash/README.Debian.gz
/usr/share/doc/bash/NEWS.gz
/usr/share/doc/bash/COMPAT.gz
/usr/share/doc/bash/README.commands.gz
/usr/share/doc/bash/README
/usr/bin
/usr/bin/clear_console
/usr/bin/bashbug
/etc
/etc/skel
/etc/skel/.bashrc
/etc/skel/.bash_logout
/etc/skel/.profile
/etc/bash.bashrc
/bin
/bin/bash
/bin/rbash

How does dpkg know that ? Why isn’t (for example) /root/.bashrc included ?


Solution

  • The contents of installed Debian packages are stored in plain text files at /var/lib/dpkg/info/PACKAGENAME.list.

    For instance:

    sh# cat /var/lib/dpkg/info/bash.list
    /.
    /etc
    /etc/bash.bashrc
    /etc/skel
    /etc/skel/.profile
    /etc/skel/.bash_logout
    /etc/skel/.bashrc
    /bin
    /bin/bash
    /usr
    …
    

    /root/.bashrc is not included because it is not a part of the bash package. It is copied from /etc/skel/.bashrc when the user is created, but is not overwritten if the bash package is updated, nor is it deleted if the package is uninstalled.