How to run custom commands during `make uninstall` from qmake in QT5?

I have a QT project that installs a service on a system when run make install . The relevant parts of the .pro file are as follows:

 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 removed, the service remains installed and running. I want the service to be stopped and make uninstall when running make uninstall .

The commands to stop and remove the service are as follows:

 sudo service myservicename stop sudo update-rc.d -f myservicename remove 

But I cannot figure out how to integrate the above commands into a .pro file, so qmake can understand them and create the corresponding rules in the Makefile.

The only documentation I found on this issue is this: http://doc.qt.io/qt-5/qmake-advanced-usage.html , but it does not say anything about deleting.

+6
source share
1 answer

try using the .uninstall command.

 mytarget2.path = ~/Documents/inst mytarget2.target = test.txt mytarget2.commands = @echo "custom command" mytarget2.uninstall = @echo "uninstall" INSTALLS += mytarget2 

it will generate this make file:

  ####### 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: 
+7
source

Source: https://habr.com/ru/post/988614/


All Articles