VirtualBox

Changeset 94335 in vbox for trunk


Ignore:
Timestamp:
Mar 23, 2022 12:39:13 PM (3 years ago)
Author:
vboxsync
Message:

Main/Unattended: ​​bugref:9781. Debian live ISOs have only menu.cfg as boot menu configuration file. These are some related changes. More to come for Debian Live ISOs.

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

Legend:

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

    r94324 r94335  
    533533     *
    534534     * @returns COM status code
    535      * @param   pEditor         Editor with the isolinux.cfg file loaded and parsed.
     535     * @param   pEditor               Editor with the isolinux.cfg file loaded and parsed.
    536536     */
    537537    virtual HRESULT editIsoLinuxCfg(GeneralTextScript *pEditor);
     
    594594     * @param   pEditor         Editor with the isolinux.cfg file loaded and parsed.
    595595     */
    596     HRESULT editDebianTxtCfg(GeneralTextScript *pEditor);
     596    HRESULT editDebianMenuCfg(GeneralTextScript *pEditor);
     597    /**
     598     * Performs basic edits on a isolinux.cfg file.
     599     *
     600     * @returns COM status code
     601     * @param   pEditor               Editor with the isolinux.cfg file loaded and parsed.
     602     * @param   pszMenuConfigFileName Name of the menu config file to include in isolinux.txt. On Debians (at least)
     603                                      it includes the kernel command line with our preseed file and command line argument.
     604     */
     605    virtual HRESULT editIsoLinuxCfg(GeneralTextScript *pEditor, const char *pszMenuConfigFileName);
    597606};
    598607
  • trunk/src/VBox/Main/src-server/UnattendedInstaller.cpp

    r94325 r94335  
    865865    try
    866866    {
    867         /* Don't include menu.cfg which may default (as most Debians do) to some vanilla menu item. txt.cfg has command
    868          * 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 
    879867        /* 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);
    881869        for (size_t i = 0; i < vecLineNumbers.size(); ++i)
    882870            if (pEditor->getContentOfLine(vecLineNumbers[i]).startsWithWord("display", RTCString::CaseInsensitive))
     
    1007995                                                            RTVFS hVfsOrgIso, bool fOverwrite)
    1008996{
    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";
    10191002
    10201003    /*
     
    10371020        /* Remove the two isolinux configure files we'll be replacing. */
    10381021        rVecArgs.append() = "isolinux/isolinux.cfg=:must-remove:";
    1039         rVecArgs.append().assign(&pszIsoLinuxTxtCfg[1]).append("=:must-remove:");
     1022        rVecArgs.append().assign(&pszMenuConfigFileName[1]).append("=:must-remove:");
    10401023
    10411024        /* Add the replacement files. */
     
    10461029        strTxtCfg = mpParent->i_getAuxiliaryBasePath();
    10471030        strTxtCfg.append("isolinux-txt.cfg");
    1048         rVecArgs.append().assign(&pszIsoLinuxTxtCfg[1]).append("=").append(strTxtCfg);
     1031        rVecArgs.append().assign(&pszMenuConfigFileName[1]).append("=").append(strTxtCfg);
    10491032    }
    10501033    catch (std::bad_alloc &)
     
    10601043        HRESULT hrc = loadAndParseFileFromIso(hVfsOrgIso, "/isolinux/isolinux.cfg", &Editor);
    10611044        if (SUCCEEDED(hrc))
    1062             hrc = editIsoLinuxCfg(&Editor);
     1045            hrc = editIsoLinuxCfg(&Editor, RTPathFilename(pszMenuConfigFileName));
    10631046        if (SUCCEEDED(hrc))
    10641047        {
     
    10821065
    10831066    /*
    1084      * Edit the txt.cfg file.
     1067     * Edit the menu config file file.
    10851068     */
    10861069    {
    10871070        GeneralTextScript Editor(mpParent);
    1088         HRESULT hrc = loadAndParseFileFromIso(hVfsOrgIso, pszIsoLinuxTxtCfg, &Editor);
     1071        HRESULT hrc = loadAndParseFileFromIso(hVfsOrgIso, pszMenuConfigFileName, &Editor);
    10891072        if (SUCCEEDED(hrc))
    1090             hrc = editDebianTxtCfg(&Editor);
     1073            hrc = editDebianMenuCfg(&Editor);
    10911074        if (SUCCEEDED(hrc))
    10921075        {
     
    11151098}
    11161099
    1117 HRESULT UnattendedDebianInstaller::editDebianTxtCfg(GeneralTextScript *pEditor)
     1100HRESULT 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
     1138HRESULT UnattendedDebianInstaller::editDebianMenuCfg(GeneralTextScript *pEditor)
    11181139{
    11191140    /*
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