VirtualBox

Changeset 96657 in vbox


Ignore:
Timestamp:
Sep 8, 2022 12:47:58 PM (2 years ago)
Author:
vboxsync
Message:

Unattended: bugref:9781. Some fixes to make unattended install work with Kubuntu 20.04 and Kubuntu 22.04.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/UnattendedInstaller.h

    r96407 r96657  
    622622     */
    623623    virtual HRESULT editIsoLinuxCfg(GeneralTextScript *pEditor, const char *pszMenuConfigFileName);
     624
     625private:
     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);
    624638};
    625639
  • trunk/src/VBox/Main/src-server/UnattendedInstaller.cpp

    r96407 r96657  
    11701170                    return hrc;
    11711171            }
     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            }
    11721182    }
    11731183    catch (std::bad_alloc &)
     
    11831193     * Unlike Redhats, Debian variants define boot menu not in isolinux.cfg but some other
    11841194     * 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'.
    11861197     */
    11871198    try
    11881199    {
    11891200        HRESULT hrc = S_OK;
    1190         const char *pszNewLabel = "VBoxUnatendedInstall";
    11911201        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
    12141207        if (!fLabelFound)
    12151208            hrc = E_FAIL;;
     
    12191212            /* Modify the content of default lines so that they point to label we have chosen above. */
    12201213            Utf8Str strNewContent("default ");
    1221             strNewContent.append(pszNewLabel);
     1214            strNewContent.append(pszNewLabelName);
    12221215
    12231216            std::vector<size_t> vecDefaultLineNumbers = pEditor->findTemplate("default", RTCString::CaseInsensitive);
     
    12431236    }
    12441237    return UnattendedLinuxInstaller::editIsoLinuxCommon(pEditor);
     1238}
     1239
     1240bool 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;
    12451265}
    12461266
Note: See TracChangeset for help on using the changeset viewer.

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