Changeset 94335 in vbox for trunk/src/VBox/Main/src-server/UnattendedInstaller.cpp
- Timestamp:
- Mar 23, 2022 12:39:13 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/UnattendedInstaller.cpp
r94325 r94335 865 865 try 866 866 { 867 /* Don't include menu.cfg which may default (as most Debians do) to some vanilla menu item. txt.cfg has command868 * kernel line options pointing to our preseed file. */869 std::vector<size_t> vecLineNumbers = pEditor->findTemplate("include", RTCString::CaseInsensitive);870 for (size_t i = 0; i < vecLineNumbers.size(); ++i)871 if (pEditor->getContentOfLine(vecLineNumbers[i]).startsWithWord("include", RTCString::CaseInsensitive))872 {873 HRESULT hrc = pEditor->setContentOfLine(vecLineNumbers.at(i), "include txt.cfg");874 if (FAILED(hrc))875 return hrc;876 }877 878 879 867 /* Comment out 'display <filename>' directives that's used for displaying files at boot time. */ 880 vecLineNumbers =pEditor->findTemplate("display", RTCString::CaseInsensitive);868 std::vector<size_t> vecLineNumbers = pEditor->findTemplate("display", RTCString::CaseInsensitive); 881 869 for (size_t i = 0; i < vecLineNumbers.size(); ++i) 882 870 if (pEditor->getContentOfLine(vecLineNumbers[i]).startsWithWord("display", RTCString::CaseInsensitive)) … … 1007 995 RTVFS hVfsOrgIso, bool fOverwrite) 1008 996 { 1009 /* 1010 * The txt.cfg file used to be called isolinux.txt (ubuntu 4.10 1011 * and possible others). 1012 */ 1013 /** @todo Ubuntu 4.10 does not work, as we generate too long command lines 1014 * and the kernel crashes immediately. */ 1015 const char *pszIsoLinuxTxtCfg = "/isolinux/txt.cfg"; 1016 if ( !hlpVfsFileExists(hVfsOrgIso, pszIsoLinuxTxtCfg) 1017 && hlpVfsFileExists(hVfsOrgIso, "/isolinux/isolinux.txt")) 1018 pszIsoLinuxTxtCfg = "/isolinux/isolinux.txt"; 997 /* On Debian Live ISOs (at least from 9 to 11) the there is only menu.cfg. */ 998 const char *pszMenuConfigFileName = "/isolinux/txt.cfg"; 999 if ( !hlpVfsFileExists(hVfsOrgIso, pszMenuConfigFileName) 1000 && hlpVfsFileExists(hVfsOrgIso, "/isolinux/menu.cfg")) 1001 pszMenuConfigFileName = "/isolinux/menu.cfg"; 1019 1002 1020 1003 /* … … 1037 1020 /* Remove the two isolinux configure files we'll be replacing. */ 1038 1021 rVecArgs.append() = "isolinux/isolinux.cfg=:must-remove:"; 1039 rVecArgs.append().assign(&psz IsoLinuxTxtCfg[1]).append("=:must-remove:");1022 rVecArgs.append().assign(&pszMenuConfigFileName[1]).append("=:must-remove:"); 1040 1023 1041 1024 /* Add the replacement files. */ … … 1046 1029 strTxtCfg = mpParent->i_getAuxiliaryBasePath(); 1047 1030 strTxtCfg.append("isolinux-txt.cfg"); 1048 rVecArgs.append().assign(&psz IsoLinuxTxtCfg[1]).append("=").append(strTxtCfg);1031 rVecArgs.append().assign(&pszMenuConfigFileName[1]).append("=").append(strTxtCfg); 1049 1032 } 1050 1033 catch (std::bad_alloc &) … … 1060 1043 HRESULT hrc = loadAndParseFileFromIso(hVfsOrgIso, "/isolinux/isolinux.cfg", &Editor); 1061 1044 if (SUCCEEDED(hrc)) 1062 hrc = editIsoLinuxCfg(&Editor );1045 hrc = editIsoLinuxCfg(&Editor, RTPathFilename(pszMenuConfigFileName)); 1063 1046 if (SUCCEEDED(hrc)) 1064 1047 { … … 1082 1065 1083 1066 /* 1084 * Edit the txt.cfgfile.1067 * Edit the menu config file file. 1085 1068 */ 1086 1069 { 1087 1070 GeneralTextScript Editor(mpParent); 1088 HRESULT hrc = loadAndParseFileFromIso(hVfsOrgIso, psz IsoLinuxTxtCfg, &Editor);1071 HRESULT hrc = loadAndParseFileFromIso(hVfsOrgIso, pszMenuConfigFileName, &Editor); 1089 1072 if (SUCCEEDED(hrc)) 1090 hrc = editDebian TxtCfg(&Editor);1073 hrc = editDebianMenuCfg(&Editor); 1091 1074 if (SUCCEEDED(hrc)) 1092 1075 { … … 1115 1098 } 1116 1099 1117 HRESULT UnattendedDebianInstaller::editDebianTxtCfg(GeneralTextScript *pEditor) 1100 HRESULT UnattendedDebianInstaller::editIsoLinuxCfg(GeneralTextScript *pEditor, const char *pszMenuConfigFileName) 1101 { 1102 try 1103 { 1104 /* Include menu config file. Since it can be txt.cfg, menu.cfg or something else we need to parametrize this. */ 1105 if (pszMenuConfigFileName && pszMenuConfigFileName[0] != '\0') 1106 { 1107 std::vector<size_t> vecLineNumbers = pEditor->findTemplate("include", RTCString::CaseInsensitive); 1108 for (size_t i = 0; i < vecLineNumbers.size(); ++i) 1109 { 1110 if (pEditor->getContentOfLine(vecLineNumbers[i]).startsWithWord("include", RTCString::CaseInsensitive)) 1111 { 1112 Utf8Str strIncludeLine("include "); 1113 strIncludeLine.append(pszMenuConfigFileName); 1114 HRESULT hrc = pEditor->setContentOfLine(vecLineNumbers.at(i), strIncludeLine); 1115 if (FAILED(hrc)) 1116 return hrc; 1117 } 1118 } 1119 } 1120 1121 /* Comment out default directives since in Debian case default is handled in menu config file. */ 1122 std::vector<size_t> vecLineNumbers = pEditor->findTemplate("default", RTCString::CaseInsensitive); 1123 for (size_t i = 0; i < vecLineNumbers.size(); ++i) 1124 if (pEditor->getContentOfLine(vecLineNumbers[i]).startsWithWord("default", RTCString::CaseInsensitive)) 1125 { 1126 HRESULT hrc = pEditor->prependToLine(vecLineNumbers.at(i), "#"); 1127 if (FAILED(hrc)) 1128 return hrc; 1129 } 1130 } 1131 catch (std::bad_alloc &) 1132 { 1133 return E_OUTOFMEMORY; 1134 } 1135 return UnattendedLinuxInstaller::editIsoLinuxCfg(pEditor); 1136 } 1137 1138 HRESULT UnattendedDebianInstaller::editDebianMenuCfg(GeneralTextScript *pEditor) 1118 1139 { 1119 1140 /*
Note:
See TracChangeset
for help on using the changeset viewer.