1 | /* $Id: UnattendedInstaller.h 93099 2021-12-29 11:13:23Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * UnattendedInstaller class header
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2020 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef MAIN_INCLUDED_UnattendedInstaller_h
|
---|
19 | #define MAIN_INCLUDED_UnattendedInstaller_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "UnattendedScript.h"
|
---|
25 |
|
---|
26 | /* Forward declarations */
|
---|
27 | class Unattended;
|
---|
28 | class UnattendedInstaller;
|
---|
29 | class BaseTextScript;
|
---|
30 |
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * The abstract UnattendedInstaller class declaration
|
---|
34 | *
|
---|
35 | * The class is intended to service a new VM that this VM will be able to
|
---|
36 | * execute an unattended installation
|
---|
37 | */
|
---|
38 | class UnattendedInstaller : public RTCNonCopyable
|
---|
39 | {
|
---|
40 | /*data*/
|
---|
41 | protected:
|
---|
42 | /** Main unattended installation script. */
|
---|
43 | UnattendedScriptTemplate mMainScript;
|
---|
44 | /** Full path to the main template file (set by initInstaller). */
|
---|
45 | Utf8Str mStrMainScriptTemplate;
|
---|
46 |
|
---|
47 | /** Post installation (shell) script. */
|
---|
48 | UnattendedScriptTemplate mPostScript;
|
---|
49 | /** Full path to the post template file (set by initInstaller). */
|
---|
50 | Utf8Str mStrPostScriptTemplate;
|
---|
51 |
|
---|
52 | /** Pointer to the parent object.
|
---|
53 | * We use this for setting errors and querying attributes. */
|
---|
54 | Unattended *mpParent;
|
---|
55 | /** The path of the extra ISO image we create (set by initInstaller).
|
---|
56 | * This is only valid when isAdditionsIsoNeeded() returns true. */
|
---|
57 | Utf8Str mStrAuxiliaryIsoFilePath;
|
---|
58 | /** The path of the extra floppy image we create (set by initInstaller)
|
---|
59 | * This is only valid when isAdditionsFloppyNeeded() returns true. */
|
---|
60 | Utf8Str mStrAuxiliaryFloppyFilePath;
|
---|
61 | /** The boot device. */
|
---|
62 | DeviceType_T const meBootDevice;
|
---|
63 | /** Default extra install kernel parameters (set by constructor).
|
---|
64 | * This can be overridden by the extraInstallKernelParameters attribute of
|
---|
65 | * IUnattended. */
|
---|
66 | Utf8Str mStrDefaultExtraInstallKernelParameters;
|
---|
67 | /** The directory of the post install script in the unattended install
|
---|
68 | * environment, i.e. when it gets started by the unattended installer
|
---|
69 | * of the respective guest OS. */
|
---|
70 | Utf8Str mStrAuxiliaryInstallDir;
|
---|
71 |
|
---|
72 | private:
|
---|
73 | UnattendedInstaller(); /* no default constructors */
|
---|
74 |
|
---|
75 | public:
|
---|
76 | DECLARE_TRANSLATE_METHODS(UnattendedInstaller)
|
---|
77 |
|
---|
78 | /**
|
---|
79 | * Regular constructor.
|
---|
80 | *
|
---|
81 | * @param pParent The parent object. Used for setting
|
---|
82 | * errors and querying attributes.
|
---|
83 | * @param pszMainScriptTemplateName The name of the template file (no path)
|
---|
84 | * for the main unattended installer
|
---|
85 | * script.
|
---|
86 | * @param pszPostScriptTemplateName The name of the template file (no path)
|
---|
87 | * for the post installation script.
|
---|
88 | * @param pszMainScriptFilename The main unattended installer script
|
---|
89 | * filename (on aux media).
|
---|
90 | * @param pszPostScriptFilename The post installation script filename
|
---|
91 | * (on aux media).
|
---|
92 | * @param enmBootDevice The boot device type.
|
---|
93 | */
|
---|
94 | UnattendedInstaller(Unattended *pParent,
|
---|
95 | const char *pszMainScriptTemplateName, const char *pszPostScriptTemplateName,
|
---|
96 | const char *pszMainScriptFilename, const char *pszPostScriptFilename,
|
---|
97 | DeviceType_T enmBootDevice = DeviceType_DVD);
|
---|
98 | virtual ~UnattendedInstaller();
|
---|
99 |
|
---|
100 | /**
|
---|
101 | * Instantiates the appropriate child class.
|
---|
102 | *
|
---|
103 | * @returns Pointer to the new instance, NULL if no appropriate installer.
|
---|
104 | * @param enmOsType The guest OS type value.
|
---|
105 | * @param strGuestOsType The guest OS type string
|
---|
106 | * @param strDetectedOSVersion The detected guest OS version.
|
---|
107 | * @param strDetectedOSFlavor The detected guest OS flavor.
|
---|
108 | * @param strDetectedOSHints Hints about the detected guest OS.
|
---|
109 | * @param pParent The parent object. Used for setting errors
|
---|
110 | * and querying attributes.
|
---|
111 | * @throws std::bad_alloc
|
---|
112 | */
|
---|
113 | static UnattendedInstaller *createInstance(VBOXOSTYPE enmOsType, const Utf8Str &strGuestOsType,
|
---|
114 | const Utf8Str &strDetectedOSVersion, const Utf8Str &strDetectedOSFlavor,
|
---|
115 | const Utf8Str &strDetectedOSHints, Unattended *pParent);
|
---|
116 |
|
---|
117 | /**
|
---|
118 | * Initialize the installer.
|
---|
119 | *
|
---|
120 | * @note This is called immediately after instantiation and the caller will
|
---|
121 | * always destroy the unattended installer instance on failure, so it
|
---|
122 | * is not necessary to keep track of whether this succeeded or not.
|
---|
123 | */
|
---|
124 | virtual HRESULT initInstaller();
|
---|
125 |
|
---|
126 | #if 0 /* These are now in the AUX VISO. */
|
---|
127 | /**
|
---|
128 | * Whether the VBox Guest Additions ISO is needed or not.
|
---|
129 | *
|
---|
130 | * The default implementation always returns false when a VISO is used, see
|
---|
131 | * UnattendedInstaller::addFilesToAuxVisoVectors.
|
---|
132 | */
|
---|
133 | virtual bool isAdditionsIsoNeeded() const;
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Whether the VBox validation kit ISO is needed or not.
|
---|
137 | *
|
---|
138 | * The default implementation always returns false when a VISO is used, see
|
---|
139 | * UnattendedInstaller::addFilesToAuxVisoVectors.
|
---|
140 | */
|
---|
141 | virtual bool isValidationKitIsoNeeded() const;
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | /**
|
---|
145 | * Indicates whether an original installation ISO is needed or not.
|
---|
146 | */
|
---|
147 | virtual bool isOriginalIsoNeeded() const { return true; }
|
---|
148 |
|
---|
149 | /**
|
---|
150 | * Indicates whether a floppy image is needed or not.
|
---|
151 | */
|
---|
152 | virtual bool isAuxiliaryFloppyNeeded() const { return false; }
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * Indicates whether an additional or replacement ISO image is needed or not.
|
---|
156 | */
|
---|
157 | virtual bool isAuxiliaryIsoNeeded() const;
|
---|
158 |
|
---|
159 | /**
|
---|
160 | * Indicates whether we should boot from the auxiliary ISO image.
|
---|
161 | *
|
---|
162 | * Will boot from installation ISO if false.
|
---|
163 | */
|
---|
164 | virtual bool bootFromAuxiliaryIso() const { return isAuxiliaryIsoNeeded(); }
|
---|
165 |
|
---|
166 | /**
|
---|
167 | * Indicates whether a the auxiliary ISO is a .viso-file rather than an
|
---|
168 | * .iso-file.
|
---|
169 | *
|
---|
170 | * Different worker methods are used depending on the return value. A
|
---|
171 | * .viso-file is generally only used when the installation media needs to
|
---|
172 | * be remastered with small changes and additions.
|
---|
173 | */
|
---|
174 | virtual bool isAuxiliaryIsoIsVISO() const { return true; }
|
---|
175 |
|
---|
176 | /*
|
---|
177 | * Getters
|
---|
178 | */
|
---|
179 | DeviceType_T getBootableDeviceType() const { return meBootDevice; }
|
---|
180 | const Utf8Str &getTemplateFilePath() const { return mStrMainScriptTemplate; }
|
---|
181 | const Utf8Str &getPostTemplateFilePath() const { return mStrPostScriptTemplate; }
|
---|
182 | const Utf8Str &getAuxiliaryIsoFilePath() const { return mStrAuxiliaryIsoFilePath; }
|
---|
183 | const Utf8Str &getAuxiliaryFloppyFilePath() const { return mStrAuxiliaryFloppyFilePath; }
|
---|
184 | const Utf8Str &getDefaultExtraInstallKernelParameters() const { return mStrDefaultExtraInstallKernelParameters; }
|
---|
185 | const Utf8Str &getAuxiliaryInstallDir() const { return mStrAuxiliaryInstallDir; }
|
---|
186 |
|
---|
187 | /*
|
---|
188 | * Setters
|
---|
189 | */
|
---|
190 | void setTemplatePath(const Utf8Str& data); /**< @todo r=bird: This is confusing as heck. Dir for a while, then it's a file. Not a comment about it. Brilliant. */
|
---|
191 |
|
---|
192 | /**
|
---|
193 | * Prepares the unattended scripts, does all but write them to the installation
|
---|
194 | * media.
|
---|
195 | */
|
---|
196 | HRESULT prepareUnattendedScripts();
|
---|
197 |
|
---|
198 | /**
|
---|
199 | * Prepares the media - floppy image, ISO image.
|
---|
200 | *
|
---|
201 | * This method calls prepareAuxFloppyImage() and prepareAuxIsoImage(), child
|
---|
202 | * classes may override these methods or methods they call.
|
---|
203 | *
|
---|
204 | * @returns COM status code.
|
---|
205 | * @param fOverwrite Whether to overwrite media files or fail if they
|
---|
206 | * already exist.
|
---|
207 | */
|
---|
208 | HRESULT prepareMedia(bool fOverwrite = true);
|
---|
209 |
|
---|
210 | protected:
|
---|
211 | /**
|
---|
212 | * Prepares (creates) the auxiliary floppy image.
|
---|
213 | *
|
---|
214 | * This is called by the base class prepareMedia() when
|
---|
215 | * isAuxiliaryFloppyNeeded() is true. The base class implementation puts the
|
---|
216 | * edited unattended script onto it.
|
---|
217 | */
|
---|
218 | HRESULT prepareAuxFloppyImage(bool fOverwrite);
|
---|
219 |
|
---|
220 | /**
|
---|
221 | * Creates and formats (FAT12) a floppy image.
|
---|
222 | *
|
---|
223 | * This can be overridden to do more preparation work or/and create a different
|
---|
224 | * sized floppy.
|
---|
225 | *
|
---|
226 | * @returns COM status code.
|
---|
227 | * @param pszFilename The path to the image file.
|
---|
228 | * @param fOverwrite Whether to overwrite the file.
|
---|
229 | * @param phVfsFile Where to return a read-writable handle to the newly
|
---|
230 | * created image.
|
---|
231 | */
|
---|
232 | virtual HRESULT newAuxFloppyImage(const char *pszFilename, bool fOverwrite, PRTVFSFILE phVfsFile);
|
---|
233 |
|
---|
234 | /**
|
---|
235 | * Copies files to the auxiliary floppy image.
|
---|
236 | *
|
---|
237 | * The base class implementation copies the main and post scripts to the root of
|
---|
238 | * the floppy using the default script names. Child classes may override this
|
---|
239 | * to add additional or different files.
|
---|
240 | *
|
---|
241 | * @returns COM status code.
|
---|
242 | * @param hVfs The floppy image VFS handle.
|
---|
243 | */
|
---|
244 | virtual HRESULT copyFilesToAuxFloppyImage(RTVFS hVfs);
|
---|
245 |
|
---|
246 | /**
|
---|
247 | * Adds the given script to the root of the floppy image under the default
|
---|
248 | * script filename.
|
---|
249 | *
|
---|
250 | * @returns COM status code.
|
---|
251 | * @param pEditor The script to add.
|
---|
252 | * @param hVfs The VFS to add it to.
|
---|
253 | */
|
---|
254 | HRESULT addScriptToFloppyImage(BaseTextScript *pEditor, RTVFS hVfs);
|
---|
255 |
|
---|
256 | /**
|
---|
257 | * Copy an arbritrary file onto the floopy image.
|
---|
258 | *
|
---|
259 | * @returns COM status code.
|
---|
260 | * @param hVfs The VFS to add it to.
|
---|
261 | * @param pszSrc The source filename.
|
---|
262 | * @param pszDst The destination filename (on @a hVfs).
|
---|
263 | */
|
---|
264 | HRESULT addFileToFloppyImage(RTVFS hVfs, const char *pszSrc, const char *pszDst);
|
---|
265 |
|
---|
266 | /**
|
---|
267 | * Prepares (creates) the auxiliary ISO image.
|
---|
268 | *
|
---|
269 | * This is called by the base class prepareMedia() when isAuxiliaryIsoNeeded()
|
---|
270 | * is true. The base class implementation puts the edited unattended script
|
---|
271 | * onto it.
|
---|
272 | */
|
---|
273 | virtual HRESULT prepareAuxIsoImage(bool fOverwrite);
|
---|
274 |
|
---|
275 | /**
|
---|
276 | * Opens the installation ISO image.
|
---|
277 | *
|
---|
278 | * @returns COM status code.
|
---|
279 | * @param phVfsIso Where to return the VFS handle for the ISO.
|
---|
280 | * @param fFlags RTFSISO9660_F_XXX flags to pass to the
|
---|
281 | * RTFsIso9660VolOpen API.
|
---|
282 | */
|
---|
283 | virtual HRESULT openInstallIsoImage(PRTVFS phVfsIso, uint32_t fFlags = 0);
|
---|
284 |
|
---|
285 | /**
|
---|
286 | * Creates and configures the ISO maker instance.
|
---|
287 | *
|
---|
288 | * This can be overridden to set configure options.
|
---|
289 | *
|
---|
290 | * @returns COM status code.
|
---|
291 | * @param phIsoMaker Where to return the ISO maker.
|
---|
292 | */
|
---|
293 | virtual HRESULT newAuxIsoImageMaker(PRTFSISOMAKER phIsoMaker);
|
---|
294 |
|
---|
295 | /**
|
---|
296 | * Adds files to the auxiliary ISO image maker.
|
---|
297 | *
|
---|
298 | * The base class implementation copies just the mMainScript and mPostScript
|
---|
299 | * files to root directory using the default filenames.
|
---|
300 | *
|
---|
301 | * @returns COM status code.
|
---|
302 | * @param hIsoMaker The ISO maker handle.
|
---|
303 | * @param hVfsOrgIso The VFS handle to the original ISO in case files
|
---|
304 | * needs to be added from it.
|
---|
305 | */
|
---|
306 | virtual HRESULT addFilesToAuxIsoImageMaker(RTFSISOMAKER hIsoMaker, RTVFS hVfsOrgIso);
|
---|
307 |
|
---|
308 | /**
|
---|
309 | * Adds the given script to the ISO maker.
|
---|
310 | *
|
---|
311 | * @returns COM status code.
|
---|
312 | * @param pEditor The script to add.
|
---|
313 | * @param hIsoMaker The ISO maker to add it to.
|
---|
314 | * @param pszDstFilename The file name (w/ path) to add it under. If NULL,
|
---|
315 | * the default script filename is used to add it to the
|
---|
316 | * root.
|
---|
317 | */
|
---|
318 | HRESULT addScriptToIsoMaker(BaseTextScript *pEditor, RTFSISOMAKER hIsoMaker, const char *pszDstFilename = NULL);
|
---|
319 |
|
---|
320 | /**
|
---|
321 | * Writes the ISO image to disk.
|
---|
322 | *
|
---|
323 | * @returns COM status code.
|
---|
324 | * @param hIsoMaker The ISO maker handle.
|
---|
325 | * @param pszFilename The filename.
|
---|
326 | * @param fOverwrite Whether to overwrite the destination file or not.
|
---|
327 | */
|
---|
328 | HRESULT finalizeAuxIsoImage(RTFSISOMAKER hIsoMaker, const char *pszFilename, bool fOverwrite);
|
---|
329 |
|
---|
330 | /**
|
---|
331 | * Adds files to the .viso-file vectors.
|
---|
332 | *
|
---|
333 | * The base class implementation adds the script from mAlg, additions ISO
|
---|
334 | * content to '/vboxadditions', and validation kit ISO to '/vboxvalidationkit'.
|
---|
335 | *
|
---|
336 | * @returns COM status code.
|
---|
337 | * @param rVecArgs The ISO maker argument list that will be turned into
|
---|
338 | * a .viso-file.
|
---|
339 | * @param rVecFiles The list of files we've created. This is for
|
---|
340 | * cleaning up at the end.
|
---|
341 | * @param hVfsOrgIso The VFS handle to the original ISO in case files
|
---|
342 | * needs to be added from it.
|
---|
343 | * @param fOverwrite Whether to overwrite files or not.
|
---|
344 | */
|
---|
345 | virtual HRESULT addFilesToAuxVisoVectors(RTCList<RTCString> &rVecArgs, RTCList<RTCString> &rVecFiles,
|
---|
346 | RTVFS hVfsOrgIso, bool fOverwrite);
|
---|
347 |
|
---|
348 | /**
|
---|
349 | * Saves the given script to disk and adds it to the .viso-file vectors.
|
---|
350 | *
|
---|
351 | * @returns COM status code.
|
---|
352 | * @param pEditor The script to add.
|
---|
353 | * @param rVecArgs The ISO maker argument list that will be turned into
|
---|
354 | * a .viso-file.
|
---|
355 | * @param rVecFiles The list of files we've created. This is for
|
---|
356 | * cleaning up at the end.
|
---|
357 | * @param fOverwrite Whether to overwrite files or not.
|
---|
358 | */
|
---|
359 | HRESULT addScriptToVisoVectors(BaseTextScript *pEditor, RTCList<RTCString> &rVecArgs,
|
---|
360 | RTCList<RTCString> &rVecFiles, bool fOverwrite);
|
---|
361 |
|
---|
362 | /**
|
---|
363 | * Writes out the .viso-file to disk.
|
---|
364 | *
|
---|
365 | * @returns COM status code.
|
---|
366 | * @param rVecArgs The ISO maker argument list to write out.
|
---|
367 | * @param pszFilename The filename.
|
---|
368 | * @param fOverwrite Whether to overwrite the destination file or not.
|
---|
369 | */
|
---|
370 | HRESULT finalizeAuxVisoFile(RTCList<RTCString> const &rVecArgs, const char *pszFilename, bool fOverwrite);
|
---|
371 |
|
---|
372 | /**
|
---|
373 | * Loads @a pszFilename from @a hVfsOrgIso into @a pEditor and parses it.
|
---|
374 | *
|
---|
375 | * @returns COM status code.
|
---|
376 | * @param hVfsOrgIso The handle to the original installation ISO.
|
---|
377 | * @param pszFilename The filename to open and load from the ISO.
|
---|
378 | * @param pEditor The editor instance to load the file into and
|
---|
379 | * do the parseing with.
|
---|
380 | */
|
---|
381 | HRESULT loadAndParseFileFromIso(RTVFS hVfsOrgIso, const char *pszFilename, AbstractScript *pEditor);
|
---|
382 | };
|
---|
383 |
|
---|
384 |
|
---|
385 | /**
|
---|
386 | * Windows installer, for versions up to xp 64 / w2k3.
|
---|
387 | */
|
---|
388 | class UnattendedWindowsSifInstaller : public UnattendedInstaller
|
---|
389 | {
|
---|
390 | public:
|
---|
391 | DECLARE_TRANSLATE_METHODS(UnattendedWindowsSifInstaller)
|
---|
392 |
|
---|
393 | UnattendedWindowsSifInstaller(Unattended *pParent)
|
---|
394 | : UnattendedInstaller(pParent,
|
---|
395 | "win_nt5_unattended.sif", "win_postinstall.cmd",
|
---|
396 | "WINNT.SIF", "VBOXPOST.CMD")
|
---|
397 | {
|
---|
398 | Assert(isOriginalIsoNeeded()); Assert(isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); Assert(!bootFromAuxiliaryIso());
|
---|
399 | mStrAuxiliaryInstallDir = "A:\\";
|
---|
400 | }
|
---|
401 | ~UnattendedWindowsSifInstaller() {}
|
---|
402 |
|
---|
403 | bool isAuxiliaryFloppyNeeded() const { return true; }
|
---|
404 | bool bootFromAuxiliaryIso() const { return false; }
|
---|
405 |
|
---|
406 | };
|
---|
407 |
|
---|
408 | /**
|
---|
409 | * Windows installer, for versions starting with Vista.
|
---|
410 | */
|
---|
411 | class UnattendedWindowsXmlInstaller : public UnattendedInstaller
|
---|
412 | {
|
---|
413 | public:
|
---|
414 | DECLARE_TRANSLATE_METHODS(UnattendedWindowsXmlInstaller)
|
---|
415 |
|
---|
416 | UnattendedWindowsXmlInstaller(Unattended *pParent)
|
---|
417 | : UnattendedInstaller(pParent,
|
---|
418 | "win_nt6_unattended.xml", "win_postinstall.cmd",
|
---|
419 | "autounattend.xml", "VBOXPOST.CMD")
|
---|
420 | {
|
---|
421 | Assert(isOriginalIsoNeeded()); Assert(isAuxiliaryFloppyNeeded() || isAuxiliaryIsoNeeded()); Assert(isAuxiliaryIsoIsVISO()); Assert(!bootFromAuxiliaryIso());
|
---|
422 | if (isAuxiliaryFloppyNeeded())
|
---|
423 | mStrAuxiliaryInstallDir = "A:\\";
|
---|
424 | else if (bootFromAuxiliaryIso())
|
---|
425 | mStrAuxiliaryInstallDir = "D:\\";
|
---|
426 | else
|
---|
427 | mStrAuxiliaryInstallDir = "E:\\";
|
---|
428 | }
|
---|
429 | ~UnattendedWindowsXmlInstaller() {}
|
---|
430 |
|
---|
431 | bool isAuxiliaryFloppyNeeded() const { return !mpParent->i_isFirmwareEFI(); }
|
---|
432 | bool isAuxiliaryIsoNeeded() const { return UnattendedInstaller::isAuxiliaryIsoNeeded() || mpParent->i_isFirmwareEFI(); }
|
---|
433 | bool isAuxiliaryIsoIsVISO() const { return true; }
|
---|
434 | bool bootFromAuxiliaryIso() const { return false; }
|
---|
435 | };
|
---|
436 |
|
---|
437 |
|
---|
438 | /**
|
---|
439 | * OS/2 installer.
|
---|
440 | */
|
---|
441 | class UnattendedOs2Installer : public UnattendedInstaller
|
---|
442 | {
|
---|
443 | public:
|
---|
444 | DECLARE_TRANSLATE_METHODS(UnattendedOs2Installer)
|
---|
445 |
|
---|
446 | UnattendedOs2Installer(Unattended *pParent, Utf8Str const &rStrHints);
|
---|
447 | ~UnattendedOs2Installer() {}
|
---|
448 |
|
---|
449 | /* Remaster original ISO with auxiliary floppy used for el torito floppy emulation: */
|
---|
450 | bool isOriginalIsoNeeded() const RT_OVERRIDE { return false; }
|
---|
451 | bool isAuxiliaryFloppyNeeded() const RT_OVERRIDE { return true; }
|
---|
452 | bool isAuxiliaryIsoNeeded() const RT_OVERRIDE { return true; }
|
---|
453 |
|
---|
454 | protected:
|
---|
455 | HRESULT replaceAuxFloppyImageBootSector(RTVFSFILE hVfsFile) RT_NOEXCEPT;
|
---|
456 | HRESULT newAuxFloppyImage(const char *pszFilename, bool fOverwrite, PRTVFSFILE phVfsFile) RT_OVERRIDE;
|
---|
457 | HRESULT copyFilesToAuxFloppyImage(RTVFS hVfs) RT_OVERRIDE;
|
---|
458 | HRESULT addFilesToAuxVisoVectors(RTCList<RTCString> &rVecArgs, RTCList<RTCString> &rVecFiles,
|
---|
459 | RTVFS hVfsOrgIso, bool fOverwrite) RT_OVERRIDE;
|
---|
460 |
|
---|
461 | HRESULT splitResponseFile() RT_NOEXCEPT;
|
---|
462 |
|
---|
463 | /**
|
---|
464 | * Splits up the given file into sub-files and writes them out with the auxilary
|
---|
465 | * path base as prefix.
|
---|
466 | *
|
---|
467 | * The source file contains @@VBOX_SPLITTER_START[filename]@@ and
|
---|
468 | * @@VBOX_SPLITTER_END[filename]@@ markup that is used to split it up. Any
|
---|
469 | * text between END and START tags are ignored and can be used for comments.
|
---|
470 | *
|
---|
471 | * @returns COM status code (error info set).
|
---|
472 | * @param pszFileToSplit The name of the file to split.
|
---|
473 | * @param rVecSplitFiles Vector where names of the sub-files are appended
|
---|
474 | * (without any path or prefix).
|
---|
475 | */
|
---|
476 | HRESULT splitFile(const char *pszFileToSplit, RTCList<RTCString> &rVecSplitFiles) RT_NOEXCEPT;
|
---|
477 |
|
---|
478 | /**
|
---|
479 | * Splits up the given editor output into sub-files and writes them out with the
|
---|
480 | * auxilary path base as prefix.
|
---|
481 | *
|
---|
482 | * The source file contains @@VBOX_SPLITTER_START[filename]@@ and
|
---|
483 | * @@VBOX_SPLITTER_END[filename]@@ markup that is used to split it up. Any
|
---|
484 | * text between END and START tags are ignored and can be used for comments.
|
---|
485 | *
|
---|
486 | * @returns COM status code (error info set).
|
---|
487 | * @param pEditor The editor which output should be split.
|
---|
488 | * @param rVecSplitFiles Vector where names of the sub-files are appended
|
---|
489 | * (without any path or prefix).
|
---|
490 | */
|
---|
491 | HRESULT splitFile(BaseTextScript *pEditor, RTCList<RTCString> &rVecSplitFiles) RT_NOEXCEPT;
|
---|
492 |
|
---|
493 | HRESULT splitFileInner(const char *pszFileToSplit, RTCList<RTCString> &rVecSplitFiles,
|
---|
494 | const char *pszSrc, size_t cbLeft) RT_NOEXCEPT;
|
---|
495 |
|
---|
496 | static int patchOs2Ldr(uint8_t *pbFile, size_t cbFile, const char *pszFilename, UnattendedOs2Installer *pThis);
|
---|
497 |
|
---|
498 | /** The OS2SE20.SRC path ("\\OS2IMAGES"). */
|
---|
499 | Utf8Str mStrOs2Images;
|
---|
500 | /** Files split out from os2_response_files.rsp (bare filenames, no paths). */
|
---|
501 | RTCList<RTCString> mVecSplitFiles;
|
---|
502 | };
|
---|
503 |
|
---|
504 |
|
---|
505 |
|
---|
506 | /**
|
---|
507 | * Base class for the unattended linux installers.
|
---|
508 | */
|
---|
509 | class UnattendedLinuxInstaller : public UnattendedInstaller
|
---|
510 | {
|
---|
511 | protected:
|
---|
512 | /** Array of linux parameter patterns that should be removed by editIsoLinuxCfg.
|
---|
513 | * The patterns are proceed by RTStrSimplePatternNMatch. */
|
---|
514 | RTCList<RTCString, RTCString *> mArrStrRemoveInstallKernelParameters;
|
---|
515 |
|
---|
516 | public:
|
---|
517 | DECLARE_TRANSLATE_METHODS(UnattendedLinuxInstaller)
|
---|
518 |
|
---|
519 | UnattendedLinuxInstaller(Unattended *pParent,
|
---|
520 | const char *pszMainScriptTemplateName, const char *pszPostScriptTemplateName,
|
---|
521 | const char *pszMainScriptFilename, const char *pszPostScriptFilename = "vboxpostinstall.sh")
|
---|
522 | : UnattendedInstaller(pParent,
|
---|
523 | pszMainScriptTemplateName, pszPostScriptTemplateName,
|
---|
524 | pszMainScriptFilename, pszPostScriptFilename) {}
|
---|
525 | ~UnattendedLinuxInstaller() {}
|
---|
526 |
|
---|
527 | bool isAuxiliaryIsoNeeded() const { return true; }
|
---|
528 |
|
---|
529 | protected:
|
---|
530 | /**
|
---|
531 | * Performs basic edits on a isolinux.cfg file.
|
---|
532 | *
|
---|
533 | * @returns COM status code
|
---|
534 | * @param pEditor Editor with the isolinux.cfg file loaded and parsed.
|
---|
535 | */
|
---|
536 | virtual HRESULT editIsoLinuxCfg(GeneralTextScript *pEditor);
|
---|
537 | };
|
---|
538 |
|
---|
539 |
|
---|
540 | /**
|
---|
541 | * Debian installer.
|
---|
542 | *
|
---|
543 | * This will remaster the orignal ISO and therefore be producing a .viso-file.
|
---|
544 | */
|
---|
545 | class UnattendedDebianInstaller : public UnattendedLinuxInstaller
|
---|
546 | {
|
---|
547 | public:
|
---|
548 | DECLARE_TRANSLATE_METHODS(UnattendedDebianInstaller)
|
---|
549 |
|
---|
550 | UnattendedDebianInstaller(Unattended *pParent,
|
---|
551 | const char *pszMainScriptTemplateName = "debian_preseed.cfg",
|
---|
552 | const char *pszPostScriptTemplateName = "debian_postinstall.sh",
|
---|
553 | const char *pszMainScriptFilename = "preseed.cfg")
|
---|
554 | : UnattendedLinuxInstaller(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
|
---|
555 | {
|
---|
556 | Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded());
|
---|
557 | Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO());
|
---|
558 | mStrDefaultExtraInstallKernelParameters.setNull();
|
---|
559 | mStrDefaultExtraInstallKernelParameters += " auto=true";
|
---|
560 | mStrDefaultExtraInstallKernelParameters.append(" preseed/file=/cdrom/").append(pszMainScriptFilename);
|
---|
561 | mStrDefaultExtraInstallKernelParameters += " priority=critical";
|
---|
562 | mStrDefaultExtraInstallKernelParameters += " quiet";
|
---|
563 | mStrDefaultExtraInstallKernelParameters += " splash";
|
---|
564 | mStrDefaultExtraInstallKernelParameters += " noprompt"; /* no questions about things like CD/DVD ejections */
|
---|
565 | mStrDefaultExtraInstallKernelParameters += " noshell"; /* No shells on VT1-3 (debian, not ubuntu). */
|
---|
566 | mStrDefaultExtraInstallKernelParameters += " automatic-ubiquity"; // ubiquity
|
---|
567 | // the following can probably go into the preseed.cfg:
|
---|
568 | mStrDefaultExtraInstallKernelParameters.append(" debian-installer/locale=").append(pParent->i_getLocale());
|
---|
569 | mStrDefaultExtraInstallKernelParameters += " keyboard-configuration/layoutcode=us";
|
---|
570 | mStrDefaultExtraInstallKernelParameters += " languagechooser/language-name=English"; /** @todo fixme */
|
---|
571 | mStrDefaultExtraInstallKernelParameters.append(" localechooser/supported-locales=").append(pParent->i_getLocale()).append(".UTF-8");
|
---|
572 | mStrDefaultExtraInstallKernelParameters.append(" countrychooser/shortlist=").append(pParent->i_getCountry()); // ubiquity?
|
---|
573 | mStrDefaultExtraInstallKernelParameters += " --";
|
---|
574 | }
|
---|
575 | ~UnattendedDebianInstaller() {}
|
---|
576 |
|
---|
577 | bool isOriginalIsoNeeded() const { return false; }
|
---|
578 |
|
---|
579 | protected:
|
---|
580 | HRESULT addFilesToAuxVisoVectors(RTCList<RTCString> &rVecArgs, RTCList<RTCString> &rVecFiles,
|
---|
581 | RTVFS hVfsOrgIso, bool fOverwrite);
|
---|
582 | HRESULT editDebianTxtCfg(GeneralTextScript *pEditor);
|
---|
583 |
|
---|
584 | };
|
---|
585 |
|
---|
586 |
|
---|
587 | /**
|
---|
588 | * Ubuntu installer (same as debian, except for the template).
|
---|
589 | */
|
---|
590 | class UnattendedUbuntuInstaller : public UnattendedDebianInstaller
|
---|
591 | {
|
---|
592 | public:
|
---|
593 | DECLARE_TRANSLATE_METHODS(UnattendedUbuntuInstaller)
|
---|
594 |
|
---|
595 | UnattendedUbuntuInstaller(Unattended *pParent)
|
---|
596 | : UnattendedDebianInstaller(pParent, "ubuntu_preseed.cfg")
|
---|
597 | { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
|
---|
598 | ~UnattendedUbuntuInstaller() {}
|
---|
599 | };
|
---|
600 |
|
---|
601 |
|
---|
602 | /**
|
---|
603 | * RHEL 6 installer.
|
---|
604 | *
|
---|
605 | * This serves as a base for the kickstart based installers.
|
---|
606 | */
|
---|
607 | class UnattendedRhel6Installer : public UnattendedLinuxInstaller
|
---|
608 | {
|
---|
609 | public:
|
---|
610 | DECLARE_TRANSLATE_METHODS(UnattendedRhel6Installer)
|
---|
611 |
|
---|
612 | UnattendedRhel6Installer(Unattended *pParent,
|
---|
613 | const char *pszMainScriptTemplateName = "redhat67_ks.cfg",
|
---|
614 | const char *pszPostScriptTemplateName = "redhat_postinstall.sh",
|
---|
615 | const char *pszMainScriptFilename = "ks.cfg")
|
---|
616 | : UnattendedLinuxInstaller(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
|
---|
617 | {
|
---|
618 | Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded());
|
---|
619 | Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO());
|
---|
620 | mStrDefaultExtraInstallKernelParameters.assign(" ks=cdrom:/").append(pszMainScriptFilename).append(' ');
|
---|
621 | mArrStrRemoveInstallKernelParameters.append("rd.live.check"); /* Disables the checkisomd5 step. Required for VISO. */
|
---|
622 | }
|
---|
623 | ~UnattendedRhel6Installer() {}
|
---|
624 |
|
---|
625 | bool isAuxiliaryIsoIsVISO() { return true; }
|
---|
626 | bool isOriginalIsoNeeded() const { return false; }
|
---|
627 |
|
---|
628 | protected:
|
---|
629 | HRESULT addFilesToAuxVisoVectors(RTCList<RTCString> &rVecArgs, RTCList<RTCString> &rVecFiles,
|
---|
630 | RTVFS hVfsOrgIso, bool fOverwrite);
|
---|
631 | };
|
---|
632 |
|
---|
633 | /**
|
---|
634 | * RHEL 7 installer (same as RHEL 6).
|
---|
635 | * The class was added for better handling any possible subtle difference between RHEL6 and RHEL7.
|
---|
636 | */
|
---|
637 | class UnattendedRhel7Installer : public UnattendedRhel6Installer
|
---|
638 | {
|
---|
639 | public:
|
---|
640 | DECLARE_TRANSLATE_METHODS(UnattendedRhel7Installer)
|
---|
641 |
|
---|
642 | UnattendedRhel7Installer(Unattended *pParent)
|
---|
643 | : UnattendedRhel6Installer(pParent)
|
---|
644 | { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
|
---|
645 |
|
---|
646 | UnattendedRhel7Installer(Unattended *pParent,
|
---|
647 | const char *pszMainScriptTemplateName,
|
---|
648 | const char *pszPostScriptTemplateName,
|
---|
649 | const char *pszMainScriptFilename)
|
---|
650 | : UnattendedRhel6Installer(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
|
---|
651 | { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
|
---|
652 | ~UnattendedRhel7Installer() {}
|
---|
653 | };
|
---|
654 |
|
---|
655 |
|
---|
656 | /**
|
---|
657 | * RHEL 8 installer (same as RHEL 7).
|
---|
658 | * The class was added for better handling any possible subtle difference between RHEL7 and RHEL8.
|
---|
659 | */
|
---|
660 | class UnattendedRhel8Installer : public UnattendedRhel7Installer
|
---|
661 | {
|
---|
662 | public:
|
---|
663 | DECLARE_TRANSLATE_METHODS(UnattendedRhel8Installer)
|
---|
664 |
|
---|
665 | UnattendedRhel8Installer(Unattended *pParent)
|
---|
666 | : UnattendedRhel7Installer(pParent)
|
---|
667 | { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
|
---|
668 |
|
---|
669 | UnattendedRhel8Installer(Unattended *pParent,
|
---|
670 | const char *pszMainScriptTemplateName,
|
---|
671 | const char *pszPostScriptTemplateName,
|
---|
672 | const char *pszMainScriptFilename)
|
---|
673 | : UnattendedRhel7Installer(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
|
---|
674 | { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
|
---|
675 | ~UnattendedRhel8Installer() {}
|
---|
676 | };
|
---|
677 |
|
---|
678 |
|
---|
679 | /**
|
---|
680 | * RHEL 5 installer (same as RHEL 6, except for the kickstart template).
|
---|
681 | */
|
---|
682 | class UnattendedRhel5Installer : public UnattendedRhel6Installer
|
---|
683 | {
|
---|
684 | public:
|
---|
685 | DECLARE_TRANSLATE_METHODS(UnattendedRhel5Installer)
|
---|
686 |
|
---|
687 | UnattendedRhel5Installer(Unattended *pParent) : UnattendedRhel6Installer(pParent, "rhel5_ks.cfg") {}
|
---|
688 | ~UnattendedRhel5Installer() {}
|
---|
689 | };
|
---|
690 |
|
---|
691 |
|
---|
692 | /**
|
---|
693 | * RHEL 4 installer (same as RHEL 6, except for the kickstart template).
|
---|
694 | */
|
---|
695 | class UnattendedRhel4Installer : public UnattendedRhel6Installer
|
---|
696 | {
|
---|
697 | public:
|
---|
698 | DECLARE_TRANSLATE_METHODS(UnattendedRhel4Installer)
|
---|
699 |
|
---|
700 | UnattendedRhel4Installer(Unattended *pParent) : UnattendedRhel6Installer(pParent, "rhel4_ks.cfg") {}
|
---|
701 | ~UnattendedRhel4Installer() {}
|
---|
702 | };
|
---|
703 |
|
---|
704 |
|
---|
705 | /**
|
---|
706 | * RHEL 3 installer (same as RHEL 6, except for the kickstart template).
|
---|
707 | */
|
---|
708 | class UnattendedRhel3Installer : public UnattendedRhel6Installer
|
---|
709 | {
|
---|
710 | public:
|
---|
711 | DECLARE_TRANSLATE_METHODS(UnattendedRhel3Installer)
|
---|
712 |
|
---|
713 | UnattendedRhel3Installer(Unattended *pParent) : UnattendedRhel6Installer(pParent, "rhel3_ks.cfg") {}
|
---|
714 | ~UnattendedRhel3Installer() {}
|
---|
715 | };
|
---|
716 |
|
---|
717 |
|
---|
718 | /**
|
---|
719 | * Fedora installer (same as RHEL 6, except for the template).
|
---|
720 | */
|
---|
721 | class UnattendedFedoraInstaller : public UnattendedRhel6Installer
|
---|
722 | {
|
---|
723 | public:
|
---|
724 | DECLARE_TRANSLATE_METHODS(UnattendedFedoraInstaller)
|
---|
725 |
|
---|
726 | UnattendedFedoraInstaller(Unattended *pParent)
|
---|
727 | : UnattendedRhel6Installer(pParent, "fedora_ks.cfg")
|
---|
728 | { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
|
---|
729 | ~UnattendedFedoraInstaller() {}
|
---|
730 | };
|
---|
731 |
|
---|
732 |
|
---|
733 | /**
|
---|
734 | * Oracle Linux 6 installer. Same as RHEL 6, except for the templates.
|
---|
735 | * The reason of adding new class is to sepatate the RHEL from OL.
|
---|
736 | */
|
---|
737 | class UnattendedOracleLinux6Installer : public UnattendedRhel6Installer
|
---|
738 | {
|
---|
739 | public:
|
---|
740 | DECLARE_TRANSLATE_METHODS(UnattendedOracleLinux6Installer)
|
---|
741 |
|
---|
742 | UnattendedOracleLinux6Installer(Unattended *pParent,
|
---|
743 | const char *pszMainScriptTemplateName = "ol_ks.cfg",
|
---|
744 | const char *pszPostScriptTemplateName = "ol_postinstall.sh",
|
---|
745 | const char *pszMainScriptFilename = "ks.cfg")
|
---|
746 | : UnattendedRhel6Installer(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
|
---|
747 | { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
|
---|
748 | ~UnattendedOracleLinux6Installer() {}
|
---|
749 | };
|
---|
750 |
|
---|
751 |
|
---|
752 | /**
|
---|
753 | * Oracle Linux 7 installer. Same as OL 6.
|
---|
754 | * The class was added for better handling any possible subtle difference between OL6 and OL7.
|
---|
755 | */
|
---|
756 | class UnattendedOracleLinux7Installer : public UnattendedOracleLinux6Installer
|
---|
757 | {
|
---|
758 | public:
|
---|
759 | DECLARE_TRANSLATE_METHODS(UnattendedOracleLinux7Installer)
|
---|
760 |
|
---|
761 | UnattendedOracleLinux7Installer(Unattended *pParent)
|
---|
762 | : UnattendedOracleLinux6Installer(pParent)
|
---|
763 | { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
|
---|
764 |
|
---|
765 | UnattendedOracleLinux7Installer(Unattended *pParent,
|
---|
766 | const char *pszMainScriptTemplateName,
|
---|
767 | const char *pszPostScriptTemplateName,
|
---|
768 | const char *pszMainScriptFilename)
|
---|
769 | : UnattendedOracleLinux6Installer(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
|
---|
770 | { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
|
---|
771 | ~UnattendedOracleLinux7Installer() {}
|
---|
772 | };
|
---|
773 |
|
---|
774 |
|
---|
775 | /**
|
---|
776 | * Oracle Linux 8 installer. Same as OL 7.
|
---|
777 | * The class was added for better handling any possible subtle difference between OL7 and OL8.
|
---|
778 | */
|
---|
779 | class UnattendedOracleLinux8Installer : public UnattendedOracleLinux7Installer
|
---|
780 | {
|
---|
781 | public:
|
---|
782 | DECLARE_TRANSLATE_METHODS(UnattendedOracleLinux8Installer)
|
---|
783 |
|
---|
784 | UnattendedOracleLinux8Installer(Unattended *pParent)
|
---|
785 | : UnattendedOracleLinux7Installer(pParent)
|
---|
786 | { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
|
---|
787 |
|
---|
788 | UnattendedOracleLinux8Installer(Unattended *pParent,
|
---|
789 | const char *pszMainScriptTemplateName,
|
---|
790 | const char *pszPostScriptTemplateName,
|
---|
791 | const char *pszMainScriptFilename)
|
---|
792 | : UnattendedOracleLinux7Installer(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
|
---|
793 | { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
|
---|
794 | ~UnattendedOracleLinux8Installer() {}
|
---|
795 | };
|
---|
796 |
|
---|
797 | #if 0 /* fixme */
|
---|
798 | /**
|
---|
799 | * SUSE linux installer.
|
---|
800 | *
|
---|
801 | * @todo needs fixing.
|
---|
802 | */
|
---|
803 | class UnattendedSuseInstaller : public UnattendedLinuxInstaller
|
---|
804 | {
|
---|
805 | public:
|
---|
806 | DECLARE_TRANSLATE_METHODS(UnattendedSuseInstaller)
|
---|
807 |
|
---|
808 | UnattendedSuseInstaller(BaseTextScript *pAlg, Unattended *pParent)
|
---|
809 | : UnattendedLinuxInstaller(pAlg, pParent, "suse_autoinstall.xml")
|
---|
810 | { Assert(isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(!isAuxiliaryIsoIsVISO()); }
|
---|
811 | ~UnattendedSuseInstaller() {}
|
---|
812 |
|
---|
813 | HRESULT setupScriptOnAuxiliaryCD(const Utf8Str &path);
|
---|
814 | };
|
---|
815 | #endif
|
---|
816 |
|
---|
817 | #endif /* !MAIN_INCLUDED_UnattendedInstaller_h */
|
---|
818 |
|
---|