FAQ:Using a Custom Install Class
From rPath Wiki
| FAQ | ||
| Question: How can I customize my appliance to skip steps during installation? How can I modify the software installed at the time of installation? | ||
Answer: You can create an install class file for your distribution or software appliance that will facilitate customization or skipping of Anaconda installer stages, and modification of the default software package selections during installation.
To do this, add a Python script to your anaconda-custom package, and have it installed in the /usr/share/anaconda/installclasses/ directory. The following represents an example install class, and a sample anaconda-custom recipe, suitable for a software appliance installation.
The Custom Install Class
| If you deviate from the naming conventions used in examples below, be sure to make all necessary updates to the example code before saving and attempting to cook the recipe. |
In this example, the class file is named custom.py, and is created in the anaconda-custom package's directory using your preferred text editor:
[you@yourhost anaconda-custom]$ $EDITOR custom.py
Use the following content for this file:
from installclass import BaseInstallClass from rhpl.translate import * from constants import * import os import iutil class InstallClass(BaseInstallClass): hidden = 0 id = "testclass" name = N_("r_Test Install Class") pixmap = "icon.png" description = N_("Software Appliance Installation") sortPriority = 100 showLoginChoice = 1 def setSteps(self, dispatch): BaseInstallClass.setSteps(self, dispatch); # Skip a bunch of steps--should be fairly self-explanatory. dispatch.skipStep("partitionmethod") dispatch.skipStep("partition") dispatch.skipStep("authentication") dispatch.skipStep("bootloader") dispatch.skipStep("network") dispatch.skipStep("package-selection") dispatch.skipStep("firewall") dispatch.skipStep("confirminstall") def setGroupSelection(self, grpset, intf): # Automatically select "Everything" in package selection. grpset.unselectAll() grpset.selectGroup("everything") def setInstallData(self, id): BaseInstallClass.setInstallData(self, id) # Default to clear ALL partitions on the system. You will be prompted first. BaseInstallClass.setDefaultPartitioning(self, id.partitions, CLEARPART_TYPE_ALL)
Notice the lines in this file beginning with dispatch.skipStep? Those lines tell the installer to skip a particular stage during installation. For example, the line below instructs the installer to skip configuration of the firewall:
dispatch.skipStep("firewall")
When firewall configuration is skipped in this manner, the configuration will default to enabling the firewall and blocking all incoming traffic. If your appliance or distribution requires that the firewall allow certain incoming connections, but you wish to define them and skip the firewall stage of installation, add a lines similar to the following to the end of your custom.py file:
self.setFirewall(id, ports = ['22:tcp', '80:tcp'])
The example above enables the firewall, but allows incoming ssh and http connections on ports 22 and 80 respectively.
anaconda-custom.recipe
Now, create or edit the anaconda-custom.recipe file in your anaconda-custom package's directory; you can optionally modify the version string if necessary, or specify a different class filename if you did not use the custom.py file naming convention for your class file.
Example content for the anaconda-custom recipe:
# # Copyright (c) 2005 rPath, Inc. # This file is distributed under the terms of the MIT License. # A copy is available at http://www.rpath.com/permanent/mit-license.html # class AnacondaCustom(PackageRecipe): name = 'anaconda-custom' version = '0.1' def setup(r): r.addSource('custom.py', dir = '/usr/share/anaconda/installclasses/') r.addArchive('pixmaps.tar.gz', dir = '/usr/share/anaconda/')
Save this file, then add this file and the custom.py class file to your anaconda-custom package:
[you@yourhost anaconda-custom]$ cvc add custom.py anaconda-custom.recipe
Next, cook the recipe:
[you@yourhost anaconda-custom]$ cvc cook anaconda-custom.recipe
If this cook is successful, you can commit and cook the anaconda-custom package into your project repository:
[you@yourhost anaconda-custom]$ cvc commit [you@yourhost anaconda-custom]$ cvc cook anaconda-custom
When the anaconda-custom package has been cooked into your project repository, it will be used automatically for subsequent builds.
| Remember to generate and download an installable ISO build for the project to test installation appearance and behavior. VMware® builds skip the installation process and cannot be used for such verification. |
