Why is dh_usrlocal throwing a build error?

12,068

Solution 1

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}

Solution 2

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.

Solution 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.

Share:
12,068
ianc1215
Author by

ianc1215

Updated on July 25, 2022

Comments

  • ianc1215
    ianc1215 almost 2 years

    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.