Changeset 93311 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jan 18, 2022 12:19:06 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/UnattendedImpl.cpp
r93285 r93311 843 843 } 844 844 845 /** 846 * Detects linux architecture by searching for the architecture substring in @p pszArch. 847 * 848 * @returns true if detected, false if not. 849 * @param pszArch The architecture string. 850 * @param penmOsType Where to return the arch and type on success. 851 * @param enmBaseOsType The base (x86) OS type to return. 852 */ 853 static bool detectLinuxArchII(const char *pszArch, VBOXOSTYPE *penmOsType, VBOXOSTYPE enmBaseOsType) 854 { 855 if ( RTStrIStr(pszArch, "amd64") != NULL 856 || RTStrIStr(pszArch, "x86_64") != NULL 857 || RTStrIStr(pszArch, "x86-64") != NULL /* just in case */ 858 || RTStrIStr(pszArch, "x64") != NULL /* ditto */ ) 859 { 860 *penmOsType = (VBOXOSTYPE)(enmBaseOsType | VBOXOSTYPE_x64); 861 return true; 862 } 863 864 if ( RTStrIStr(pszArch, "x86") != NULL 865 || RTStrIStr(pszArch, "i386") != NULL 866 || RTStrIStr(pszArch, "i486") != NULL 867 || RTStrIStr(pszArch, "i586") != NULL 868 || RTStrIStr(pszArch, "i686") != NULL 869 || RTStrIStr(pszArch, "i786") != NULL 870 || RTStrIStr(pszArch, "i886") != NULL 871 || RTStrIStr(pszArch, "i986") != NULL) 872 { 873 *penmOsType = enmBaseOsType; 874 return true; 875 } 876 return false; 877 } 878 845 879 static bool detectLinuxDistroName(const char *pszOsAndVersion, VBOXOSTYPE *penmOsType, const char **ppszNext) 846 880 { … … 891 925 *penmOsType = (VBOXOSTYPE)((*penmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_Ubuntu); 892 926 pszOsAndVersion = RTStrStripL(pszOsAndVersion + 7); 927 } 928 else if ( RTStrNICmp(pszOsAndVersion, RT_STR_TUPLE("Debian")) == 0 929 && !RT_C_IS_ALNUM(pszOsAndVersion[6])) 930 { 931 *penmOsType = (VBOXOSTYPE)((*penmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_Debian); 932 pszOsAndVersion = RTStrStripL(pszOsAndVersion + 6); 893 933 } 894 934 else … … 1000 1040 if (RT_SUCCESS(vrc)) 1001 1041 { 1002 RT_ZERO(*pBuf);1003 1042 size_t cchIgn; 1004 RTVfsFileRead(hVfsFile, pBuf->sz, sizeof(*pBuf) - 1, &cchIgn);1005 pBuf->sz[ sizeof(*pBuf) - 1] = '\0';1043 vrc = RTVfsFileRead(hVfsFile, pBuf->sz, sizeof(*pBuf) - 1, &cchIgn); 1044 pBuf->sz[RT_SUCCESS(vrc) ? cchIgn : 0] = '\0'; 1006 1045 RTVfsFileRelease(hVfsFile); 1007 1046 … … 1135 1174 if (RT_SUCCESS(vrc)) 1136 1175 { 1137 RT_ZERO(*pBuf);1138 1176 size_t cchIgn; 1139 RTVfsFileRead(hVfsFile, pBuf->sz, sizeof(*pBuf) - 1, &cchIgn);1140 pBuf->sz[ sizeof(*pBuf) - 1] = '\0';1177 vrc = RTVfsFileRead(hVfsFile, pBuf->sz, sizeof(*pBuf) - 1, &cchIgn); 1178 pBuf->sz[RT_SUCCESS(vrc) ? cchIgn : 0] = '\0'; 1141 1179 RTVfsFileRelease(hVfsFile); 1142 1180 … … 1208 1246 { 1209 1247 if (!detectLinuxArch(pszArch, penmOsType, VBOXOSTYPE_Ubuntu)) 1248 LogRel(("Unattended: README.diskdefines: Unknown: arch='%s'\n", pszArch)); 1249 1250 const char *pszVersion = NULL; 1251 if (detectLinuxDistroName(pszDiskName, penmOsType, &pszVersion)) 1252 { 1253 LogRelFlow(("Unattended: README.diskdefines: version=%s\n", pszVersion)); 1254 try { mStrDetectedOSVersion = RTStrStripL(pszVersion); } 1255 catch (std::bad_alloc &) { return E_OUTOFMEMORY; } 1256 } 1257 else 1258 LogRel(("Unattended: README.diskdefines: Unknown: diskname='%s'\n", pszDiskName)); 1259 } 1260 else 1261 LogRel(("Unattended: README.diskdefines: Did not find both DISKNAME and ARCH. :-/\n")); 1262 1263 if (*penmOsType != VBOXOSTYPE_Unknown) 1264 return S_FALSE; 1265 } 1266 1267 /* 1268 * All of the debian based distro versions I checked have a single line ./disk/info file. 1269 * Only info I could find related to .disk folder is: https://lists.debian.org/debian-cd/2004/01/msg00069.html 1270 * Some example content from several install ISOs is as follows: 1271 * Ubuntu 4.10 "Warty Warthog" - Preview amd64 Binary-1 (20041020) 1272 * Linux Mint 20.3 "Una" - Release amd64 20220104 1273 * Debian GNU/Linux 11.2.0 "Bullseye" - Official amd64 NETINST 20211218-11:12 1274 * Debian GNU/Linux 9.13.0 "Stretch" - Official amd64 DVD Binary-1 20200718-11:07 1275 * Xubuntu 20.04.2.0 LTS "Focal Fossa" - Release amd64 (20210209.1) 1276 * Ubuntu 17.10 "Artful Aardvark" - Release amd64 (20180105.1) 1277 * Ubuntu 16.04.6 LTS "Xenial Xerus" - Release i386 (20190227.1) 1278 * Debian GNU/Linux 8.11.1 "Jessie" - Official amd64 CD Binary-1 20190211-02:10 1279 * Kali GNU/Linux 2021.3a "Kali-last-snapshot" - Official amd64 BD Binary-1 with firmware 20211015-16:55 1280 */ 1281 vrc = RTVfsFileOpen(hVfsIso, ".disk/info", RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN, &hVfsFile); 1282 if (RT_SUCCESS(vrc)) 1283 { 1284 size_t cchIgn; 1285 vrc = RTVfsFileRead(hVfsFile, pBuf->sz, sizeof(*pBuf) - 1, &cchIgn); 1286 pBuf->sz[RT_SUCCESS(vrc) ? cchIgn : 0] = '\0'; 1287 1288 pBuf->sz[sizeof(*pBuf) - 1] = '\0'; 1289 RTVfsFileRelease(hVfsFile); 1290 1291 char *psz = pBuf->sz; 1292 char *pszDiskName = psz; 1293 char *pszArch = NULL; 1294 1295 /* Only care about the first line of the file even if it is multi line and assume disk name ended with ' - '.*/ 1296 psz = RTStrStr(pBuf->sz, " - "); 1297 if (psz && memchr(pBuf->sz, '\n', (size_t)(psz - pBuf->sz)) == NULL) 1298 { 1299 *psz = '\0'; 1300 psz += 3; 1301 if (*psz) 1302 pszArch = psz; 1303 } 1304 1305 if (pszDiskName && pszArch) 1306 { 1307 if (!detectLinuxArchII(pszArch, penmOsType, VBOXOSTYPE_Ubuntu)) 1210 1308 LogRel(("Unattended: README.diskdefines: Unknown: arch='%s'\n", pszArch)); 1211 1309 … … 3116 3214 return false; 3117 3215 } 3118
Note:
See TracChangeset
for help on using the changeset viewer.