![debuild 无法删除‘..’权限被拒绝,debian/rules:9:目标‘clean’的配方失败](https://linux22.com/image/1187603/debuild%20%E6%97%A0%E6%B3%95%E5%88%A0%E9%99%A4%E2%80%98..%E2%80%99%E6%9D%83%E9%99%90%E8%A2%AB%E6%8B%92%E7%BB%9D%EF%BC%8Cdebian%2Frules%3A9%EF%BC%9A%E7%9B%AE%E6%A0%87%E2%80%98clean%E2%80%99%E7%9A%84%E9%85%8D%E6%96%B9%E5%A4%B1%E8%B4%A5.png)
我正在尝试运行 debuild 命令来使用 debian 处理我的项目但是,当我运行 debuild 命令时出现这样的错误:
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
我的 makefile 如下所示:
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
这是我的 debian 规则文件
#!/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
因此,正如您在终端中看到的错误一样,如果我理解正确的话,debuild 会以某种方式尝试运行 makefile 中定义的 clean 来删除在 debian 文件夹中创建的 elecrotest。但是该文件夹是一个权限受限的文件夹,clean 显示权限被拒绝错误。
我已经检查过这个帖子https://unix.stackexchange.com/questions/304590/how-to-prevent-debuild-from-performing-a-clean如何防止 debuild 执行清理?其中一个答案是
override_dh_clean:
但我不确定这是否是正确的方法,因为我认为这会导致构建出现问题。使用 chmod a 更改 debian 生成的文件夹的权限是唯一的方法吗?或者有什么聪明的想法可以解决这个问题?我不是在寻找解决方法。需要一些解决方案