[英]How to run custom commands during `make uninstall` from qmake in QT5?
我有一個QT項目,在運行make install
時為系統安裝服務。 .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
這將正確安裝服務,然后啟動它。
但是,當我運行make uninstall
,雖然已正確刪除已安裝的文件,但該服務仍保持安裝並正在運行。 我希望在運行make uninstall
時停止並卸載該服務。
停止和卸載服務的命令如下:
sudo service myservicename stop
sudo update-rc.d -f myservicename remove
但我無法弄清楚如何在.pro
文件中集成上述命令,以便qmake
可以理解它們並在Makefile中創建相關規則。
我在這個主題上找到的唯一文檔是這樣的: http : //doc.qt.io/qt-5/qmake-advanced-usage.html ,但它沒有提到有關卸載的任何內容。
嘗試使用.uninstall命令。
mytarget2.path = ~/Documents/inst
mytarget2.target = test.txt
mytarget2.commands = @echo "custom command"
mytarget2.uninstall = @echo "uninstall"
INSTALLS += mytarget2
它會生成這個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.