Changeset 96657 in vbox
- Timestamp:
- Sep 8, 2022 12:47:58 PM (2 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/UnattendedInstaller.h
r96407 r96657 622 622 */ 623 623 virtual HRESULT editIsoLinuxCfg(GeneralTextScript *pEditor, const char *pszMenuConfigFileName); 624 625 private: 626 627 /** 628 * Tries to set label name of a label line. 629 * 630 * @returns true if label line is found and label name can be set. 631 * @param pEditor Editor with the menu configuration file loaded and parsed. 632 * @param vecLineNumbers Indices of the label lines (within pEditor data). 633 * @param pszKeyWord The keyword searched within the original label name. 634 * @param pszNewLabelName The new name of the label. 635 */ 636 bool modifyLabelLine(GeneralTextScript *pEditor, const std::vector<size_t> &vecLineNumbers, 637 const char *pszKeyWord, const char *pszNewLabelName); 624 638 }; 625 639 -
trunk/src/VBox/Main/src-server/UnattendedInstaller.cpp
r96407 r96657 1170 1170 return hrc; 1171 1171 } 1172 1173 /* Comment out "ui gfxboot bootlogo" line as it somehow messes things up on Kubuntu 20.04 (possibly others as well). */ 1174 vecLineNumbers = pEditor->findTemplate("ui gfxboot", RTCString::CaseInsensitive); 1175 for (size_t i = 0; i < vecLineNumbers.size(); ++i) 1176 if (pEditor->getContentOfLine(vecLineNumbers[i]).startsWithWord("ui gfxboot", RTCString::CaseInsensitive)) 1177 { 1178 HRESULT hrc = pEditor->prependToLine(vecLineNumbers.at(i), "#"); 1179 if (FAILED(hrc)) 1180 return hrc; 1181 } 1172 1182 } 1173 1183 catch (std::bad_alloc &) … … 1183 1193 * Unlike Redhats, Debian variants define boot menu not in isolinux.cfg but some other 1184 1194 * menu configuration files. They are mostly called txt.cfg and/or menu.cfg (and possibly some other names) 1185 * In this functions we attempt to set menu's default label (default menu item) to the one containing the word 'install'. 1195 * In this functions we attempt to set menu's default label (default menu item) to the one containing the word 'install', 1196 * failing to find such a label (on Kubuntu 20.04 for example) we pick the first label with name 'live'. 1186 1197 */ 1187 1198 try 1188 1199 { 1189 1200 HRESULT hrc = S_OK; 1190 const char *pszNewLabel = "VBoxUnatendedInstall";1191 1201 std::vector<size_t> vecLineNumbers = pEditor->findTemplate("label", RTCString::CaseInsensitive); 1192 bool fLabelFound = false; 1193 for (size_t i = 0; i < vecLineNumbers.size(); ++i) 1194 { 1195 RTCString const &rContent = pEditor->getContentOfLine(vecLineNumbers[i]); 1196 /* Skip this line if it does not start with the word 'label'. */ 1197 if (!RTStrIStartsWith(rContent.c_str(), "label")) 1198 continue; 1199 /* Use the first menu item starting with word label and includes the word 'install'.*/ 1200 if (RTStrIStr(rContent.c_str(), "install") != NULL) 1201 { 1202 /* Set the content of the line. It looks like multiple word labels (like label Debian Installer) 1203 * does not work very well in some cases. */ 1204 Utf8Str strNewLabel("label "); 1205 strNewLabel.append(pszNewLabel); 1206 hrc = pEditor->setContentOfLine(vecLineNumbers[i], strNewLabel); 1207 if (SUCCEEDED(hrc)) 1208 { 1209 fLabelFound = true; 1210 break; 1211 } 1212 } 1213 } 1202 const char *pszNewLabelName = "VBoxUnatendedInstall"; 1203 bool fLabelFound = modifyLabelLine(pEditor, vecLineNumbers, "install", pszNewLabelName); 1204 if (!fLabelFound) 1205 fLabelFound = modifyLabelLine(pEditor, vecLineNumbers, "live", pszNewLabelName); 1206 1214 1207 if (!fLabelFound) 1215 1208 hrc = E_FAIL;; … … 1219 1212 /* Modify the content of default lines so that they point to label we have chosen above. */ 1220 1213 Utf8Str strNewContent("default "); 1221 strNewContent.append(pszNewLabel );1214 strNewContent.append(pszNewLabelName); 1222 1215 1223 1216 std::vector<size_t> vecDefaultLineNumbers = pEditor->findTemplate("default", RTCString::CaseInsensitive); … … 1243 1236 } 1244 1237 return UnattendedLinuxInstaller::editIsoLinuxCommon(pEditor); 1238 } 1239 1240 bool UnattendedDebianInstaller::modifyLabelLine(GeneralTextScript *pEditor, const std::vector<size_t> &vecLineNumbers, 1241 const char *pszKeyWord, const char *pszNewLabelName) 1242 { 1243 if (!pEditor) 1244 return false; 1245 Utf8Str strNewLabel("label "); 1246 strNewLabel.append(pszNewLabelName); 1247 HRESULT hrc = S_OK; 1248 for (size_t i = 0; i < vecLineNumbers.size(); ++i) 1249 { 1250 RTCString const &rContent = pEditor->getContentOfLine(vecLineNumbers[i]); 1251 /* Skip this line if it does not start with the word 'label'. */ 1252 if (!RTStrIStartsWith(rContent.c_str(), "label")) 1253 continue; 1254 /* Use the first menu item starting with word label and includes pszKeyWord.*/ 1255 if (RTStrIStr(rContent.c_str(), pszKeyWord) != NULL) 1256 { 1257 /* Set the content of the line. It looks like multiple word labels (like label Debian Installer) 1258 * does not work very well in some cases. */ 1259 hrc = pEditor->setContentOfLine(vecLineNumbers[i], strNewLabel); 1260 if (SUCCEEDED(hrc)) 1261 return true; 1262 } 1263 } 1264 return false; 1245 1265 } 1246 1266
Note:
See TracChangeset
for help on using the changeset viewer.