Changeset 93954 in vbox
- Timestamp:
- Feb 25, 2022 2:34:34 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 150184
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/UnattendedTemplates/ol_ks.cfg
r87895 r93954 82 82 glibc-headers 83 83 gcc 84 @@VBOX_COND _GUEST_VERSION[>8.0.0]@@84 @@VBOX_COND[${GUEST_OS_VERSION} vgt 8.0.0]@@ 85 85 elfutils-libelf-devel 86 86 @@VBOX_COND_END@@ … … 107 107 umount /tmp/vboxcdrom 108 108 %end 109 -
trunk/src/VBox/Main/UnattendedTemplates/ol_postinstall.sh
r93115 r93954 202 202 log_command_in_target yum -y install binutils 203 203 log_command_in_target yum -y install make 204 @@VBOX_COND _GUEST_VERSION[>8.0.0]@@204 @@VBOX_COND[${GUEST_OS_VERSION} vgt 8.0.0]@@ 205 205 log_command_in_target yum -y install elfutils-libelf-devel 206 206 @@VBOX_COND_END@@ … … 329 329 330 330 exit ${MY_EXITCODE} 331 -
trunk/src/VBox/Main/UnattendedTemplates/redhat67_ks.cfg
r87895 r93954 82 82 glibc-headers 83 83 gcc 84 @@VBOX_COND _GUEST_VERSION[>8.0.0]@@84 @@VBOX_COND[${GUEST_OS_VERSION} vgt 8.0.0]@@ 85 85 elfutils-libelf-devel 86 86 @@VBOX_COND_END@@ … … 107 107 umount /tmp/vboxcdrom 108 108 %end 109 -
trunk/src/VBox/Main/UnattendedTemplates/redhat_postinstall.sh
r93115 r93954 190 190 log_command_in_target yum -y install binutils 191 191 log_command_in_target yum -y install make 192 @@VBOX_COND _GUEST_VERSION[>8.0.0]@@192 @@VBOX_COND[${GUEST_OS_VERSION} vgt 8.0.0]@@ 193 193 log_command_in_target yum -y install elfutils-libelf-devel 194 194 @@VBOX_COND_END@@ … … 317 317 318 318 exit ${MY_EXITCODE} 319 -
trunk/src/VBox/Main/src-server/UnattendedScript.cpp
r93920 r93954 55 55 static const char g_szPrefixCondEnd[] = "@@VBOX_COND_END@@"; 56 56 static const char g_szPrefixSplitter[] = "@@VBOX_SPLITTER"; 57 58 59 /*********************************************************************************************************************************60 * Static Functions *61 *********************************************************************************************************************************/62 63 /**64 * Searches comparison operators'<', '<=', '>', '>=', or '=' in string.65 *66 * @returns true if detected, false if not.67 * @param pszComparisonOperator Comparison operators string array. Assumed to be of size 3,68 * @param pachPlaceholder The string array in which we search the comparison operators,69 * @param startPos The position with in the pachPlaceholder from where the seach starts. Required to be smaller then70 * sizeof(pachPlaceholder) - 371 */72 73 static bool detectComparisonOperator(char *pszComparisonOperator, const char *pachPlaceholder, size_t &startPos)74 {75 memset(pszComparisonOperator, '\0', 3);76 /* Search for '>', '<', '>=', '<=', '='. */77 if (pachPlaceholder[startPos] == '<')78 {79 pszComparisonOperator[0] = '<';80 ++startPos;81 if (pachPlaceholder[startPos] == '=')82 {83 pszComparisonOperator[1] = '=';84 ++startPos;85 }86 return true;87 }88 if (pachPlaceholder[startPos] == '>')89 {90 pszComparisonOperator[0] = '>';91 ++startPos;92 if (pachPlaceholder[startPos] == '=')93 {94 pszComparisonOperator[1] = '=';95 ++startPos;96 }97 return true;98 }99 else if (pachPlaceholder[startPos] == '=')100 {101 pszComparisonOperator[0] = '=';102 ++startPos;103 return true;104 }105 return false;106 }107 57 108 58 … … 800 750 ( cchPlaceholder == sizeof("@@VBOX_COND_" a_szMatch "@@") - 1U \ 801 751 && memcmp(pachPlaceholder, "@@VBOX_COND_" a_szMatch "@@", sizeof("@@VBOX_COND_" a_szMatch "@@") - 1U) == 0) 802 #define IS_PLACEHOLDER_PARTIALLY_MATCH(a_szMatch) \803 (memcmp(pachPlaceholder, "@@VBOX_COND_" a_szMatch, sizeof("@@VBOX_COND_" a_szMatch) - 1U) == 0)804 752 805 753 /* Install Guest Additions: */ … … 845 793 else if (IS_PLACEHOLDER_MATCH("HAS_PROXY")) 846 794 *pfOutputting = mpUnattended->i_getProxy().isNotEmpty(); 847 else if (IS_PLACEHOLDER_PARTIALLY_MATCH("GUEST_VERSION["))848 {849 /* Check the passed string against format @@VBOX_COND_GUEST_VERSION[>8.04.0]@@. Allowed comparison operators are:850 * '<', '<=', '>', '>=', or '=' in string. No spaces are allowed in anywhere of the expr. */851 static const char s_szTail[] = "]@@";852 size_t endLength = sizeof(s_szTail) - 1;853 if (memcmp(&pachPlaceholder[cchPlaceholder - endLength], RT_STR_TUPLE(s_szTail)) != 0)854 {855 *pfOutputting = false;856 return mpSetError->setErrorBoth(E_FAIL, VERR_PARSE_ERROR, tr("Malformed @@VBOX_COND_GUEST_VERSION[expr]@@: Missing ']' (%.*s)"),857 cchPlaceholder, pachPlaceholder);858 }859 size_t startPos = sizeof("@@VBOX_COND_GUEST_VERSION[") - 1;860 size_t endPos = cchPlaceholder - endLength;861 if (startPos >= endPos)862 {863 *pfOutputting = false;864 return mpSetError->setErrorBoth(E_FAIL, VERR_PARSE_ERROR, tr("Malformed @@VBOX_COND_GUEST_VERSION[expr]@@: Missing expr (%.*s)"),865 cchPlaceholder, pachPlaceholder);866 }867 /* Parse for the comparison operator. Assuming the expression starts with one of the allowed operators. */868 char pszComparisonOperator[3];869 if (!detectComparisonOperator(pszComparisonOperator, pachPlaceholder, startPos))870 {871 *pfOutputting = false;872 return mpSetError->setErrorBoth(E_FAIL, VERR_PARSE_ERROR, tr("Malformed @@VBOX_COND_GUEST_VERSION[expr]@@: Only space, '>', '>=', '<', <=', and '=' are allowed at the start. (%.*s)"),873 cchPlaceholder, pachPlaceholder);874 }875 if (startPos >= endPos)876 {877 *pfOutputting = false;878 return mpSetError->setErrorBoth(E_FAIL, VERR_PARSE_ERROR, tr("Malformed @@VBOX_COND_GUEST_VERSION[expr]@@: No version string found. (%.*s)"),879 cchPlaceholder, pachPlaceholder);880 }881 /* Check if the version string includes any character other than '.' and digits. */882 for (size_t i = startPos; i < endPos; ++i)883 {884 if ( (pachPlaceholder[i] < '0' || pachPlaceholder[i] > '9') && pachPlaceholder[i] != '.')885 {886 *pfOutputting = false;887 return mpSetError->setErrorBoth(E_FAIL, VERR_PARSE_ERROR, tr("Malformed @@VBOX_COND_GUEST_VERSION[expr]@@: Version string must be consist of only digits and '.', and no spaces. (%.*s)"),888 cchPlaceholder, pachPlaceholder);889 }890 }891 892 RTCString strRequiredOSVersion(pachPlaceholder, startPos, endPos - startPos);893 RTCString strDetectedOSVersion = mpUnattended->i_getDetectedOSVersion();894 int res = RTStrVersionCompare(strDetectedOSVersion.c_str(), strRequiredOSVersion.c_str());895 896 if ( res == 0897 && ( pszComparisonOperator[0] == '='898 || memcmp(pszComparisonOperator, ">=", 2) == 0899 || memcmp(pszComparisonOperator, "<=", 2) == 0))900 *pfOutputting = true;901 else if (res < 0 && pszComparisonOperator[0] == '<')902 *pfOutputting = true;903 else if (res > 0 && pszComparisonOperator[0] == '>')904 *pfOutputting = true;905 else906 *pfOutputting = false;907 }908 795 else 909 796 return mpSetError->setErrorBoth(E_FAIL, VERR_NOT_FOUND, tr("Unknown conditional placeholder '%.*s'"),
Note:
See TracChangeset
for help on using the changeset viewer.