VirtualBox

source: vbox/trunk/src/VBox/Main/include/UnattendedInstaller.h@ 102116

最後變更 在這個檔案從102116是 102116,由 vboxsync 提交於 16 月 前

Main/Unattended: added user payload to unattended. bugref:10446

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

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