VirtualBox

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

Last change on this file since 101695 was 101695, checked in by vboxsync, 15 months ago

Main/UnattendedInstaller: Move editDebianGrubCfg() to the base UnattendedLinuxInstaller as it will come in handy for other distributions as well, bugref:10516

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 38.1 KB
Line 
1/* $Id: UnattendedInstaller.h 101695 2023-11-01 10:41:27Z 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.virtualbox.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', and validation kit ISO to '/vboxvalidationkit'.
345 *
346 * @returns COM status code.
347 * @param rVecArgs The ISO maker argument list that will be turned into
348 * a .viso-file.
349 * @param rVecFiles The list of files we've created. This is for
350 * cleaning up at the end.
351 * @param hVfsOrgIso The VFS handle to the original ISO in case files
352 * needs to be added from it.
353 * @param fOverwrite Whether to overwrite files or not.
354 */
355 virtual HRESULT addFilesToAuxVisoVectors(RTCList<RTCString> &rVecArgs, RTCList<RTCString> &rVecFiles,
356 RTVFS hVfsOrgIso, bool fOverwrite);
357
358 /**
359 * Saves the given script to disk and adds it to the .viso-file vectors.
360 *
361 * @returns COM status code.
362 * @param pEditor The script to add.
363 * @param rVecArgs The ISO maker argument list that will be turned into
364 * a .viso-file.
365 * @param rVecFiles The list of files we've created. This is for
366 * cleaning up at the end.
367 * @param fOverwrite Whether to overwrite files or not.
368 */
369 HRESULT addScriptToVisoVectors(BaseTextScript *pEditor, RTCList<RTCString> &rVecArgs,
370 RTCList<RTCString> &rVecFiles, bool fOverwrite);
371
372 /**
373 * Writes out the .viso-file to disk.
374 *
375 * @returns COM status code.
376 * @param rVecArgs The ISO maker argument list to write out.
377 * @param pszFilename The filename.
378 * @param fOverwrite Whether to overwrite the destination file or not.
379 */
380 HRESULT finalizeAuxVisoFile(RTCList<RTCString> const &rVecArgs, const char *pszFilename, bool fOverwrite);
381
382 /**
383 * Loads @a pszFilename from @a hVfsOrgIso into @a pEditor and parses it.
384 *
385 * @returns COM status code.
386 * @param hVfsOrgIso The handle to the original installation ISO.
387 * @param pszFilename The filename to open and load from the ISO.
388 * @param pEditor The editor instance to load the file into and
389 * do the parseing with.
390 */
391 HRESULT loadAndParseFileFromIso(RTVFS hVfsOrgIso, const char *pszFilename, AbstractScript *pEditor);
392};
393
394
395/**
396 * Windows installer, for versions up to xp 64 / w2k3.
397 */
398class UnattendedWindowsSifInstaller : public UnattendedInstaller
399{
400public:
401 DECLARE_TRANSLATE_METHODS(UnattendedWindowsSifInstaller)
402
403 UnattendedWindowsSifInstaller(Unattended *pParent)
404 : UnattendedInstaller(pParent,
405 "win_nt5_unattended.sif", "win_postinstall.cmd",
406 "WINNT.SIF", "VBOXPOST.CMD")
407 {
408 Assert(isOriginalIsoNeeded()); Assert(isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); Assert(!bootFromAuxiliaryIso());
409 mStrAuxiliaryInstallDir = "A:\\";
410 }
411 ~UnattendedWindowsSifInstaller() {}
412
413 bool isAuxiliaryFloppyNeeded() const { return true; }
414 bool bootFromAuxiliaryIso() const { return false; }
415
416};
417
418/**
419 * Windows installer, for versions starting with Vista.
420 */
421class UnattendedWindowsXmlInstaller : public UnattendedInstaller
422{
423public:
424 DECLARE_TRANSLATE_METHODS(UnattendedWindowsXmlInstaller)
425
426 UnattendedWindowsXmlInstaller(Unattended *pParent)
427 : UnattendedInstaller(pParent,
428 "win_nt6_unattended.xml", "win_postinstall.cmd",
429 "autounattend.xml", "VBOXPOST.CMD")
430 {
431 Assert(isOriginalIsoNeeded()); Assert(isAuxiliaryFloppyNeeded() || isAuxiliaryIsoNeeded()); Assert(isAuxiliaryIsoIsVISO()); Assert(!bootFromAuxiliaryIso());
432 if (isAuxiliaryFloppyNeeded())
433 mStrAuxiliaryInstallDir = "A:\\";
434 else if (bootFromAuxiliaryIso())
435 mStrAuxiliaryInstallDir = "D:\\";
436 else
437 mStrAuxiliaryInstallDir = "E:\\";
438 }
439 ~UnattendedWindowsXmlInstaller() {}
440
441 bool isAuxiliaryFloppyNeeded() const { return !mpParent->i_isFirmwareEFI(); }
442 bool isAuxiliaryIsoNeeded() const { return UnattendedInstaller::isAuxiliaryIsoNeeded() || mpParent->i_isFirmwareEFI(); }
443 bool isAuxiliaryIsoIsVISO() const { return true; }
444 bool bootFromAuxiliaryIso() const { return false; }
445};
446
447
448/**
449 * OS/2 installer.
450 */
451class UnattendedOs2Installer : public UnattendedInstaller
452{
453public:
454 DECLARE_TRANSLATE_METHODS(UnattendedOs2Installer)
455
456 UnattendedOs2Installer(Unattended *pParent, Utf8Str const &rStrHints);
457 ~UnattendedOs2Installer() {}
458
459 /* Remaster original ISO with auxiliary floppy used for el torito floppy emulation: */
460 bool isOriginalIsoNeeded() const RT_OVERRIDE { return false; }
461 bool isAuxiliaryFloppyNeeded() const RT_OVERRIDE { return true; }
462 bool isAuxiliaryIsoNeeded() const RT_OVERRIDE { return true; }
463
464protected:
465 HRESULT replaceAuxFloppyImageBootSector(RTVFSFILE hVfsFile) RT_NOEXCEPT;
466 HRESULT newAuxFloppyImage(const char *pszFilename, bool fOverwrite, PRTVFSFILE phVfsFile) RT_OVERRIDE;
467 HRESULT copyFilesToAuxFloppyImage(RTVFS hVfs) RT_OVERRIDE;
468 HRESULT addFilesToAuxVisoVectors(RTCList<RTCString> &rVecArgs, RTCList<RTCString> &rVecFiles,
469 RTVFS hVfsOrgIso, bool fOverwrite) RT_OVERRIDE;
470
471 HRESULT splitResponseFile() RT_NOEXCEPT;
472
473 /**
474 * Splits up the given file into sub-files and writes them out with the auxilary
475 * path base as prefix.
476 *
477 * The source file contains @@VBOX_SPLITTER_START[filename]@@ and
478 * @@VBOX_SPLITTER_END[filename]@@ markup that is used to split it up. Any
479 * text between END and START tags are ignored and can be used for comments.
480 *
481 * @returns COM status code (error info set).
482 * @param pszFileToSplit The name of the file to split.
483 * @param rVecSplitFiles Vector where names of the sub-files are appended
484 * (without any path or prefix).
485 */
486 HRESULT splitFile(const char *pszFileToSplit, RTCList<RTCString> &rVecSplitFiles) RT_NOEXCEPT;
487
488 /**
489 * Splits up the given editor output into sub-files and writes them out with the
490 * auxilary path base as prefix.
491 *
492 * The source file contains @@VBOX_SPLITTER_START[filename]@@ and
493 * @@VBOX_SPLITTER_END[filename]@@ markup that is used to split it up. Any
494 * text between END and START tags are ignored and can be used for comments.
495 *
496 * @returns COM status code (error info set).
497 * @param pEditor The editor which output should be split.
498 * @param rVecSplitFiles Vector where names of the sub-files are appended
499 * (without any path or prefix).
500 */
501 HRESULT splitFile(BaseTextScript *pEditor, RTCList<RTCString> &rVecSplitFiles) RT_NOEXCEPT;
502
503 HRESULT splitFileInner(const char *pszFileToSplit, RTCList<RTCString> &rVecSplitFiles,
504 const char *pszSrc, size_t cbLeft) RT_NOEXCEPT;
505
506 static int patchTestCfg(uint8_t *pbFile, size_t cbFile, const char *pszFilename, UnattendedOs2Installer *pThis);
507 static int patchOs2Ldr(uint8_t *pbFile, size_t cbFile, const char *pszFilename, UnattendedOs2Installer *pThis);
508
509 /** The OS2SE20.SRC path ("\\OS2IMAGES"). */
510 Utf8Str mStrOs2Images;
511 /** Files split out from os2_response_files.rsp (bare filenames, no paths). */
512 RTCList<RTCString> mVecSplitFiles;
513};
514
515
516
517/**
518 * Base class for the unattended linux installers.
519 */
520class UnattendedLinuxInstaller : public UnattendedInstaller
521{
522protected:
523 /** Array of linux parameter patterns that should be removed by editIsoLinuxCfg.
524 * The patterns are proceed by RTStrSimplePatternNMatch. */
525 RTCList<RTCString, RTCString *> mArrStrRemoveInstallKernelParameters;
526
527public:
528 DECLARE_TRANSLATE_METHODS(UnattendedLinuxInstaller)
529
530 UnattendedLinuxInstaller(Unattended *pParent,
531 const char *pszMainScriptTemplateName, const char *pszPostScriptTemplateName,
532 const char *pszMainScriptFilename, const char *pszPostScriptFilename = "vboxpostinstall.sh")
533 : UnattendedInstaller(pParent,
534 pszMainScriptTemplateName, pszPostScriptTemplateName,
535 pszMainScriptFilename, pszPostScriptFilename) {}
536 ~UnattendedLinuxInstaller() {}
537
538 bool isAuxiliaryIsoNeeded() const { return true; }
539
540protected:
541 /**
542 * Performs basic edits on a isolinux.cfg file.
543 *
544 * @returns COM status code
545 * @param pEditor Editor with the isolinux.cfg file loaded and parsed.
546 */
547 virtual HRESULT editIsoLinuxCfg(GeneralTextScript *pEditor);
548 /**
549 * Performs basic common edits on a isolinux.cfg and menu configuration file(s) (txt.cfg or menu.cfg etc).
550 *
551 * @returns COM status code
552 * @param pEditor Editor with the isolinux.cfg file loaded and parsed.
553 */
554 virtual HRESULT editIsoLinuxCommon(GeneralTextScript *pEditor);
555
556 /**
557 * Performs basic edits on grub configuration file (grub.cfg).
558 *
559 * @returns COM status code
560 * @param pEditor Editor with the grub.cfg file loaded and parsed.
561 */
562 virtual HRESULT editGrubCfg(GeneralTextScript *pEditor);
563};
564
565
566/**
567 * Debian installer.
568 *
569 * This will remaster the orignal ISO and therefore be producing a .viso-file.
570 */
571class UnattendedDebianInstaller : public UnattendedLinuxInstaller
572{
573public:
574 DECLARE_TRANSLATE_METHODS(UnattendedDebianInstaller)
575
576 UnattendedDebianInstaller(Unattended *pParent,
577 const char *pszMainScriptTemplateName = "debian_preseed.cfg",
578 const char *pszPostScriptTemplateName = "debian_postinstall.sh",
579 const char *pszMainScriptFilename = "preseed.cfg")
580 : UnattendedLinuxInstaller(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
581 {
582 Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded());
583 Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO());
584 mStrDefaultExtraInstallKernelParameters.setNull();
585 mStrDefaultExtraInstallKernelParameters += " auto=true";
586 mStrDefaultExtraInstallKernelParameters.append(" preseed/file=/cdrom/").append(pszMainScriptFilename);
587 mStrDefaultExtraInstallKernelParameters += " priority=critical";
588 mStrDefaultExtraInstallKernelParameters += " quiet";
589 mStrDefaultExtraInstallKernelParameters += " splash";
590 mStrDefaultExtraInstallKernelParameters += " noprompt"; /* no questions about things like CD/DVD ejections */
591 mStrDefaultExtraInstallKernelParameters += " noshell"; /* No shells on VT1-3 (debian, not ubuntu). */
592 mStrDefaultExtraInstallKernelParameters += " automatic-ubiquity"; // ubiquity
593 // the following can probably go into the preseed.cfg:
594 mStrDefaultExtraInstallKernelParameters.append(" debian-installer/locale=").append(pParent->i_getLocale());
595 mStrDefaultExtraInstallKernelParameters += " keyboard-configuration/layoutcode=us";
596 mStrDefaultExtraInstallKernelParameters += " languagechooser/language-name=English"; /** @todo fixme */
597 mStrDefaultExtraInstallKernelParameters.append(" localechooser/supported-locales=").append(pParent->i_getLocale()).append(".UTF-8");
598 mStrDefaultExtraInstallKernelParameters.append(" countrychooser/shortlist=").append(pParent->i_getCountry()); // ubiquity?
599 mStrDefaultExtraInstallKernelParameters += " --";
600 }
601 ~UnattendedDebianInstaller() {}
602
603 bool isOriginalIsoNeeded() const { return false; }
604
605protected:
606 HRESULT addFilesToAuxVisoVectors(RTCList<RTCString> &rVecArgs, RTCList<RTCString> &rVecFiles,
607 RTVFS hVfsOrgIso, bool fOverwrite);
608 /**
609 * Performs basic edits on menu configuration file(s) of isolinux (txt.cfg or menu.cfg etc).
610 *
611 * @returns COM status code
612 * @param pEditor Editor with the menu config. file loaded and parsed.
613 */
614 HRESULT editDebianMenuCfg(GeneralTextScript *pEditor);
615
616 /**
617 * Performs basic edits on a isolinux.cfg file.
618 *
619 * @returns COM status code
620 * @param pEditor Editor with the isolinux.cfg file loaded and parsed.
621 * @param pszMenuConfigFileName Name of the menu config file to include in isolinux.txt. On Debians (at least)
622 it includes the kernel command line with our preseed file and command line argument.
623 */
624 virtual HRESULT editIsoLinuxCfg(GeneralTextScript *pEditor, const char *pszMenuConfigFileName);
625
626private:
627
628 /**
629 * Tries to set label name of a label line.
630 *
631 * @returns true if label line is found and label name can be set.
632 * @param pEditor Editor with the menu configuration file loaded and parsed.
633 * @param vecLineNumbers Indices of the label lines (within pEditor data).
634 * @param pszKeyWord The keyword searched within the original label name.
635 * @param pszNewLabelName The new name of the label.
636 */
637 bool modifyLabelLine(GeneralTextScript *pEditor, const std::vector<size_t> &vecLineNumbers,
638 const char *pszKeyWord, const char *pszNewLabelName);
639};
640
641
642/**
643 * Ubuntu installer (same as debian, except for the template).
644 */
645class UnattendedUbuntuInstaller : public UnattendedDebianInstaller
646{
647public:
648 DECLARE_TRANSLATE_METHODS(UnattendedUbuntuInstaller)
649
650 UnattendedUbuntuInstaller(Unattended *pParent)
651 : UnattendedDebianInstaller(pParent, "ubuntu_preseed.cfg")
652 { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
653 ~UnattendedUbuntuInstaller() {}
654};
655
656/**
657 * RHEL installer.
658 *
659 * This serves as a base for the kickstart based installers.
660 */
661class UnattendedRhelInstaller : public UnattendedLinuxInstaller
662{
663public:
664 DECLARE_TRANSLATE_METHODS(UnattendedRhelInstaller)
665
666 UnattendedRhelInstaller(Unattended *pParent,
667 const char *pszMainScriptTemplateName,
668 const char *pszPostScriptTemplateName,
669 const char *pszMainScriptFilename)
670 : UnattendedLinuxInstaller(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
671 {}
672 ~UnattendedRhelInstaller() {}
673
674 bool isAuxiliaryIsoIsVISO() { return true; }
675 bool isOriginalIsoNeeded() const { return false; }
676
677protected:
678 HRESULT addFilesToAuxVisoVectors(RTCList<RTCString> &rVecArgs, RTCList<RTCString> &rVecFiles,
679 RTVFS hVfsOrgIso, bool fOverwrite);
680};
681
682/**
683 * RHEL 6 installer.
684 *
685 */
686class UnattendedRhel6Installer : public UnattendedRhelInstaller
687{
688public:
689 DECLARE_TRANSLATE_METHODS(UnattendedRhel6Installer)
690
691 UnattendedRhel6Installer(Unattended *pParent,
692 const char *pszMainScriptTemplateName = "redhat67_ks.cfg",
693 const char *pszPostScriptTemplateName = "redhat_postinstall.sh",
694 const char *pszMainScriptFilename = "ks.cfg")
695 : UnattendedRhelInstaller(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
696 {
697 Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded());
698 Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO());
699 mStrDefaultExtraInstallKernelParameters.assign(" ks=cdrom:/").append(pszMainScriptFilename).append(' ');
700 mArrStrRemoveInstallKernelParameters.append("rd.live.check"); /* Disables the checkisomd5 step. Required for VISO. */
701 }
702 ~UnattendedRhel6Installer() {}
703};
704
705/**
706 * RHEL 7 installer (same as RHEL 6).
707 * The class was added for better handling any possible subtle difference between RHEL6 and RHEL7.
708 */
709class UnattendedRhel7Installer : public UnattendedRhel6Installer
710{
711public:
712 DECLARE_TRANSLATE_METHODS(UnattendedRhel7Installer)
713
714 UnattendedRhel7Installer(Unattended *pParent)
715 : UnattendedRhel6Installer(pParent)
716 { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
717
718 UnattendedRhel7Installer(Unattended *pParent,
719 const char *pszMainScriptTemplateName,
720 const char *pszPostScriptTemplateName,
721 const char *pszMainScriptFilename)
722 : UnattendedRhel6Installer(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
723 { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
724 ~UnattendedRhel7Installer() {}
725};
726
727
728/**
729 * RHEL 8 installer (same as RHEL 7).
730 * The class was added for better handling any possible subtle difference between RHEL7 and RHEL8.
731 */
732class UnattendedRhel8Installer : public UnattendedRhel7Installer
733{
734public:
735 DECLARE_TRANSLATE_METHODS(UnattendedRhel8Installer)
736
737 UnattendedRhel8Installer(Unattended *pParent)
738 : UnattendedRhel7Installer(pParent)
739 { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
740
741 UnattendedRhel8Installer(Unattended *pParent,
742 const char *pszMainScriptTemplateName,
743 const char *pszPostScriptTemplateName,
744 const char *pszMainScriptFilename)
745 : UnattendedRhel7Installer(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
746 { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
747 ~UnattendedRhel8Installer() {}
748};
749
750
751/**
752 * RHEL 5 installer (same as RHEL 6, except for the kickstart template).
753 */
754class UnattendedRhel5Installer : public UnattendedRhel6Installer
755{
756public:
757 DECLARE_TRANSLATE_METHODS(UnattendedRhel5Installer)
758
759 UnattendedRhel5Installer(Unattended *pParent) : UnattendedRhel6Installer(pParent, "rhel5_ks.cfg") {}
760 ~UnattendedRhel5Installer() {}
761};
762
763
764/**
765 * RHEL 4 installer (same as RHEL 6, except for the kickstart template).
766 */
767class UnattendedRhel4Installer : public UnattendedRhel6Installer
768{
769public:
770 DECLARE_TRANSLATE_METHODS(UnattendedRhel4Installer)
771
772 UnattendedRhel4Installer(Unattended *pParent) : UnattendedRhel6Installer(pParent, "rhel4_ks.cfg") {}
773 ~UnattendedRhel4Installer() {}
774};
775
776
777/**
778 * RHEL 3 installer (same as RHEL 6, except for the kickstart template).
779 */
780class UnattendedRhel3Installer : public UnattendedRhel6Installer
781{
782public:
783 DECLARE_TRANSLATE_METHODS(UnattendedRhel3Installer)
784
785 UnattendedRhel3Installer(Unattended *pParent) : UnattendedRhel6Installer(pParent, "rhel3_ks.cfg") {}
786 ~UnattendedRhel3Installer() {}
787};
788
789
790/**
791 * Fedora installer (same as RHEL 6, except for the template).
792 */
793class UnattendedFedoraInstaller : public UnattendedRhel6Installer
794{
795public:
796 DECLARE_TRANSLATE_METHODS(UnattendedFedoraInstaller)
797
798 UnattendedFedoraInstaller(Unattended *pParent)
799 : UnattendedRhel6Installer(pParent, "fedora_ks.cfg")
800 { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
801 ~UnattendedFedoraInstaller() {}
802};
803
804
805/**
806 * Oracle Linux 6 installer. Same as RHEL 6, except for the templates.
807 * The reason of adding new class is to sepatate the RHEL from OL.
808 */
809class UnattendedOracleLinux6Installer : public UnattendedRhel6Installer
810{
811public:
812 DECLARE_TRANSLATE_METHODS(UnattendedOracleLinux6Installer)
813
814 UnattendedOracleLinux6Installer(Unattended *pParent,
815 const char *pszMainScriptTemplateName = "ol_ks.cfg",
816 const char *pszPostScriptTemplateName = "ol_postinstall.sh",
817 const char *pszMainScriptFilename = "ks.cfg")
818 : UnattendedRhel6Installer(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
819 { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
820 ~UnattendedOracleLinux6Installer() {}
821};
822
823
824/**
825 * Oracle Linux 7 installer. Same as OL 6.
826 * The class was added for better handling any possible subtle difference between OL6 and OL7.
827 */
828class UnattendedOracleLinux7Installer : public UnattendedOracleLinux6Installer
829{
830public:
831 DECLARE_TRANSLATE_METHODS(UnattendedOracleLinux7Installer)
832
833 UnattendedOracleLinux7Installer(Unattended *pParent)
834 : UnattendedOracleLinux6Installer(pParent)
835 { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
836
837 UnattendedOracleLinux7Installer(Unattended *pParent,
838 const char *pszMainScriptTemplateName,
839 const char *pszPostScriptTemplateName,
840 const char *pszMainScriptFilename)
841 : UnattendedOracleLinux6Installer(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
842 { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
843 ~UnattendedOracleLinux7Installer() {}
844};
845
846
847/**
848 * Oracle Linux 8 installer. Using a different kickstart file than earlier OL versions.
849 */
850class UnattendedOracleLinux8Installer : public UnattendedOracleLinux7Installer
851{
852public:
853 DECLARE_TRANSLATE_METHODS(UnattendedOracleLinux8Installer)
854
855 UnattendedOracleLinux8Installer(Unattended *pParent,
856 const char *pszMainScriptTemplateName = "ol8_ks.cfg",
857 const char *pszPostScriptTemplateName = "ol_postinstall.sh",
858 const char *pszMainScriptFilename = "ks.cfg")
859
860 : UnattendedOracleLinux7Installer(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
861 { Assert(!isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(isAuxiliaryIsoIsVISO()); }
862 ~UnattendedOracleLinux8Installer() {}
863};
864
865/**
866 * Oracle Linux 9 installer.
867 * Uses a different kickstart file since several commands/options are removed in OL9.
868 * See the ol9_ks.cfg file for comments. Also, as of OL9 kernel command argument 'ks' should have
869 * 'inst.' prefix.
870 */
871class UnattendedOracleLinux9Installer : public UnattendedRhelInstaller
872{
873public:
874 DECLARE_TRANSLATE_METHODS(UnattendedOracleLinux9Installer)
875
876 UnattendedOracleLinux9Installer(Unattended *pParent,
877 const char *pszMainScriptTemplateName = "ol9_ks.cfg",
878 const char *pszPostScriptTemplateName = "ol_postinstall.sh",
879 const char *pszMainScriptFilename = "ks.cfg")
880 : UnattendedRhelInstaller(pParent, pszMainScriptTemplateName, pszPostScriptTemplateName, pszMainScriptFilename)
881 {
882 Assert(!isOriginalIsoNeeded());
883 Assert(isAuxiliaryIsoNeeded());
884 Assert(!isAuxiliaryFloppyNeeded());
885 Assert(isAuxiliaryIsoIsVISO());
886 mStrDefaultExtraInstallKernelParameters.assign(" inst.ks=cdrom:/").append(pszMainScriptFilename).append(' ');
887 mArrStrRemoveInstallKernelParameters.append("rd.live.check"); /* Disables the checkisomd5 step. Required for VISO. */
888 }
889 ~UnattendedOracleLinux9Installer() {}
890};
891
892
893#if 0 /* fixme */
894/**
895 * SUSE linux installer.
896 *
897 * @todo needs fixing.
898 */
899class UnattendedSuseInstaller : public UnattendedLinuxInstaller
900{
901public:
902 DECLARE_TRANSLATE_METHODS(UnattendedSuseInstaller)
903
904 UnattendedSuseInstaller(BaseTextScript *pAlg, Unattended *pParent)
905 : UnattendedLinuxInstaller(pAlg, pParent, "suse_autoinstall.xml")
906 { Assert(isOriginalIsoNeeded()); Assert(isAuxiliaryIsoNeeded()); Assert(!isAuxiliaryFloppyNeeded()); Assert(!isAuxiliaryIsoIsVISO()); }
907 ~UnattendedSuseInstaller() {}
908
909 HRESULT setupScriptOnAuxiliaryCD(const Utf8Str &path);
910};
911#endif
912
913/**
914 * Base class for the unattended FreeBSD installers.
915 */
916class UnattendedFreeBsdInstaller : public UnattendedInstaller
917{
918public:
919 UnattendedFreeBsdInstaller(Unattended *pParent)
920 : UnattendedInstaller(pParent,
921 "freebsd_installer.cfg", "freebsd_postinstall.sh",
922 "installerconfig", "vboxpostinstall.sh") {}
923 ~UnattendedFreeBsdInstaller() {}
924
925 bool isAuxiliaryIsoNeeded() const { return true; }
926 bool isOriginalIsoNeeded() const { return false; }
927
928protected:
929 HRESULT addFilesToAuxVisoVectors(RTCList<RTCString> &rVecArgs, RTCList<RTCString> &rVecFiles,
930 RTVFS hVfsOrgIso, bool fOverwrite);
931};
932
933#endif /* !MAIN_INCLUDED_UnattendedInstaller_h */
Note: See TracBrowser for help on using the repository browser.

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