0

I am trying to run debuild command to work with debian with my project However, when I run debuild command I get such error:

hoseopjeong@hoseopjeong-VirtualBox:~/Documents/HoseopJeong_debian_lab9/debianlaboration9-0.0$ debuild
dpkg-buildpackage -rfakeroot -D -us -uc
dpkg-buildpackage: source package debianlaboration9
dpkg-buildpackage: source version 0.0-1
dpkg-buildpackage: source distribution UNRELEASED
dpkg-buildpackage: source changed by Ho Seop Jeong <my email>
dpkg-source --before-build debianlaboration9-0.0
dpkg-buildpackage: host architecture i386
fakeroot debian/rules clean
dh clean  
 dh_testdir
 dh_auto_clean
  make -j1 distclean
 make[1]: Entering directory '/home/hoseopjeong/Documents/HoseopJeong_debian_lab9/debianlaboration9-0.0'
rm -f electrotest
make[1]: Leaving directory '/home/hoseopjeong/Documents/HoseopJeong_debian_lab9/debianlaboration9-0.0'
dh_clean
rm -f debian/debhelper-build-stamp
rm -f debian/debianlaboration9.substvars
rm -f debian/debianlaboration9.*.debhelper
rm -rf debian/debianlaboration9/
rm: cannot remove 'debian/debianlaboration9/usr/electrotest_standalone': Permission denied
 dh_clean: rm -rf debian/debianlaboration9/ returned exit code 1
 debian/rules:9: recipe for target 'clean' failed
 make: *** [clean] Error 25
 dpkg-buildpackage: error: fakeroot debian/rules clean gave error exit status 2
 debuild: fatal error at line 1376:
 dpkg-buildpackage -rfakeroot -D -us -uc failed

this is how my makefile look like:

prefix = /usr/local
all: electrotest


electrotest: ./src/electrotest_standalone.c
   gcc -o electrotest_standalone ./src/electrotest_standalone.c -lm
install:electrotest
   install -D electrotest_standalone \
$(DESTDIR)$(prefix)/bin/electrotest_standalone
clean:
   -rm -f electrotest

distclean:clean
uninstall:
    -rm -f $(DESTDIR)$(prefix)/bin/electrotest_standalone

PHONY: all install clean distclean uninstall

this is my debian rules file

#!/usr/bin/make -f
# You must remove unused comment lines for the released package.
export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
    dh $@  

#override_dh_auto_install:
#   dh_auto_install -- prefix=/usr

#override_dh_install:
#   dh_install --list-missing -X.pyc -X.pyo
override_dh_auto_install:
    dh_auto_install -- prefix=/usr

So as you see errors generated in terminal, If I understand right, debuild somehow tries to run clean that is defined in makefile to remove elecrotest which is created inside debian folder. However the folder is a folder with a limited privilege and clean shows permission denied error.

I have checked this post How to prevent debuild from performing a clean? and one of the answers are saying

override_dh_clean:

but I was not sure is that a right way to go because I thought it can make problems with build. Is changing privilege of folder generated by debian with chmod a the only way to go? or is there any smart idea that can solve this problem? I am not looking for workarounds.. need some solution to this

As A.B mentioned in comment, I did ls -ld debian/debianlaboration9/usr/ and got this result

drwxr-xr-x 2 root root 4096 jun 14 03:19
  • I guess the build part (without fakeroot) makes something like `chmod -w somedir` which prevents to then remove a file in this dir even with `fakeroot`. Doing the same *within* fakeroot before the chmod -w would then have worked. So is there something special about the directory containing the file that couldn't be removed? Don't forget to mention special environment (eg: directory belongs to hypervisor etc.). – A.B Jun 16 '22 at 20:38
  • @A.B If I understood right, command debian which I ran before running debuild generates a folder which is called debian. Then I think because there is override_dh_auto_install inside debian rules file, I think the debuild runs install that is defined in makefile and generates folder user with a binary file electrotest_standalone. problem is I do not have permission to usr folder generated by debuild.. – javaprogrammer Jun 16 '22 at 20:45
  • @A.B Because debuild generated folder usr without giving permission to me, the clean cannot remove that. I am not running clean manually, debuild runs clean automatically.. – javaprogrammer Jun 16 '22 at 20:47
  • @A.B I don't think I have understood your question So is there something special about the directory containing the file that couldn't be removed? What do you mean exactly here? Do you mean it's not strange that the file won't be removed? – javaprogrammer Jun 16 '22 at 20:56
  • once clean has failed do a `ls -ld debian/debianlaboration9/usr/` and report the result. Or if it's difficult to find: `find . -name usr -ls` – A.B Jun 16 '22 at 21:08
  • @A.B I have done ls -ld as you mentioned. See question – javaprogrammer Jun 16 '22 at 21:13
  • Wait: how comes it belongs to root and not a normal user? – A.B Jun 16 '22 at 21:15
  • @A.B that's the problem I mean. Debuild generated usr folder with root permission. That's why clean command can't remove file from there. I have no idea why debuild generated usr folder in that way. – javaprogrammer Jun 16 '22 at 21:17
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/137156/discussion-between-a-b-and-javaprogrammer). – A.B Jun 16 '22 at 21:20
  • 1
    Can't use chat rooms it appears to be broken on my web browser sorry. My last comment: if in the past you were using sudo instead of fakeroot to become root, then some files/dirs really belonging to root were left over. You'd have to clean them up manually as root user. – A.B Jun 16 '22 at 21:25

0 Answers0