VirtualBox

Changeset 93954 in vbox


Ignore:
Timestamp:
Feb 25, 2022 2:34:34 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
150184
Message:

Main/Unattended: ​bugref:9781. Replacing VBOX_COND_GUEST_VERSION[exp] construct with VBOX_COND[exp] to utilize new expression functionality. Removing related code as well.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/UnattendedTemplates/ol_ks.cfg

    r87895 r93954  
    8282glibc-headers
    8383gcc
    84 @@VBOX_COND_GUEST_VERSION[>8.0.0]@@
     84@@VBOX_COND[${GUEST_OS_VERSION} vgt 8.0.0]@@
    8585elfutils-libelf-devel
    8686@@VBOX_COND_END@@
     
    107107umount /tmp/vboxcdrom
    108108%end
    109 
  • trunk/src/VBox/Main/UnattendedTemplates/ol_postinstall.sh

    r93115 r93954  
    202202log_command_in_target yum -y install binutils
    203203log_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]@@
    205205log_command_in_target yum -y install elfutils-libelf-devel
    206206@@VBOX_COND_END@@
     
    329329
    330330exit ${MY_EXITCODE}
    331 
  • trunk/src/VBox/Main/UnattendedTemplates/redhat67_ks.cfg

    r87895 r93954  
    8282glibc-headers
    8383gcc
    84 @@VBOX_COND_GUEST_VERSION[>8.0.0]@@
     84@@VBOX_COND[${GUEST_OS_VERSION} vgt 8.0.0]@@
    8585elfutils-libelf-devel
    8686@@VBOX_COND_END@@
     
    107107umount /tmp/vboxcdrom
    108108%end
    109 
  • trunk/src/VBox/Main/UnattendedTemplates/redhat_postinstall.sh

    r93115 r93954  
    190190log_command_in_target yum -y install binutils
    191191log_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]@@
    193193log_command_in_target yum -y install elfutils-libelf-devel
    194194@@VBOX_COND_END@@
     
    317317
    318318exit ${MY_EXITCODE}
    319 
  • trunk/src/VBox/Main/src-server/UnattendedScript.cpp

    r93920 r93954  
    5555static const char g_szPrefixCondEnd[]    = "@@VBOX_COND_END@@";
    5656static 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 then
    70  *                                sizeof(pachPlaceholder) - 3
    71  */
    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 }
    10757
    10858
     
    800750        (   cchPlaceholder == sizeof("@@VBOX_COND_" a_szMatch "@@") - 1U \
    801751         && 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)
    804752
    805753    /* Install Guest Additions: */
     
    845793    else if (IS_PLACEHOLDER_MATCH("HAS_PROXY"))
    846794        *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 == 0
    897             && (   pszComparisonOperator[0] == '='
    898                 || memcmp(pszComparisonOperator, ">=", 2) == 0
    899                 || 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         else
    906             *pfOutputting = false;
    907     }
    908795    else
    909796        return mpSetError->setErrorBoth(E_FAIL, VERR_NOT_FOUND, tr("Unknown conditional placeholder '%.*s'"),
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette