28

I am trying to compile a deb package for my server. When I go to build, everything looks good until it gets to dh_usrlocal The build stops and make returns an error. The problem is I am trying this for the first time and I really don't know where to look for the problem.

This is the output from my terminal, I also included the command I ran at the bottom of the output.

make[2]: Leaving directory `/home/ian/Desktop/scst-2.1.0/src'
make[1]: Leaving directory `/home/ian/Desktop/scst-2.1.0'
   dh_install
   dh_installdocs
   dh_installchangelogs
   dh_installexamples
   dh_installman
   dh_installcatalogs
   dh_installcron
   dh_installdebconf
   dh_installemacsen
   dh_installifupdown
   dh_installinfo
   dh_pysupport
   dh_installinit
   dh_installmenu
   dh_installmime
   dh_installmodules
   dh_installlogcheck
   dh_installlogrotate
   dh_installpam
   dh_installppp
   dh_installudev
   dh_installwm
   dh_installxfonts
   dh_bugfiles
   dh_lintian
   dh_gconf
   dh_icons
   dh_perl
   dh_usrlocal
dh_usrlocal: debian/scst/usr/local/include/scst/scst.h is not a directory
dh_usrlocal: debian/scst/usr/local/include/scst/scst_user.h is not a directory
dh_usrlocal: debian/scst/usr/local/include/scst/Module.symvers is not a directory
dh_usrlocal: debian/scst/usr/local/include/scst/scst_debug.h is not a directory
dh_usrlocal: debian/scst/usr/local/include/scst/scst_const.h is not a directory
dh_usrlocal: debian/scst/usr/local/include/scst/scst_sgv.h is not a directory
rmdir: failed to remove `debian/scst/usr/local/include/scst': Directory not empty
dh_usrlocal: rmdir debian/scst/usr/local/include/scst returned exit code 1
make: *** [binary] Error 1
dpkg-buildpackage: error: debian/rules binary gave error exit status 2
ian@vm01:~/Desktop/scst-2.1.0$ sudo dpkg-buildpackage -rfakeroot

Any help would be appreciated.

AtomicPorkchop
  • 2,625
  • 5
  • 36
  • 55
  • I know why but I don't know how to work around it. According to Debians documentation debs should put files into /bin or /usr/bin and that it should not put a file in /usr/local/ – Joe Coder Oct 12 '11 at 19:45
  • I actually found a way to fix the problem, I modifed the perl script `dh_usrlocal` so the problem did not occur. But in doing so I am not sure if other builds will work. – AtomicPorkchop Oct 13 '11 at 06:00
  • 7
    Modifying `dh_usrlocal` is *absolutely* not the right solution to this, in case anyone else happens by here. The proper solution is for your package not to install files in `/usr/local`, since that area is reserved for use by the local admin. If you insist on using `/usr/local`, then just don't call `dh_usrlocal` in `debian/rules`. – the paul May 07 '12 at 20:08
  • Yeah I realized that after I had done it. By now the developer(s) have integrated the deb package build process into their makefile(s). – AtomicPorkchop Sep 05 '12 at 17:17
  • I started getting this error after adding a `package.install` file into the `debian` folder. – NuclearPeon Sep 13 '13 at 18:02
  • @thepaul is correct. Modifying `dh_usrlocal` is just a workaround hack, not the solution. Normally when you install something from source it uses `/usr/local`. You can modify this behavior by adding a `prefix` when you `./configure` the package. – Kalpa Gunarathna Nov 13 '17 at 05:31

3 Answers3

34

you should skip running dh_usrlocal. to do it you just add this to debian/rules file: override_dh_usrlocal:

In general manner if you have a problem with a specific target, you just override it by adding override_{target} in your debian/rules file.
example, you have a problem with dh_icons. you just add this in your debian/rules file.

override_dh_icons:
    {insert your processing commands or do nothing to skip it when building package}
elhadi dp ıpɐɥןǝ
  • 4,763
  • 2
  • 30
  • 34
  • 1
    dh_usrlocal does some fudging with all paths that relate to /usr/local. See here: http://man.he.net/man1/dh_usrlocal. My answer only worked when I had both usr/ folders specified in my `.install` file, but that meant my package was installed into `/usr/usr/local/...` and failed. – NuclearPeon Sep 13 '13 at 19:20
5

A proper Debian package is not allowed to generate stuff there but empty directories.That is why it is complaining that it can not delete the directory. It doesnt expect files to be there.the only thing you can have is a directory in /usr/local and that's what dh_usrlocal tries to handle but you shouldn't have files

Users only put files in /usr/local/.

Also i think if you have usr/local name in your directory path it will cause the error also like even though it is not the correct usr/local. An example of what could cause the problem also. I think the regex in build software looks for usr/local.

/var/tmp/usr/local/

I know this is an old post but it is ranked #1 on google so needs a good answer so people solve this problem quickly.

Martin Naughton
  • 1,476
  • 17
  • 14
  • Most third-party software installs itself in the / usr / local directory. In Debian, it is reserved for private use by the system administrator, so packages should not use directories such as / usr / local / bin, but rather use system directories such as / usr / bin in accordance with File hierarchy standard (FHS). – elhadi dp ıpɐɥןǝ Nov 14 '16 at 11:04
3

IMPORTANT: This error ONLY occurs when you try to install to /usr/local/

I moved my package to install from /usr/local/lib/python3/dist-packages/ to /usr/lib/python3/dist-packages and the error disappeared. dh_usrlocal seems to be broken or my package is not abiding by rules it expects.


I started getting the error after adding a package.install file to my debian package so it would copy the package contents to the filesystem. (I was installing to /usr/local/ at the time)

Contents of my install file when it failed:

usr/* usr/

Contents when it works correctly:

usr/ usr/

File structure of debian package:

packagename-0.1/
  debian/
  usr/
    local/
      lib/
        python3/
          packagename/

Edit: This seems only to work when copying root directories. Once I try to specify copying past usr/, it breaks with the same error. See top of answer to find my solution.

NuclearPeon
  • 5,743
  • 4
  • 44
  • 52
  • 3
    you shouldn't do that as your package is not a standard package. user software's should go into /usr/local/.... – elhadi dp ıpɐɥןǝ Sep 14 '13 at 09:01
  • 2
    I completely agree with you. However, the build breaks whenever I specify that path. I am uncertain of what is required to make /usr/local/ work and am just stating what is error-free and solves my problem. It's good that you point this out, but I spent hours just getting to this point. I may file a bug with Debian or sift through their forums/mailing lists later. – NuclearPeon Sep 16 '13 at 21:00