Changeset 95026 in vbox for trunk/src/VBox/Installer/win/Stub
- Timestamp:
- May 16, 2022 6:15:31 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/win/Stub/VBoxStub.cpp
r95025 r95026 619 619 * @param pszMsi The path to the MSI to process. 620 620 * @param pszMsiArgs Any additional installer (MSI) argument 621 * @param fLogging Whether to enable installer logging.622 */ 623 static RTEXITCODE ProcessMsiPackage(const char *pszMsi, const char *pszMsiArgs, bool fLogging)621 * @param pszMsiLogFile Where to let MSI log its output to. NULL if logging is disabled. 622 */ 623 static RTEXITCODE ProcessMsiPackage(const char *pszMsi, const char *pszMsiArgs, const char *pszMsiLogFile) 624 624 { 625 625 int rc; … … 636 636 * Enable logging? 637 637 */ 638 if (fLogging) 639 { 640 char szLogFile[RTPATH_MAX]; 641 rc = RTStrCopy(szLogFile, sizeof(szLogFile), pszMsi); 642 if (RT_SUCCESS(rc)) 643 { 644 RTPathStripFilename(szLogFile); 645 rc = RTPathAppend(szLogFile, sizeof(szLogFile), "VBoxInstallLog.txt"); 646 } 638 if (pszMsiLogFile) 639 { 640 PRTUTF16 pwszLogFile; 641 rc = RTStrToUtf16(pszMsiLogFile, &pwszLogFile); 647 642 if (RT_FAILURE(rc)) 648 return ShowError("Internal error: Filename path too long."); 649 650 PRTUTF16 pwszLogFile; 651 rc = RTStrToUtf16(szLogFile, &pwszLogFile); 652 if (RT_FAILURE(rc)) 653 return ShowError("RTStrToUtf16 failed on '%s': %Rrc", szLogFile, rc); 643 return ShowError("RTStrToUtf16 failed on '%s': %Rrc", pszMsiLogFile, rc); 654 644 655 645 UINT uLogLevel = MsiEnableLogW(INSTALLLOGMODE_VERBOSE, … … 659 649 if (uLogLevel != ERROR_SUCCESS) 660 650 return ShowError("MsiEnableLogW failed"); 661 662 if (g_iVerbosity)663 RTPrintf("Logging to file : %s\n", szLogFile);664 651 } 665 652 … … 771 758 * @param iPackage The package number. 772 759 * @param pszMsiArgs Any additional installer (MSI) argument 773 * @param fLogging Whether to enable installer logging.774 */ 775 static RTEXITCODE ProcessPackage(unsigned iPackage, const char *pszMsiArgs, bool fLogging)760 * @param pszMsiLogFile Where to let MSI log its output to. NULL if logging is disabled. 761 */ 762 static RTEXITCODE ProcessPackage(unsigned iPackage, const char *pszMsiArgs, const char *pszMsiLogFile) 776 763 { 777 764 /* … … 809 796 const char *pszSuff = RTPathSuffix(pRec->szPath); 810 797 if (RTStrICmpAscii(pszSuff, ".msi") == 0) 811 rcExit = ProcessMsiPackage(pRec->szPath, pszMsiArgs, fLogging);798 rcExit = ProcessMsiPackage(pRec->szPath, pszMsiArgs, pszMsiLogFile); 812 799 else if (RTStrICmpAscii(pszSuff, ".cab") == 0) 813 800 rcExit = RTEXITCODE_SUCCESS; /* Ignore .cab files, they're generally referenced by other files. */ … … 1058 1045 char szExtractPath[RTPATH_MAX] = {0}; 1059 1046 char szMSIArgs[_4K] = {0}; 1047 char szMSILogFile[RTPATH_MAX] = {0}; 1048 1049 /* Argument enumeration IDs. */ 1050 enum KVBOXSTUBOPT 1051 { 1052 KVBOXSTUBOPT_MSI_LOG_FILE = 1000 1053 }; 1060 1054 1061 1055 /* Parameter definitions. */ … … 1064 1058 /** @todo Replace short parameters with enums since they're not 1065 1059 * used (and not documented to the public). */ 1066 { "--extract", 'x', RTGETOPT_REQ_NOTHING },1067 { "-extract", 'x', RTGETOPT_REQ_NOTHING },1068 { "/extract", 'x', RTGETOPT_REQ_NOTHING },1069 { "--silent", 's', RTGETOPT_REQ_NOTHING },1070 { "-silent", 's', RTGETOPT_REQ_NOTHING },1071 { "/silent", 's', RTGETOPT_REQ_NOTHING },1060 { "--extract", 'x', RTGETOPT_REQ_NOTHING }, 1061 { "-extract", 'x', RTGETOPT_REQ_NOTHING }, 1062 { "/extract", 'x', RTGETOPT_REQ_NOTHING }, 1063 { "--silent", 's', RTGETOPT_REQ_NOTHING }, 1064 { "-silent", 's', RTGETOPT_REQ_NOTHING }, 1065 { "/silent", 's', RTGETOPT_REQ_NOTHING }, 1072 1066 #ifdef VBOX_WITH_CODE_SIGNING 1073 { "--no-silent-cert", 'c', RTGETOPT_REQ_NOTHING },1074 { "-no-silent-cert", 'c', RTGETOPT_REQ_NOTHING },1075 { "/no-silent-cert", 'c', RTGETOPT_REQ_NOTHING },1067 { "--no-silent-cert", 'c', RTGETOPT_REQ_NOTHING }, 1068 { "-no-silent-cert", 'c', RTGETOPT_REQ_NOTHING }, 1069 { "/no-silent-cert", 'c', RTGETOPT_REQ_NOTHING }, 1076 1070 #endif 1077 { "--logging", 'l', RTGETOPT_REQ_NOTHING }, 1078 { "-logging", 'l', RTGETOPT_REQ_NOTHING }, 1079 { "/logging", 'l', RTGETOPT_REQ_NOTHING }, 1080 { "--path", 'p', RTGETOPT_REQ_STRING }, 1081 { "-path", 'p', RTGETOPT_REQ_STRING }, 1082 { "/path", 'p', RTGETOPT_REQ_STRING }, 1083 { "--msiparams", 'm', RTGETOPT_REQ_STRING }, 1084 { "-msiparams", 'm', RTGETOPT_REQ_STRING }, 1085 { "--msi-prop", 'P', RTGETOPT_REQ_STRING }, 1086 { "--reinstall", 'f', RTGETOPT_REQ_NOTHING }, 1087 { "-reinstall", 'f', RTGETOPT_REQ_NOTHING }, 1088 { "/reinstall", 'f', RTGETOPT_REQ_NOTHING }, 1089 { "--ignore-reboot", 'r', RTGETOPT_REQ_NOTHING }, 1090 { "--verbose", 'v', RTGETOPT_REQ_NOTHING }, 1091 { "-verbose", 'v', RTGETOPT_REQ_NOTHING }, 1092 { "/verbose", 'v', RTGETOPT_REQ_NOTHING }, 1093 { "--version", 'V', RTGETOPT_REQ_NOTHING }, 1094 { "-version", 'V', RTGETOPT_REQ_NOTHING }, 1095 { "/version", 'V', RTGETOPT_REQ_NOTHING }, 1096 { "--help", 'h', RTGETOPT_REQ_NOTHING }, 1097 { "-help", 'h', RTGETOPT_REQ_NOTHING }, 1098 { "/help", 'h', RTGETOPT_REQ_NOTHING }, 1099 { "/?", 'h', RTGETOPT_REQ_NOTHING }, 1071 { "--logging", 'l', RTGETOPT_REQ_NOTHING }, 1072 { "-logging", 'l', RTGETOPT_REQ_NOTHING }, 1073 { "--msi-log-file", KVBOXSTUBOPT_MSI_LOG_FILE, RTGETOPT_REQ_STRING }, 1074 { "-msilogfile", KVBOXSTUBOPT_MSI_LOG_FILE, RTGETOPT_REQ_STRING }, 1075 { "/logging", 'l', RTGETOPT_REQ_NOTHING }, 1076 { "--path", 'p', RTGETOPT_REQ_STRING }, 1077 { "-path", 'p', RTGETOPT_REQ_STRING }, 1078 { "/path", 'p', RTGETOPT_REQ_STRING }, 1079 { "--msiparams", 'm', RTGETOPT_REQ_STRING }, 1080 { "-msiparams", 'm', RTGETOPT_REQ_STRING }, 1081 { "--msi-prop", 'P', RTGETOPT_REQ_STRING }, 1082 { "--reinstall", 'f', RTGETOPT_REQ_NOTHING }, 1083 { "-reinstall", 'f', RTGETOPT_REQ_NOTHING }, 1084 { "/reinstall", 'f', RTGETOPT_REQ_NOTHING }, 1085 { "--ignore-reboot", 'r', RTGETOPT_REQ_NOTHING }, 1086 { "--verbose", 'v', RTGETOPT_REQ_NOTHING }, 1087 { "-verbose", 'v', RTGETOPT_REQ_NOTHING }, 1088 { "/verbose", 'v', RTGETOPT_REQ_NOTHING }, 1089 { "--version", 'V', RTGETOPT_REQ_NOTHING }, 1090 { "-version", 'V', RTGETOPT_REQ_NOTHING }, 1091 { "/version", 'V', RTGETOPT_REQ_NOTHING }, 1092 { "--help", 'h', RTGETOPT_REQ_NOTHING }, 1093 { "-help", 'h', RTGETOPT_REQ_NOTHING }, 1094 { "/help", 'h', RTGETOPT_REQ_NOTHING }, 1095 { "/?", 'h', RTGETOPT_REQ_NOTHING }, 1100 1096 }; 1101 1097 … … 1135 1131 case 'l': 1136 1132 fEnableLogging = true; 1133 break; 1134 1135 case KVBOXSTUBOPT_MSI_LOG_FILE: 1136 if (*ValueUnion.psz == '\0') 1137 szMSILogFile[0] = '\0'; 1138 else 1139 { 1140 vrc = RTPathAbs(ValueUnion.psz, szMSILogFile, sizeof(szMSILogFile)); 1141 if (RT_FAILURE(vrc)) 1142 return ShowSyntaxError("MSI log file path is too long (%Rrc)", vrc); 1143 } 1137 1144 break; 1138 1145 … … 1200 1207 " Extract file contents to temporary directory\n" 1201 1208 "--logging\n" 1202 " Enables installer logging\n" 1209 " Enables MSI installer logging (to extract path)\n" 1210 "--msi-log-file <path/to/file>\n" 1211 " Sets MSI logging to <file>\n" 1203 1212 "--msiparams <parameters>\n" 1204 1213 " Specifies extra parameters for the MSI installers\n" … … 1325 1334 #endif /* VBOX_STUB_WITH_OWN_CONSOLE */ 1326 1335 1336 /* Convenience: Enable logging if a log file (via --log-file) is specified. */ 1337 if ( !fEnableLogging 1338 && szMSILogFile[0] != '\0') 1339 fEnableLogging = true; 1340 1341 if ( fEnableLogging 1342 && szMSILogFile[0] == '\0') /* No log file explicitly specified? Use the extract path by default. */ 1343 { 1344 vrc = RTStrCopy(szMSILogFile, sizeof(szMSILogFile), szExtractPath); 1345 if (RT_SUCCESS(vrc)) 1346 vrc = RTPathAppend(szMSILogFile, sizeof(szMSILogFile), "VBoxInstallLog.txt"); 1347 if (RT_FAILURE(vrc)) 1348 return ShowError("Error creating MSI log file name, rc=%Rrc", vrc); 1349 } 1350 1327 1351 if (g_iVerbosity) 1328 1352 { … … 1332 1356 RTPrintf("Certificate installation : %RTbool\n", fEnableSilentCert); 1333 1357 #endif 1334 RTPrintf("Additional MSI parameters: %s\n", szMSIArgs[0] ? szMSIArgs : "<None>");1335 RTPrintf("Logging enabled : %RTbool\n", fEnableLogging);1358 RTPrintf("Additional MSI parameters: %s\n", szMSIArgs[0] ? szMSIArgs : "<None>"); 1359 RTPrintf("Logging to file : %s\n", szMSILogFile[0] ? szMSILogFile : "<None>"); 1336 1360 } 1337 1361 … … 1375 1399 && (rcExit == RTEXITCODE_SUCCESS || rcExit == (RTEXITCODE)ERROR_SUCCESS_REBOOT_REQUIRED)) 1376 1400 { 1377 RTEXITCODE rcExit2 = ProcessPackage(iPackage, szMSIArgs, fEnableLogging);1401 RTEXITCODE rcExit2 = ProcessPackage(iPackage, szMSIArgs, szMSILogFile[0] ? szMSILogFile : NULL); 1378 1402 if (rcExit2 != RTEXITCODE_SUCCESS) 1379 1403 rcExit = rcExit2;
Note:
See TracChangeset
for help on using the changeset viewer.