VirtualBox

Changeset 93584 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 3, 2022 2:49:19 PM (3 years ago)
Author:
vboxsync
Message:

Main/Unattended: Update detectedOS* attributes when setting imageIndex and we've detectedImages info handy. Ditto for prepare() and detectIsoOS(). Parse LANGUAGES from the XML data in install.xim. Stop windows detection if we seems to have found the necessary info in the XML section of install.wim. bugref:9781

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r93561 r93584  
    48994899        one of the indices of <link to="IUnattended::detectedImageIndices"/>.
    49004900
     4901        Changing this after ISO detection may cause
     4902        <link to="IUnattended::detectedOSTypeId"/>, <link to="IUnattended::detectedOSVersion"/>,
     4903        <link to="IUnattended::detectedOSFlavor"/>, <link to="IUnattended::detectedOSLanguages"/>,
     4904        and <link to="IUnattended::detectedOSHints"/> to be updated with values
     4905        specific to the selected image.
     4906
    49014907        Used only with Windows installation CD/DVD:
    49024908        https://technet.microsoft.com/en-us/library/cc766022%28v=ws.10%29.aspx
     
    50375043        Prepare for running the unattended process of installation.
    50385044
    5039         This will instantiate the installer based on the guest type associated
    5040         with the machine (see <link to="IMachine::OSTypeId"/>).  It will also
    5041         perform <link to="IUnattended::detectIsoOS"/> if not yet called on the
    5042         current <link to="IUnattended::isoPath"/> value.
     5045        This will perform <link to="IUnattended::detectIsoOS"/> if not yet called on the
     5046        current <link to="IUnattended::isoPath"/> value.  It may then may cause
     5047        <link to="IUnattended::detectedOSTypeId"/>, <link to="IUnattended::detectedOSVersion"/>,
     5048        <link to="IUnattended::detectedOSFlavor"/>, <link to="IUnattended::detectedOSLanguages"/>,
     5049        and <link to="IUnattended::detectedOSHints"/> to be updated with values
     5050        specific to the image selected by <link to="IUnattended::imageIndex"/> if the ISO
     5051        contains images.
     5052
     5053        This method will then instantiate the installer based on the detected guest type
     5054        (see <link to="IUnattended::detectedOSTypeId"/>).
    50435055      </desc>
    50445056    </method>
  • trunk/src/VBox/Main/include/UnattendedImpl.h

    r93581 r93584  
    287287     */
    288288    bool i_isGuestOSArchX64(Utf8Str const &rStrGuestOsTypeId);
     289
     290    /**
     291     * Updates the detected attributes when the image index or image list changes.
     292     *
     293     * @returns true if we've got all necessary stuff for a successful detection.
     294     */
     295    bool i_updateDetectedAttributeForImage(WIMImage const &rImage);
     296
    289297};
    290298
  • trunk/src/VBox/Main/src-server/UnattendedImpl.cpp

    r93581 r93584  
    551551        {
    552552            rImage.mArch   = s_aArches[uArch].pszArch;
    553             rImage.mOSType = (VBOXOSTYPE)(s_aArches[uArch].enmArch | (rImage.mOSType & VBOXOSTYPE_ArchitectureMask));
     553            rImage.mOSType = (VBOXOSTYPE)(s_aArches[uArch].enmArch | (rImage.mOSType & VBOXOSTYPE_OsTypeMask));
    554554        }
    555555        else
     
    765765    // sources/lang.ini       - ditto.
    766766
     767    /*
     768     * The install.wim file contains an XML document describing the install
     769     * images it contains.  This includes all the info we need for a successful
     770     * detection.
     771     */
    767772    RTVFSFILE hVfsFile;
    768     /** @todo look at the install.wim file too, extracting the XML (easy) and
    769      *        figure out the available image numbers and such. The format is
    770      *        documented. It would also provide really accurate Windows
    771      *        version information without the need to guess. The current
    772      *        content of mStrDetectedOSVersion is mostly useful for human
    773      *        consumption. ~~Long term it should be possible to have version
    774      *        conditionals (expr style, please) in the templates, which
    775      *        would make them a lot easier to write and more flexible at the
    776      *        same time. - done already~~
    777      *
    778      * Here is how to list images inside an install.wim file from powershell:
    779      * https://docs.microsoft.com/en-us/powershell/module/dism/get-windowsimage?view=windowsserver2022-ps
    780      *
    781      * Unfortunately, powershell is not available by default on non-windows hosts, so we
    782      * have to do it ourselves of course, but this can help when coding & testing.
    783      */
    784 
    785773    int vrc = RTVfsFileOpen(hVfsIso, "sources/install.wim", RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN, &hVfsFile);
    786774    if (RT_SUCCESS(vrc))
     
    839827                                try
    840828                                {
     829                                    mDetectedImages.clear(); /* debugging convenience  */
    841830                                    parseWimXMLData(pElmRoot, mDetectedImages);
    842831                                }
     
    844833                                {
    845834                                    vrc = VERR_NO_MEMORY;
     835                                }
     836
     837                                /*
     838                                 * If we found images, update the detected info attributes.
     839                                 */
     840                                if (RT_SUCCESS(vrc) && mDetectedImages.size() > 0)
     841                                {
     842                                    size_t i;
     843                                    for (i = 0; i < mDetectedImages.size(); i++)
     844                                        if (mDetectedImages[i].mImageIndex == midxImage)
     845                                            break;
     846                                    if (i >= mDetectedImages.size())
     847                                        i = 0; /* use the first one if midxImage wasn't found */
     848                                    if (i_updateDetectedAttributeForImage(mDetectedImages[i]))
     849                                    {
     850                                        LogRel2(("Unattended: happy with mDetectedImages[%u]\n", i));
     851                                        *penmOsType = mDetectedImages[i].mOSType;
     852                                        return S_OK;
     853                                    }
    846854                                }
    847855                            }
     
    21712179            if (midxImage == mDetectedImages[i].mImageIndex)
    21722180            {
     2181                i_updateDetectedAttributeForImage(mDetectedImages[i]);
    21732182                fImageFound = true;
    2174                 /** @todo Replace / amend the detected version? */
    21752183                break;
    21762184            }
     
    33413349    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    33423350    AssertReturn(mpInstaller == NULL, setErrorBoth(E_FAIL, VERR_WRONG_ORDER, tr("Cannot change after prepare() has been called")));
     3351
     3352    /* Validate the selection if detection was done already: */
     3353    if (mDetectedImages.size() > 0)
     3354    {
     3355        for (size_t i = 0; i < mDetectedImages.size(); i++)
     3356            if (mDetectedImages[i].mImageIndex == index)
     3357            {
     3358                midxImage = index;
     3359                i_updateDetectedAttributeForImage(mDetectedImages[i]);
     3360                return S_OK;
     3361            }
     3362        LogRel(("Unattended: Setting invalid index=%u\n", index)); /** @todo fail? */
     3363    }
     3364
    33433365    midxImage = index;
    33443366    return S_OK;
     
    37363758    return false;
    37373759}
     3760
     3761
     3762bool Unattended::i_updateDetectedAttributeForImage(WIMImage const &rImage)
     3763{
     3764    bool fRet = true;
     3765
     3766    /*
     3767     * If the image doesn't have a valid value, we don't change it.
     3768     * This is obviously a little bit bogus, but what can we do...
     3769     */
     3770    const char *pszOSTypeId = Global::OSTypeId(rImage.mOSType);
     3771    if (pszOSTypeId && strcmp(pszOSTypeId, "Other") != 0)
     3772        mStrDetectedOSTypeId = pszOSTypeId;
     3773    else
     3774        fRet = false;
     3775
     3776    if (rImage.mVersion.isNotEmpty())
     3777        mStrDetectedOSVersion = rImage.mVersion;
     3778    else
     3779        fRet = false;
     3780
     3781    if (rImage.mLanguages.size() > 0)
     3782        mDetectedOSLanguages  = rImage.mLanguages;
     3783    else
     3784        fRet = false;
     3785
     3786    return fRet;
     3787}
     3788
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