I have created a package of zsh 5.0.7 from sources and now I can install it successfully but when I try to remove it I get this:

$ sudo dpkg -i zsh_5.0.7_amd64.deb
Selecting previously unselected package zsh.
(Reading database ... 177638 files and directories currently installed.)
Preparing to unpack zsh_5.0.7_amd64.deb ...
Unpacking zsh (5.0.7) ...
Setting up zsh (5.0.7) ...
Processing triggers for man-db ( ...
Reading package lists...
Building dependency tree...
$ sudo apt-get purge zsh
Reading state information...
The following packages will be REMOVED:
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 6473 kB disk space will be freed.
Do you want to continue? [Y/n] (Reading database ... 178746 files and directories currently installed.)
Removing zsh (5.0.7) ...
dpkg: warning: while removing zsh, directory '/usr/local/bin' not empty so not removed
dpkg: warning: while removing zsh, directory '/usr/local/lib' not empty so not removed
dpkg: warning: while removing zsh, directory '/usr/local/share/man/man1' not empty so not removed
Processing triggers for man-db ( ...

What can I change in packaging (debian/{control,rules} or other files) to make that warning go away ?


Source: zsh
Section: unknown
Priority: optional
Maintainer: Patryk <[email protected]>
Build-Depends: debhelper (>= 8.0.0), autotools-dev
Standards-Version: 3.9.4
Homepage: http://zsh.sourceforge.net/

Package: zsh
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, libc6
Description: ZSH shell
 Zsh is a shell designed for interactive use, although it is also a powerful scripting language. Many of the useful features of bash, ksh, and tcsh were incorporated into zsh; many original features were added.


#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

        dh $@  --with autotools-dev


I have forked zsh sources and added debian directory for packaging:


  • Presumably, you are telling your package to create /usr/bin so it then tries to remove when you reinstall. We can't tell you what to change in debian/{control,rules} if you don't show us what you have at the moment, but check what you're doing to /usr/bin.
    – terdon
    Oct 26, 2014 at 14:53
  • @terdon I've added debian/control and debian/rules files, anything more that might be helpful?
    – Patryk
    Oct 26, 2014 at 14:56
  • Hmm, they don't seem to be relevant, sorry. I don't really know the first thing about .deb packaging but presumably, there is a file that lists the directories & files that should be created by the package. I thought they might be those two files only because you mentioned them. I am guessing that you need to show whichever file defines these directories since, presumably, one of them lists /usr/bin. Try running grep -wR "/user/bin" /path/to/package/build/dir.
    – terdon
    Oct 26, 2014 at 15:18
  • @terdon output: paste.ubuntu.com/8689535
    – Patryk
    Oct 26, 2014 at 15:22
  • 1
    I notice you have override_dh_usrlocal: but nothing under it. Did you paste the entire rules file? Oct 26, 2014 at 16:14

1 Answer 1


In general, this warning is completely harmless and normal. When dpkg is removing (or trying to remove) a package, it removes all files and directories which were created as part of that package installation. Now, suppose there are some files in a directory that is a candidate for removal in such a scenario, and dpkg doesn't know about these files. This could happen either because they were machine generated, either during or after the install, or because they were created by a user. Then, unless instructed, dpkg will not remove those files. Since, by default, it will not remove a non-empty directory, in such a case, the directory containing these files will not be removed. So, in summary, after the package is removed, you may end up with a basically empty directory (or directories) with a few machine generated files or something. This is not a problem - you can just remove these manually.

Note, the defaults above are all sensible defaults. There are no bugs here.

In your case, you are installing files to /usr/local as part of your Debian binary package, which is a violation of the File Hierarchy Standard, and is wrong. Don't do this. User binaries should go into /usr/bin, for example, libraries should go into /usr/lib, etc. I assume your package creates /usr/local/bin, because dpkg, naturally, does not know about it already. (Since a Debian package containing files/directories in /usr/local is a violation of the FHS and therefore Debian Policy). Therefore it tries to remove that file when it removes the package. Stop installing in /usr/local, and your problem will go away.

Give us a little more context, perhaps? Why are you trying to build your own zsh Debian package rather than using the one your distribution ships, and what distribution are you using anyway?

If you really want to do this, here is a simple tip. Check how your distribution (or even Debian) packages zsh, and just reuse the packaging. It should work fine. There is no reason to try writing your own, unless you are trying to learn how to package, which I assume is not the case here.

  • Actually I am trying to learn how to package :) I can't find a guide that will tell me where are "files installed with a package" defined.
    – Patryk
    Oct 27, 2014 at 1:26
  • man dh_install. debian/package.install are the files normally used. Oct 27, 2014 at 2:08
  • Regarding the violation of FHS, from Wiki: "Most of the time /usr/local/ is used for installing software/data that are not part of the standard operating system distribution" - so why is this bad to install software in /usr/local/?
    – Patryk
    Oct 27, 2014 at 14:51
  • @Patryk Good question. By definition, a deb package is part of the operating system distribution. Source that is installed from source, e.g. with the classic autotools mantra ./configure, make, make install typically goes into /usr/local. Deb binary packages never do. Oct 27, 2014 at 14:57
  • So what you say is that is should go to /usr/{bin,lib,man,share}? This still does not solve my problem because I don't know how to define the installation dir nor I do I have package.install file created by dh_make (I have tried looking for it in zsh Ubuntu packaging on launchpad but they don't use it either)
    – Patryk
    Oct 27, 2014 at 15:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .