Changeset 93365 in vbox for trunk/src/VBox
- Timestamp:
- Jan 20, 2022 1:11:45 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/UnattendedImpl.cpp
r93358 r93365 988 988 if (RT_FAILURE(vrc) || !pBuf->sz[0]) 989 989 vrc = RTIniFileQueryValue(hIniFile, "general", "arch", pBuf->sz, sizeof(*pBuf), NULL); 990 if (RT_SUCCESS(vrc)) 990 if (RT_FAILURE(vrc)) 991 LogRel(("Unattended: .treeinfo: No 'arch' property.\n")); 992 else 991 993 { 992 994 LogRelFlow(("Unattended: .treeinfo: arch=%s\n", pBuf->sz)); 993 if (!detectLinuxArch(pBuf->sz, penmOsType, VBOXOSTYPE_RedHat)) 995 if (detectLinuxArch(pBuf->sz, penmOsType, VBOXOSTYPE_RedHat)) 996 { 997 /* Try figure the release name, it doesn't have to be redhat. */ 998 vrc = RTIniFileQueryValue(hIniFile, "release", "name", pBuf->sz, sizeof(*pBuf), NULL); 999 if (RT_FAILURE(vrc) || !pBuf->sz[0]) 1000 vrc = RTIniFileQueryValue(hIniFile, "product", "name", pBuf->sz, sizeof(*pBuf), NULL); 1001 if (RT_FAILURE(vrc) || !pBuf->sz[0]) 1002 vrc = RTIniFileQueryValue(hIniFile, "general", "family", pBuf->sz, sizeof(*pBuf), NULL); 1003 if (RT_SUCCESS(vrc)) 1004 { 1005 LogRelFlow(("Unattended: .treeinfo: name/family=%s\n", pBuf->sz)); 1006 if (!detectLinuxDistroName(pBuf->sz, penmOsType, NULL)) 1007 { 1008 LogRel(("Unattended: .treeinfo: Unknown: name/family='%s', assuming Red Hat\n", pBuf->sz)); 1009 *penmOsType = (VBOXOSTYPE)((*penmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_RedHat); 1010 } 1011 } 1012 1013 /* Try figure the version. */ 1014 vrc = RTIniFileQueryValue(hIniFile, "release", "version", pBuf->sz, sizeof(*pBuf), NULL); 1015 if (RT_FAILURE(vrc) || !pBuf->sz[0]) 1016 vrc = RTIniFileQueryValue(hIniFile, "product", "version", pBuf->sz, sizeof(*pBuf), NULL); 1017 if (RT_FAILURE(vrc) || !pBuf->sz[0]) 1018 vrc = RTIniFileQueryValue(hIniFile, "general", "version", pBuf->sz, sizeof(*pBuf), NULL); 1019 if (RT_SUCCESS(vrc)) 1020 { 1021 LogRelFlow(("Unattended: .treeinfo: version=%s\n", pBuf->sz)); 1022 try { mStrDetectedOSVersion = RTStrStrip(pBuf->sz); } 1023 catch (std::bad_alloc &) { return E_OUTOFMEMORY; } 1024 } 1025 } 1026 else 994 1027 LogRel(("Unattended: .treeinfo: Unknown: arch='%s'\n", pBuf->sz)); 995 }996 else997 LogRel(("Unattended: .treeinfo: No 'arch' property.\n"));998 999 /* Try figure the release name, it doesn't have to be redhat. */1000 vrc = RTIniFileQueryValue(hIniFile, "release", "name", pBuf->sz, sizeof(*pBuf), NULL);1001 if (RT_FAILURE(vrc) || !pBuf->sz[0])1002 vrc = RTIniFileQueryValue(hIniFile, "product", "name", pBuf->sz, sizeof(*pBuf), NULL);1003 if (RT_FAILURE(vrc) || !pBuf->sz[0])1004 vrc = RTIniFileQueryValue(hIniFile, "general", "family", pBuf->sz, sizeof(*pBuf), NULL);1005 if (RT_SUCCESS(vrc))1006 {1007 LogRelFlow(("Unattended: .treeinfo: name/family=%s\n", pBuf->sz));1008 if (!detectLinuxDistroName(pBuf->sz, penmOsType, NULL))1009 {1010 LogRel(("Unattended: .treeinfo: Unknown: name/family='%s', assuming Red Hat\n", pBuf->sz));1011 *penmOsType = (VBOXOSTYPE)((*penmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_RedHat);1012 }1013 }1014 1015 /* Try figure the version. */1016 vrc = RTIniFileQueryValue(hIniFile, "release", "version", pBuf->sz, sizeof(*pBuf), NULL);1017 if (RT_FAILURE(vrc) || !pBuf->sz[0])1018 vrc = RTIniFileQueryValue(hIniFile, "product", "version", pBuf->sz, sizeof(*pBuf), NULL);1019 if (RT_FAILURE(vrc) || !pBuf->sz[0])1020 vrc = RTIniFileQueryValue(hIniFile, "general", "version", pBuf->sz, sizeof(*pBuf), NULL);1021 if (RT_SUCCESS(vrc))1022 {1023 LogRelFlow(("Unattended: .treeinfo: version=%s\n", pBuf->sz));1024 try { mStrDetectedOSVersion = RTStrStrip(pBuf->sz); }1025 catch (std::bad_alloc &) { return E_OUTOFMEMORY; }1026 1028 } 1027 1029 … … 1067 1069 /* Do we recognize the architecture? */ 1068 1070 LogRelFlow(("Unattended: .discinfo: arch=%s\n", apszLines[2])); 1069 if (!detectLinuxArch(apszLines[2], penmOsType, VBOXOSTYPE_RedHat)) 1071 if (detectLinuxArch(apszLines[2], penmOsType, VBOXOSTYPE_RedHat)) 1072 { 1073 /* Do we recognize the release string? */ 1074 LogRelFlow(("Unattended: .discinfo: product+version=%s\n", apszLines[1])); 1075 const char *pszVersion = NULL; 1076 if (!detectLinuxDistroName(apszLines[1], penmOsType, &pszVersion)) 1077 LogRel(("Unattended: .discinfo: Unknown: release='%s'\n", apszLines[1])); 1078 1079 if (*pszVersion) 1080 { 1081 LogRelFlow(("Unattended: .discinfo: version=%s\n", pszVersion)); 1082 try { mStrDetectedOSVersion = RTStrStripL(pszVersion); } 1083 catch (std::bad_alloc &) { return E_OUTOFMEMORY; } 1084 1085 /* CentOS likes to call their release 'Final' without mentioning the actual version 1086 number (e.g. CentOS-4.7-x86_64-binDVD.iso), so we need to go look elsewhere. 1087 This is only important for centos 4.x and 3.x releases. */ 1088 if (RTStrNICmp(pszVersion, RT_STR_TUPLE("Final")) == 0) 1089 { 1090 static const char * const s_apszDirs[] = { "CentOS/RPMS/", "RedHat/RPMS", "Server", "Workstation" }; 1091 for (unsigned iDir = 0; iDir < RT_ELEMENTS(s_apszDirs); iDir++) 1092 { 1093 RTVFSDIR hVfsDir; 1094 vrc = RTVfsDirOpen(hVfsIso, s_apszDirs[iDir], 0, &hVfsDir); 1095 if (RT_FAILURE(vrc)) 1096 continue; 1097 char szRpmDb[128]; 1098 char szReleaseRpm[128]; 1099 szRpmDb[0] = '\0'; 1100 szReleaseRpm[0] = '\0'; 1101 for (;;) 1102 { 1103 RTDIRENTRYEX DirEntry; 1104 size_t cbDirEntry = sizeof(DirEntry); 1105 vrc = RTVfsDirReadEx(hVfsDir, &DirEntry, &cbDirEntry, RTFSOBJATTRADD_NOTHING); 1106 if (RT_FAILURE(vrc)) 1107 break; 1108 1109 /* redhat-release-4WS-2.4.i386.rpm 1110 centos-release-4-7.x86_64.rpm, centos-release-4-4.3.i386.rpm 1111 centos-release-5-3.el5.centos.1.x86_64.rpm */ 1112 if ( (psz = strstr(DirEntry.szName, "-release-")) != NULL 1113 || (psz = strstr(DirEntry.szName, "-RELEASE-")) != NULL) 1114 { 1115 psz += 9; 1116 if (RT_C_IS_DIGIT(*psz)) 1117 RTStrCopy(szReleaseRpm, sizeof(szReleaseRpm), psz); 1118 } 1119 /* rpmdb-redhat-4WS-2.4.i386.rpm, 1120 rpmdb-CentOS-4.5-0.20070506.i386.rpm, 1121 rpmdb-redhat-3.9-0.20070703.i386.rpm. */ 1122 else if ( ( RTStrStartsWith(DirEntry.szName, "rpmdb-") 1123 || RTStrStartsWith(DirEntry.szName, "RPMDB-")) 1124 && RT_C_IS_DIGIT(DirEntry.szName[6]) ) 1125 RTStrCopy(szRpmDb, sizeof(szRpmDb), &DirEntry.szName[6]); 1126 } 1127 RTVfsDirRelease(hVfsDir); 1128 1129 /* Did we find anything relvant? */ 1130 psz = szRpmDb; 1131 if (!RT_C_IS_DIGIT(*psz)) 1132 psz = szReleaseRpm; 1133 if (RT_C_IS_DIGIT(*psz)) 1134 { 1135 /* Convert '-' to '.' and strip stuff which doesn't look like a version string. */ 1136 char *pszCur = psz + 1; 1137 for (char ch = *pszCur; ch != '\0'; ch = *++pszCur) 1138 if (ch == '-') 1139 *pszCur = '.'; 1140 else if (ch != '.' && !RT_C_IS_DIGIT(ch)) 1141 { 1142 *pszCur = '\0'; 1143 break; 1144 } 1145 while (&pszCur[-1] != psz && pszCur[-1] == '.') 1146 *--pszCur = '\0'; 1147 1148 /* Set it and stop looking. */ 1149 try { mStrDetectedOSVersion = psz; } 1150 catch (std::bad_alloc &) { return E_OUTOFMEMORY; } 1151 break; 1152 } 1153 } 1154 } 1155 } 1156 } 1157 else 1070 1158 LogRel(("Unattended: .discinfo: Unknown: arch='%s'\n", apszLines[2])); 1071 1072 /* Do we recognize the release string? */1073 LogRelFlow(("Unattended: .discinfo: product+version=%s\n", apszLines[1]));1074 const char *pszVersion = NULL;1075 if (!detectLinuxDistroName(apszLines[1], penmOsType, &pszVersion))1076 LogRel(("Unattended: .discinfo: Unknown: release='%s'\n", apszLines[1]));1077 1078 if (*pszVersion)1079 {1080 LogRelFlow(("Unattended: .discinfo: version=%s\n", pszVersion));1081 try { mStrDetectedOSVersion = RTStrStripL(pszVersion); }1082 catch (std::bad_alloc &) { return E_OUTOFMEMORY; }1083 1084 /* CentOS likes to call their release 'Final' without mentioning the actual version1085 number (e.g. CentOS-4.7-x86_64-binDVD.iso), so we need to go look elsewhere.1086 This is only important for centos 4.x and 3.x releases. */1087 if (RTStrNICmp(pszVersion, RT_STR_TUPLE("Final")) == 0)1088 {1089 static const char * const s_apszDirs[] = { "CentOS/RPMS/", "RedHat/RPMS", "Server", "Workstation" };1090 for (unsigned iDir = 0; iDir < RT_ELEMENTS(s_apszDirs); iDir++)1091 {1092 RTVFSDIR hVfsDir;1093 vrc = RTVfsDirOpen(hVfsIso, s_apszDirs[iDir], 0, &hVfsDir);1094 if (RT_FAILURE(vrc))1095 continue;1096 char szRpmDb[128];1097 char szReleaseRpm[128];1098 szRpmDb[0] = '\0';1099 szReleaseRpm[0] = '\0';1100 for (;;)1101 {1102 RTDIRENTRYEX DirEntry;1103 size_t cbDirEntry = sizeof(DirEntry);1104 vrc = RTVfsDirReadEx(hVfsDir, &DirEntry, &cbDirEntry, RTFSOBJATTRADD_NOTHING);1105 if (RT_FAILURE(vrc))1106 break;1107 1108 /* redhat-release-4WS-2.4.i386.rpm1109 centos-release-4-7.x86_64.rpm, centos-release-4-4.3.i386.rpm1110 centos-release-5-3.el5.centos.1.x86_64.rpm */1111 if ( (psz = strstr(DirEntry.szName, "-release-")) != NULL1112 || (psz = strstr(DirEntry.szName, "-RELEASE-")) != NULL)1113 {1114 psz += 9;1115 if (RT_C_IS_DIGIT(*psz))1116 RTStrCopy(szReleaseRpm, sizeof(szReleaseRpm), psz);1117 }1118 /* rpmdb-redhat-4WS-2.4.i386.rpm,1119 rpmdb-CentOS-4.5-0.20070506.i386.rpm,1120 rpmdb-redhat-3.9-0.20070703.i386.rpm. */1121 else if ( ( RTStrStartsWith(DirEntry.szName, "rpmdb-")1122 || RTStrStartsWith(DirEntry.szName, "RPMDB-"))1123 && RT_C_IS_DIGIT(DirEntry.szName[6]) )1124 RTStrCopy(szRpmDb, sizeof(szRpmDb), &DirEntry.szName[6]);1125 }1126 RTVfsDirRelease(hVfsDir);1127 1128 /* Did we find anything relvant? */1129 psz = szRpmDb;1130 if (!RT_C_IS_DIGIT(*psz))1131 psz = szReleaseRpm;1132 if (RT_C_IS_DIGIT(*psz))1133 {1134 /* Convert '-' to '.' and strip stuff which doesn't look like a version string. */1135 char *pszCur = psz + 1;1136 for (char ch = *pszCur; ch != '\0'; ch = *++pszCur)1137 if (ch == '-')1138 *pszCur = '.';1139 else if (ch != '.' && !RT_C_IS_DIGIT(ch))1140 {1141 *pszCur = '\0';1142 break;1143 }1144 while (&pszCur[-1] != psz && pszCur[-1] == '.')1145 *--pszCur = '\0';1146 1147 /* Set it and stop looking. */1148 try { mStrDetectedOSVersion = psz; }1149 catch (std::bad_alloc &) { return E_OUTOFMEMORY; }1150 break;1151 }1152 }1153 }1154 }1155 1159 1156 1160 if (*penmOsType != VBOXOSTYPE_Unknown) … … 1245 1249 if (pszDiskName && pszArch) 1246 1250 { 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)) 1251 if (detectLinuxArch(pszArch, penmOsType, VBOXOSTYPE_Ubuntu)) 1252 1252 { 1253 LogRelFlow(("Unattended: README.diskdefines: version=%s\n", pszVersion)); 1254 try { mStrDetectedOSVersion = RTStrStripL(pszVersion); } 1255 catch (std::bad_alloc &) { return E_OUTOFMEMORY; } 1253 const char *pszVersion = NULL; 1254 if (detectLinuxDistroName(pszDiskName, penmOsType, &pszVersion)) 1255 { 1256 LogRelFlow(("Unattended: README.diskdefines: version=%s\n", pszVersion)); 1257 try { mStrDetectedOSVersion = RTStrStripL(pszVersion); } 1258 catch (std::bad_alloc &) { return E_OUTOFMEMORY; } 1259 } 1260 else 1261 LogRel(("Unattended: README.diskdefines: Unknown: diskname='%s'\n", pszDiskName)); 1256 1262 } 1257 1263 else 1258 LogRel(("Unattended: README.diskdefines: Unknown: diskname='%s'\n", pszDiskName));1264 LogRel(("Unattended: README.diskdefines: Unknown: arch='%s'\n", pszArch)); 1259 1265 } 1260 1266 else
Note:
See TracChangeset
for help on using the changeset viewer.