Dpkg: warning: while removing directory /usr/local not empty so not removed


I built and installed a debian package from the following folder structure:

  • myprog
    • DEBIAN
      • control
    • usr
      • local
        • bin
          • myprog.sh

… using the following commands:

dpkg -b myprog/ myprog.deb && dpkg -i myprog.deb

When i now remove the package by typing:

dpkg -r myprog

.. I got the following warning:

dpkg: warning: while removing myprog, directory '/usr/local' not empty so not removed.

As I think this is an every day scenario, how can I avoid the warning?

Greets Thorsten!

# Edit

I tried to install the file to /bin instead of /usr/local/bin and got no warning when removing it. Seems so, that the /usr/local/.. folder will not treated as a system folder (?) by dpkg.

Best Solution

That's right -- packages should never touch /usr/local directory, it's reserved for system administrators by Filesystem Hierarchy Standard and is their zone of responsibility.

Related Question