VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditionsExternal.nsh@ 107377

Last change on this file since 107377 was 107237, checked in by vboxsync, 2 months ago

Windows Guest Additions installer: Fixed regression from r153570 within CmdExecute macro, where there was a double negation in the options checking as well as a bug which prevented the installation to abort if the caller told so via the given options.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1; $Id: VBoxGuestAdditionsExternal.nsh 107237 2024-12-05 14:53:26Z vboxsync $
2;; @file
3; VBoxGuestAdditionExternal.nsh - Utility function for invoking external applications.
4;
5
6;
7; Copyright (C) 2013-2024 Oracle and/or its affiliates.
8;
9; This file is part of VirtualBox base platform packages, as
10; available from https://www.virtualbox.org.
11;
12; This program is free software; you can redistribute it and/or
13; modify it under the terms of the GNU General Public License
14; as published by the Free Software Foundation, in version 3 of the
15; License.
16;
17; This program is distributed in the hope that it will be useful, but
18; WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20; General Public License for more details.
21;
22; You should have received a copy of the GNU General Public License
23; along with this program; if not, see <https://www.gnu.org/licenses>.
24;
25; SPDX-License-Identifier: GPL-3.0-only
26;
27
28;;
29; Macro for executing external applications.
30;
31; Uses the nsExec plugin in different styles, depending on whether this
32; installer runs in silent mode or not. If the external program reports an exit
33; code other than 0 the installer will be aborted.
34;
35; @param ${cmdline} Command line (full qualified and quoted).
36; @param ${options} Either 'non-zero-exitcode=log' or 'non-zero-exitcode=abort'.
37; Controls how to handle non-zero exit codes, in the latter
38; case they will trigger an installation abort, while in the
39; form only a warning in the log file.
40;
41!macro _cmdExecute cmdline options
42 ; Save $0 & $1
43 Push $0
44 Push $1
45
46 ; Check that the options are valid.
47 ${If} ${options} != "non-zero-exitcode=log"
48 ${AndIf} ${options} != "non-zero-exitcode=abort"
49 Abort "Internal error in _cmdExecute: options=${options} cmdline=${cmdline}"
50 ${EndIf}
51
52 ;
53 ; Execute the command, putting the exit code in $0 when done.
54 ;
55 ${LogVerbose} "Executing: ${cmdline}"
56 ${If} ${Silent}
57 nsExec::ExecToStack "${cmdline}"
58 Pop $0 ; Return value (exit code)
59 Pop $1 ; Stdout/stderr output (up to ${NSIS_MAX_STRLEN})
60 ${LogVerbose} "exit code=$0: $1"
61 ${Else}
62 nsExec::ExecToLog "${cmdline}"
63 Pop $0 ; Return value (exit code)
64 ${EndIf}
65
66 ${LogVerbose} "Execution returned exit code: $0"
67
68 ;
69 ; Check if it failed and take action according to the 2nd argument.
70 ;
71 ${If} $0 <> 0
72 ${OrIf} $0 == "error" ; Issued by the nsExec plugin if the DLL call failed (messy handling within nsExec, sigh).
73 ${If} ${options} == "non-zero-exitcode=abort"
74 ${LogVerbose} "Error excuting $\"${cmdline}$\" (exit code: $0) -- aborting installation"
75 Abort "Error excuting $\"${cmdline}$\" (exit code: $0) -- aborting installation"
76 ${Else}
77 ${LogVerbose} "Warning: Executing $\"${cmdline}$\" returned with exit code $0"
78 ${EndIf}
79 ${EndIf}
80
81 ; Restore $0 and $1.
82 Pop $1
83 Pop $0
84!macroend
85!define CmdExecute "!insertmacro _cmdExecute"
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette