[英]How to run custom commands during `make uninstall` from qmake in QT5?
I have a QT project that installs a service to the system, when running make install
. 我有一个QT项目,在运行
make install
时为系统安装服务。 The relevant parts of the .pro
file are the following: .pro
文件的相关部分如下:
init.path = /etc/init.d/
init.files = myservicename
updaterc.path = /etc/init.d/
updaterc.extra = chmod 755 $$init.files; \
update-rc.d $$init.files defaults 97 03; \
service $$init.files start
INSTALLS += target ... init updaterc
This installs the service correctly and then starts it. 这将正确安装服务,然后启动它。
However, when I run make uninstall
, although the installed files are correctly deleted, the service remains installed and running. 但是,当我运行
make uninstall
,虽然已正确删除已安装的文件,但该服务仍保持安装并正在运行。 I would like the service to be stopped and uninstalled when running make uninstall
. 我希望在运行
make uninstall
时停止并卸载该服务。
The commands for stopping and uninstalling the service are the following: 停止和卸载服务的命令如下:
sudo service myservicename stop
sudo update-rc.d -f myservicename remove
But I cannot figure out how to integrate the above commands in .pro
file, so that qmake
can understand them and create the relevant rules in the Makefile. 但我无法弄清楚如何在
.pro
文件中集成上述命令,以便qmake
可以理解它们并在Makefile中创建相关规则。
The only documentation I have found on the subject is this: http://doc.qt.io/qt-5/qmake-advanced-usage.html , but it does not say anything about uninstalling. 我在这个主题上找到的唯一文档是这样的: http : //doc.qt.io/qt-5/qmake-advanced-usage.html ,但它没有提到有关卸载的任何内容。
try to use .uninstall command. 尝试使用.uninstall命令。
mytarget2.path = ~/Documents/inst
mytarget2.target = test.txt
mytarget2.commands = @echo "custom command"
mytarget2.uninstall = @echo "uninstall"
INSTALLS += mytarget2
it will generate this makefile: 它会生成这个makefile:
####### Install
install_mytarget2: first FORCE
@test -d $(INSTALL_ROOT)/Users/mac/Documents/inst || mkdir -p $(INSTALL_ROOT)/Users/mac/Documents/inst
@echo custom command
uninstall_mytarget2: FORCE
@echo uninstall
-$(DEL_DIR) $(INSTALL_ROOT)/Users/mac/Documents/inst/
install: install_mytarget2 FORCE
uninstall: uninstall_mytarget2 FORCE
FORCE:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.