VirtualBox

Changeset 94296 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 17, 2022 3:15:46 PM (3 years ago)
Author:
vboxsync
Message:

Main/Unattended: ​​bugref:9781. Detect OS type, version, and version of Debian Live ISOs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/UnattendedImpl.cpp

    r94136 r94296  
    13901390    }
    13911391    else if (    (   RTStrNICmp(pszOsAndVersion, RT_STR_TUPLE("Xubuntu")) == 0
    1392                   || RTStrNICmp(pszOsAndVersion, RT_STR_TUPLE("Kubuntu")) == 0)
     1392                  || RTStrNICmp(pszOsAndVersion, RT_STR_TUPLE("Kubuntu")) == 0
     1393                  || RTStrNICmp(pszOsAndVersion, RT_STR_TUPLE("Lubuntu")) == 0)
    13931394             && !RT_C_IS_ALNUM(pszOsAndVersion[7]))
    13941395    {
     
    14221423}
    14231424
     1425static bool detectLinuxDistroNameII(const char *pszOsAndVersion, VBOXOSTYPE *penmOsType, const char **ppszNext)
     1426{
     1427    bool fRet = true;
     1428    if (   RTStrIStr(pszOsAndVersion, "RedHat")  != NULL
     1429        || RTStrIStr(pszOsAndVersion, "Red Hat") != NULL)
     1430            *penmOsType = (VBOXOSTYPE)((*penmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_RedHat);
     1431    else if (RTStrIStr(pszOsAndVersion, "Oracle") != NULL)
     1432        *penmOsType = (VBOXOSTYPE)((*penmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_Oracle);
     1433    else if (RTStrIStr(pszOsAndVersion, "CentOS") != NULL)
     1434        *penmOsType = (VBOXOSTYPE)((*penmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_RedHat);
     1435    else if (RTStrIStr(pszOsAndVersion, "Fedora") != NULL)
     1436        *penmOsType = (VBOXOSTYPE)((*penmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_FedoraCore);
     1437    else if (RTStrIStr(pszOsAndVersion, "Ubuntu") != NULL)
     1438        *penmOsType = (VBOXOSTYPE)((*penmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_Ubuntu);
     1439    else if (RTStrIStr(pszOsAndVersion, "Debian"))
     1440        *penmOsType = (VBOXOSTYPE)((*penmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_Debian);
     1441    else
     1442        fRet = false;
     1443
     1444    /*
     1445     * Skip forward till we get a number.
     1446     */
     1447    if (ppszNext)
     1448    {
     1449        *ppszNext = pszOsAndVersion;
     1450        char ch;
     1451        for (const char *pszVersion = pszOsAndVersion; (ch = *pszVersion) != '\0'; pszVersion++)
     1452            if (RT_C_IS_DIGIT(ch))
     1453            {
     1454                *ppszNext = pszVersion;
     1455                break;
     1456            }
     1457    }
     1458    return fRet;
     1459}
    14241460
    14251461/**
     
    17521788     * Debian GNU/Linux 8.11.1 "Jessie" - Official amd64 CD Binary-1 20190211-02:10
    17531789     * Kali GNU/Linux 2021.3a "Kali-last-snapshot" - Official amd64 BD Binary-1 with firmware 20211015-16:55
     1790     * Official Debian GNU/Linux Live 10.10.0 cinnamon 2021-06-19T12:13
    17541791     */
    17551792    vrc = RTVfsFileOpen(hVfsIso, ".disk/info", RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN, &hVfsFile);
     
    17771814        }
    17781815
    1779         if (pszDiskName && pszArch)
     1816        /* Some Debian Live ISO's have info file content as follows:
     1817         * Official Debian GNU/Linux Live 10.10.0 cinnamon 2021-06-19T12:13
     1818         * thus  pszArch stays empty. Try Volume Id (label) if we get lucky and get architecture from that. */
     1819        if (!pszArch)
     1820        {
     1821            char szVolumeId[128];
     1822            size_t cchVolumeId;
     1823            vrc = RTVfsQueryLabel(hVfsIso, szVolumeId, 128, &cchVolumeId);
     1824            if (RT_SUCCESS(vrc))
     1825            {
     1826                if (!detectLinuxArchII(szVolumeId, &mEnmOsType, VBOXOSTYPE_Ubuntu))
     1827                    LogRel(("Unattended: .disk/info: Unknown: arch='%s'\n", pszArch));
     1828            }
     1829            else
     1830                LogRel(("Unattended: .disk/info No Volume Label found\n"));
     1831        }
     1832        else
    17801833        {
    17811834            if (!detectLinuxArchII(pszArch, &mEnmOsType, VBOXOSTYPE_Ubuntu))
    1782                 LogRel(("Unattended: README.diskdefines: Unknown: arch='%s'\n", pszArch));
    1783 
     1835                LogRel(("Unattended: .disk/info: Unknown: arch='%s'\n", pszArch));
     1836        }
     1837
     1838        if (pszDiskName)
     1839        {
    17841840            const char *pszVersion = NULL;
    1785             if (detectLinuxDistroName(pszDiskName, &mEnmOsType, &pszVersion))
     1841            if (detectLinuxDistroNameII(pszDiskName, &mEnmOsType, &pszVersion))
    17861842            {
    1787                 LogRelFlow(("Unattended: README.diskdefines: version=%s\n", pszVersion));
     1843                LogRelFlow(("Unattended: .disk/info: version=%s\n", pszVersion));
    17881844                try { mStrDetectedOSVersion = RTStrStripL(pszVersion); }
    17891845                catch (std::bad_alloc &) { return E_OUTOFMEMORY; }
    17901846            }
    17911847            else
    1792                 LogRel(("Unattended: README.diskdefines: Unknown: diskname='%s'\n", pszDiskName));
    1793         }
     1848                LogRel(("Unattended: .disk/info: Unknown: diskname='%s'\n", pszDiskName));
     1849        }
     1850
     1851        if (mEnmOsType == VBOXOSTYPE_Unknown)
     1852            LogRel(("Unattended: .disk/info: Did not find DISKNAME or/and ARCH. :-/\n"));
    17941853        else
    1795             LogRel(("Unattended: README.diskdefines: Did not find both DISKNAME and ARCH. :-/\n"));
    1796 
    1797         if (mEnmOsType != VBOXOSTYPE_Unknown)
    17981854            return S_FALSE;
    17991855    }
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