VirtualBox

Changeset 68071 in vbox


Ignore:
Timestamp:
Jul 20, 2017 4:24:08 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
117104
Message:

Unattended: Split out the post installation script into a separate file. Dropped the IUnattended::loadSettings method, don't see much point. Simplified the script editor classes, moving the default filenames and templates to the installer constructor, allowing us to avoid having to 'new' the script editors. The editors are now direct members of UnattendedInstaller.

Location:
trunk/src/VBox
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r68055 r68071  
    12861286    int         fInstallTxs             = -1;
    12871287    const char *pszMachineName          = NULL;
    1288     Utf8Str     strAbsSettingsFile;
    1289     const char *pszSettingsFile         = NULL;
    12901288    bool        fSetImageIdx            = false;
    12911289    uint32_t    idxImage                = 0;
     
    12951293    Utf8Str     strAbsScriptTemplatePath;
    12961294    const char *pszScriptTemplatePath   = NULL;
     1295    Utf8Str     strAbsPostInstallScriptTemplatePath;
     1296    const char *pszPostInstallScriptTemplatePath = NULL;
    12971297    const char *pszSessionType          = "headless";
    12981298
     
    13191319        { "--image-index",              'm', RTGETOPT_REQ_UINT32 },
    13201320        { "--script-template",          'c', RTGETOPT_REQ_STRING },
     1321        { "--post-install-template",    'C', RTGETOPT_REQ_STRING },
    13211322        { "--post-install-command",     'P', RTGETOPT_REQ_STRING },
    1322         { "--settings-file",            's', RTGETOPT_REQ_STRING },
    13231323        { "--session-type",             'S', RTGETOPT_REQ_STRING },
    13241324    };
     
    13421342                break;
    13431343
    1344             case 's':   // --settings-file <key value file>
    1345                 vrc = RTPathAbsCxx(strAbsSettingsFile, ValueUnion.psz);
    1346                 if (RT_FAILURE(vrc))
    1347                     return errorSyntax(USAGE_UNATTENDEDINSTALL, "RTPathAbsCxx failed on '%s': %Rrc", ValueUnion.psz, vrc);
    1348                 pszSettingsFile = strAbsSettingsFile.c_str();
    1349                 break;
    1350 
    13511344            case 'i':   // --iso
    13521345                vrc = RTPathAbsCxx(strAbsIsoPath, ValueUnion.psz);
     
    14171410                break;
    14181411
     1412            case 'C':  // --post-install-script-template
     1413                vrc = RTPathAbsCxx(strAbsPostInstallScriptTemplatePath, ValueUnion.psz);
     1414                if (RT_FAILURE(vrc))
     1415                    return errorSyntax(USAGE_UNATTENDEDINSTALL, "RTPathAbsCxx failed on '%s': %Rrc", ValueUnion.psz, vrc);
     1416                pszPostInstallScriptTemplatePath = strAbsPostInstallScriptTemplatePath.c_str();
     1417                break;
     1418
    14191419            case 'P':   // --post-install-command.
    14201420                pszPostInstallCommand = ValueUnion.psz;
     
    14361436        return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing VM name/UUID");
    14371437
    1438     if (!pszSettingsFile && !pszIsoPath)
    1439         return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --iso (or --settings-file) option");
     1438    if (!pszIsoPath)
     1439        return errorSyntax(USAGE_UNATTENDEDINSTALL, "Missing required --iso option");
    14401440
    14411441    /*
     
    14861486            ComPtr<IUnattended> ptrUnattended;
    14871487            CHECK_ERROR_BREAK(machine, CreateUnattendedInstaller(ptrUnattended.asOutParam()));
    1488 
    1489             if (pszSettingsFile)
    1490                 CHECK_ERROR_BREAK(ptrUnattended, LoadSettings(Bstr(pszSettingsFile).raw()));
    14911488
    14921489            if (pszIsoPath)
     
    15121509            if (pszScriptTemplatePath)
    15131510                CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(ScriptTemplatePath)(Bstr(pszScriptTemplatePath).raw()));
     1511            if (pszPostInstallScriptTemplatePath)
     1512                CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(PostInstallScriptTemplatePath)(Bstr(pszPostInstallScriptTemplatePath).raw()));
    15141513            if (pszPostInstallCommand)
    15151514                CHECK_ERROR_BREAK(ptrUnattended, COMSETTER(PostInstallCommand)(Bstr(pszPostInstallCommand).raw()));
     
    15291528                    HRESULT hrc2 = ptrUnattended->COMGETTER(a_Attr)(&Value); \
    15301529                    if (SUCCEEDED(hrc2)) \
    1531                         RTPrintf("  %22s = " a_szFmt "\n", a_szText, Value); \
     1530                        RTPrintf("  %32s = " a_szFmt "\n", a_szText, Value); \
    15321531                    else \
    1533                         RTPrintf("  %22s = failed: %Rhrc\n", a_szText, hrc2); \
     1532                        RTPrintf("  %32s = failed: %Rhrc\n", a_szText, hrc2); \
    15341533                } while (0)
    15351534#define SHOW_STR_ATTR(a_Attr, a_szText) do { \
     
    15371536                    HRESULT hrc2 = ptrUnattended->COMGETTER(a_Attr)(bstrString.asOutParam()); \
    15381537                    if (SUCCEEDED(hrc2)) \
    1539                         RTPrintf("  %22s = %ls\n", a_szText, bstrString.raw()); \
     1538                        RTPrintf("  %32s = %ls\n", a_szText, bstrString.raw()); \
    15401539                    else \
    1541                         RTPrintf("  %22s = failed: %Rhrc\n", a_szText, hrc2); \
     1540                        RTPrintf("  %32s = failed: %Rhrc\n", a_szText, hrc2); \
    15421541                } while (0)
    15431542
     
    15541553            SHOW_ATTR(    ImageIndex,               "imageIndex",               ULONG, "%u");
    15551554            SHOW_STR_ATTR(ScriptTemplatePath,       "scriptTemplatePath");
     1555            SHOW_STR_ATTR(PostInstallScriptTemplatePath, "postInstallScriptTemplatePath");
    15561556            SHOW_STR_ATTR(PostInstallCommand,       "postInstallCommand");
    15571557
  • trunk/src/VBox/Main/UnattendedTemplates/debian_preseed.cfg

    r68057 r68071  
    6262
    6363# Custom Commands
    64 d-i preseed/late_command string \
    65 mkdir -p /target/postinstall && \
    66 cd /target/postinstall && \
    67 echo '#!/bin/bash' > post-install.sh && \
    68 echo 'apt-get -y install build-essential' >> post-install.sh && \
    69 echo 'apt-get -y install linux-headers-$(uname -r)' >> post-install.sh && \
    70 @@VBOX_COND_IS_INSTALLING_ADDITIONS@@echo 'echo' >> post-install.sh && \
    71 echo 'echo "Installing VirtualBox Guest Additions..."' >> post-install.sh && \
    72 echo 'bash /cdrom/VBoxAdditions/VBoxLinuxAdditions.run' >> post-install.sh && \
    73 echo 'usermod -a -G vboxsf "@@VBOX_INSERT_USER_LOGIN@@"' >> post-install.sh && \
    74 @@VBOX_COND_END@@@@VBOX_COND_IS_INSTALLING_TEST_EXEC_SERVICE@@echo 'echo' >> post-install.sh && \
    75 echo 'echo "TODO: Installing Test Execution Service..."' >> post-install.sh && \
    76 @@VBOX_COND_END@@echo exit 0' >> post-install.sh && \
    77 chmod +x /target/postinstall/post-install.sh && \
    78 chroot /target /bin/bash /postinstall/post-install.sh
     64d-i preseed/late_command string cp /cdrom/vboxpostinstall.sh /target/root/vboxpostinstall.sh \
     65 && chmod +x /target/root/vboxpostinstall.sh \
     66 && chroot /target /bin/bash /root/vboxpostinstall.sh
    7967
  • trunk/src/VBox/Main/UnattendedTemplates/fedora_ks.cfg

    r67881 r68071  
    6464
    6565@@VBOX_COND_IS_INSTALLING_ADDITIONS@@
    66 mkdir -p /mnt/cdrom
    67 mount -o ro /dev/sr2 /mnt/cdrom
    68 echo
    69 echo "Installing VirtualBox Guest Additions..."
    70 bash /mnt/cdrom/VBoxLinuxAdditions.run
    71 usermod -a -G vboxsf @@VBOX_INSERT_USER_LOGIN_SH@@
    72 @@VBOX_COND_END@@
     66## @todo fix this.
     67cp /cdrom/vboxpostinstall.sh /root/vboxpostinstall.sh && chmod a+x /root/vboxpostinstall.sh && /bin/bash /root/vboxpostinstall.sh
    7368eject /dev/sr0
    7469eject /dev/sr1
  • trunk/src/VBox/Main/UnattendedTemplates/ol_ks.cfg

    r67881 r68071  
    7272
    7373%post --log=/root/ks-post.log
    74 @@VBOX_COND_IS_INSTALLING_ADDITIONS@@
    75 mkdir -p /mnt/cdrom
    76 mount -o ro /dev/sr2 /mnt/cdrom
    77 echo
    78 echo "Installing VirtualBox Guest Additions..."
    79 bash /mnt/cdrom/VBoxLinuxAdditions.run
    80 usermod -a -G vboxsf @@VBOX_INSERT_USER_LOGIN_SH@@
    81 @@VBOX_COND_END@@
     74## @todo fix this.
     75cp /cdrom/vboxpostinstall.sh /root/vboxpostinstall.sh && chmod a+x /root/vboxpostinstall.sh && /bin/bash /root/vboxpostinstall.sh
    8276eject /dev/sr0
    8377eject /dev/sr1
  • trunk/src/VBox/Main/UnattendedTemplates/redhat67_ks.cfg

    r67881 r68071  
    7171
    7272%post --log=/root/ks-post.log
    73 @@VBOX_COND_IS_INSTALLING_ADDITIONS@@
    74 mkdir -p /mnt/cdrom
    75 mount -o ro /dev/sr2 /mnt/cdrom
    76 echo
    77 echo "Installing VirtualBox Guest Additions..."
    78 bash /mnt/cdrom/VBoxLinuxAdditions.run
    79 usermod -a -G vboxsf @@VBOX_INSERT_USER_LOGIN_SH@@
    80 @@VBOX_COND_END@@
     73## @todo fix this.
     74cp /cdrom/vboxpostinstall.sh /root/vboxpostinstall.sh && chmod a+x /root/vboxpostinstall.sh && /bin/bash /root/vboxpostinstall.sh
    8175eject /dev/sr0
    8276eject /dev/sr1
  • trunk/src/VBox/Main/UnattendedTemplates/ubuntu_preseed.cfg

    r68057 r68071  
    6262
    6363# Custom Commands
    64 d-i preseed/late_command string \
    65 mkdir -p /target/postinstall && \
    66 cd /target/postinstall && \
    67 echo '#!/bin/bash' > post-install.sh && \
    68 echo 'apt-get -y install build-essential' >> post-install.sh && \
    69 echo 'apt-get -y install linux-headers-$(uname -r)' >> post-install.sh && \
    70 @@VBOX_COND_IS_INSTALLING_ADDITIONS@@echo 'echo' >> post-install.sh && \
    71 echo 'echo "Installing VirtualBox Guest Additions..."' >> post-install.sh && \
    72 echo 'bash /cdrom/VBoxAdditions/VBoxLinuxAdditions.run' >> post-install.sh && \
    73 echo 'usermod -a -G vboxsf "@@VBOX_INSERT_USER_LOGIN@@"' >> post-install.sh && \
    74 @@VBOX_COND_END@@@@VBOX_COND_IS_INSTALLING_TEST_EXEC_SERVICE@@echo 'echo' >> post-install.sh && \
    75 echo 'echo "TODO: Installing Test Execution Service..."' >> post-install.sh && \
    76 @@VBOX_COND_END@@echo exit 0' >> post-install.sh && \
    77 chmod +x /target/postinstall/post-install.sh && \
    78 chroot /target /bin/bash /postinstall/post-install.sh
     64d-i preseed/late_command string cp /cdrom/vboxpostinstall.sh /target/root/vboxpostinstall.sh \
     65 && chmod +x /target/root/vboxpostinstall.sh \
     66 && chroot /target /bin/bash /root/vboxpostinstall.sh
    7967
    8068# Same as above, but for ubiquity.
    81 ubiquity ubiquity/success_command string \
    82 mkdir -p /target/postinstall && \
    83 cd /target/postinstall && \
    84 echo '#!/bin/bash' > post-install.sh && \
    85 echo 'apt-get -y install build-essential' >> post-install.sh && \
    86 echo 'apt-get -y install linux-headers-$(uname -r)' >> post-install.sh && \
    87 @@VBOX_COND_IS_INSTALLING_ADDITIONS@@echo 'echo' >> post-install.sh && \
    88 echo 'echo "Installing VirtualBox Guest Additions..."' >> post-install.sh && \
    89 echo 'bash /cdrom/VBoxAdditions/VBoxLinuxAdditions.run' >> post-install.sh && \
    90 echo 'usermod -a -G vboxsf "@@VBOX_INSERT_USER_LOGIN@@"' >> post-install.sh && \
    91 @@VBOX_COND_END@@@@VBOX_COND_IS_INSTALLING_TEST_EXEC_SERVICE@@echo 'echo' >> post-install.sh && \
    92 echo 'echo "TODO: Installing Test Execution Service..."' >> post-install.sh && \
    93 @@VBOX_COND_END@@echo exit 0' >> post-install.sh && \
    94 chmod +x /target/postinstall/post-install.sh && \
    95 chroot /target /bin/bash /postinstall/post-install.sh
     69ubiquity ubiquity/success_command string cp /cdrom/vboxpostinstall.sh /target/root/vboxpostinstall.sh \
     70 && chmod +x /target/root/vboxpostinstall.sh \
     71 && chroot /target /bin/bash /root/vboxpostinstall.sh
    9672
  • trunk/src/VBox/Main/UnattendedTemplates/win_nt5_unattended.sif

    r67881 r68071  
    5757@@VBOX_COND_IS_INSTALLING_ADDITIONS@@
    5858[GuiRunOnce]
    59     Command0="E:\VBoxWindowsAdditions.exe"
     59    Command0="A:\vboxpost.cmd"
    6060@@VBOX_COND_END@@
    6161
  • trunk/src/VBox/Main/UnattendedTemplates/win_nt6_unattended.xml

    r67941 r68071  
    126126                    <CommandLine>reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\Network\NewNetworkWindowOff"</CommandLine>
    127127                </SynchronousCommand>
    128 @@VBOX_COND_IS_INSTALLING_ADDITIONS@@
    129128                <SynchronousCommand wcm:action="add">
    130129                    <Order>2</Order>
    131                     <Description>Install Oracle certificate</Description>
    132                     <CommandLine>e:\cert\VBoxCertUtil.exe add-trusted-publisher e:\cert\vbox*.cer --root e:\cert\vbox*.cer</CommandLine>
     130                    <Description>VirtualBox post guest install steps </Description>
     131                    <CommandLine>cmd.exe /c A:\vboxpost.cmd</CommandLine>
    133132                </SynchronousCommand>
    134                 <SynchronousCommand wcm:action="add">
    135                     <Order>3</Order>
    136                     <Description>Install VirtualBox Guest Additions</Description>
    137                     <CommandLine>e:\VBoxWindowsAdditions.exe /S</CommandLine>
    138                 </SynchronousCommand>
    139 @@VBOX_COND_END@@
    140133            </FirstLogonCommands>
    141134
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r68038 r68071  
    37673767  <interface
    37683768    name="IUnattended" extends="$unknown"
    3769     uuid="1f9a37d3-c3ba-4741-a53a-822a1b2d308d"
     3769    uuid="663fc677-ca00-4a24-b940-8741f76a898a"
    37703770    wsmap="managed"
    37713771    reservedMethods="4" reservedAttributes="16"
     
    39003900    </attribute>
    39013901
     3902    <attribute name="postInstallScriptTemplatePath" type="wstring">
     3903      <desc>
     3904        The post installation (shell/batch) script template file.
     3905
     3906        The template default is based on the guest OS type and is determined by the
     3907        internal installer when when <link to="IUnattended::prepare"/> is invoked.
     3908        Most users will want the defaults.
     3909
     3910        After <link to="IUnattended::prepare"/> is called, it can be read to see
     3911        which file is being used.
     3912      </desc>
     3913    </attribute>
     3914
    39023915    <attribute name="postInstallCommand" type="wstring">
    39033916      <desc>
     
    39053918
    39063919        Exactly what is expected as input here depends on the guest OS installer
    3907         and the script template (see <link to="IUnattended::scriptTemplatePath"/>).
     3920        and the post installation script template (see
     3921        <link to="IUnattended::postInstallScriptTemplatePath"/>).
    39083922        Most users will not need to set this attribute.
    39093923      </desc>
    39103924    </attribute>
    39113925
     3926    <!-- See no point in having this any more.
    39123927    <method name="loadSettings">
    39133928      <desc>
     
    39223937      </param>
    39233938    </method>
     3939    -->
    39243940
    39253941    <method name="prepare">
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