VirtualBox

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

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1; $Id: VBoxGuestAdditionsExternal.nsh 98103 2023-01-17 14:15:46Z vboxsync $
2;; @file
3; VBoxGuestAdditionExternal.nsh - Utility function for invoking external applications.
4;
5
6;
7; Copyright (C) 2013-2023 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 ${IfNot} ${options} != "exitcode=0"
48 ${AndIfNot} ${options} != "ignore-exitcode"
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} "$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 ${If} ${options} == "exitcode=0"
73 ${LogVerbose} "Error excuting $\"${cmdline}$\" (exit code: $0) -- aborting installation"
74 Abort "Error excuting $\"${cmdline}$\" (exit code: $0) -- aborting installation"
75 ${Else}
76 ${LogVerbose} "Warning: Executing $\"${cmdline}$\" returned with exit code $0"
77 ${EndIf}
78 ${EndIf}
79
80 ; Restore $0 and $1.
81 Pop $1
82 Pop $0
83!macroend
84!define CmdExecute "!insertmacro _cmdExecute"
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use