summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2015-04-28 19:35:58 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2015-04-28 19:37:25 +0200
commit5ff22d39192bc004d667862239528447262b773c (patch)
treef010a4f66e55265c5222dc38f25beb9b26c616b8
parentd3451732bd12426ebca028ab51b0e4c7680a1ba5 (diff)
nsis: Refactor StopServices
Use ${if} to make it more readable, and introduce a StopService helper function as the code to share the SPICE agent and the balloon service is the same.
-rw-r--r--spice-guest-tools.nsis47
1 files changed, 27 insertions, 20 deletions
diff --git a/spice-guest-tools.nsis b/spice-guest-tools.nsis
index 047cdf3..17f7812 100644
--- a/spice-guest-tools.nsis
+++ b/spice-guest-tools.nsis
@@ -245,32 +245,39 @@ Function InstallDriver
FunctionEnd
!macro StopServices un
-Function ${un}StopServices
- SimpleSC::ServiceIsRunning "vdservice"
+Function ${un}StopService
+ pop $R0
+
+ SimpleSC::ServiceIsRunning $R0
pop $0
pop $1
- IntCmp $0 0 +1 stopBalloon stopBalloon
- IntCmp $1 0 stopBalloon +1 +1
+ ${if} $0 != 0
+ # error
+ Return
+ ${endif}
+ ${if} $1 == 0
+ # service not running
+ Return
+ ${endif}
- DetailPrint "Stopping vdservice"
- SimpleSC::StopService "vdservice" 1 30
+ DetailPrint "Stopping $R0"
+ SimpleSC::StopService $R0 1 30
pop $0
- IntCmp $1 0 stopBalloon +1 +1
- DetailPrint "Failed to stop vdservice: $0"
+ ${if} $0 != 0
+ DetailPrint "Failed to stop $R0: $0"
+ Return
+ ${endif}
+ DetailPrint "$R0 stopped"
+FunctionEnd
+
+Function ${un}StopServices
+ push "vdservice"
+ Call ${un}StopService
+
+ push "BalloonService"
+ Call ${un}StopService
-stopBalloon:
- SimpleSC::ServiceIsRunning "BalloonService"
- pop $0
- pop $1
- IntCmp $0 0 +1 end end
- IntCmp $1 0 end +1 +1
- DetailPrint "Stopping BalloonService"
- SimpleSC::StopService "BalloonService" 1 30
- pop $0
- IntCmp $1 0 end +1 +1
- DetailPrint "Failed to stop BalloonService: $0"
-end:
FunctionEnd
!macroend