Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. The relevant parts of the .pro file are the following:

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. I would like the service to be stopped and uninstalled when running 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.

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.

like image 921
user000001 Avatar asked Jun 06 '15 08:06

user000001


1 Answers

try to use .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 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:
like image 193
Alexander Dalshov Avatar answered Oct 03 '22 21:10

Alexander Dalshov