/usr/share/system-config-kickstart/kickstartParser.py is in system-config-kickstart 2.5.20-0ubuntu23.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | ## Kickstart Configurator - A graphical kickstart file generator
## Copyright (C) 2000, 2001, 2002, 2003 Red Hat, Inc.
## Copyright (C) 2000, 2001, 2002, 2003 Brent Fox <bfox@redhat.com>
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import string
import getopt
import sys
##
## I18N
##
import gettext
domain = 'system-config-kickstart'
gettext.bindtextdomain(domain, '/usr/share/locale')
gettext.textdomain(domain)
_ = gettext.gettext
class KickstartParser:
def __init__(self, kickstartData, file):
self.kickstartData = kickstartData
self.handlers = {
"auth" : self.kickstartData.setAuth ,
"authconfig" : self.kickstartData.setAuth ,
"bootloader" : self.kickstartData.setBootloader ,
"cdrom" : self.kickstartData.setCdrom ,
"clearpart" : self.kickstartData.setClearPart ,
## "device" : None ,
## "deviceprobe" : None ,
## "driverdisk" : None ,
"firewall" : self.kickstartData.setFirewall ,
"firstboot" : self.kickstartData.setFirstboot ,
"harddrive" : self.kickstartData.setHardDrive ,
"install" : self.kickstartData.setInstall ,
"keyboard" : self.kickstartData.setKeyboard ,
# "lang" : self.kickstartData.setLang ,
"lang" : self.kickstartData.setLang ,
"langsupport" : self.kickstartData.setLangSupport ,
## "lilo" : self.kickstartData.setLilo ,
## "lilocheck" : self.kickstartData.setLiloCheck ,
"mouse" : self.kickstartData.setMouse ,
"network" : self.kickstartData.setNetwork ,
"nfs" : self.kickstartData.setNfs ,
"part" : self.kickstartData.definePartition ,
"partition" : self.kickstartData.definePartition ,
"raid" : self.kickstartData.defineRaid ,
## "volgroup" : self.defineVolumeGroup,
## "logvol" : self.defineLogicalVolume,
"reboot" : self.kickstartData.setReboot ,
"rootpw" : self.kickstartData.setRootPw ,
"skipx" : self.kickstartData.setSkipX ,
"text" : self.kickstartData.setText ,
"timezone" : self.kickstartData.setTimezone ,
"url" : self.kickstartData.setUrl ,
"upgrade" : self.kickstartData.setUpgrade ,
"user" : self.kickstartData.setUser ,
"xconfig" : self.kickstartData.setXconfig ,
## "xdisplay" : None ,
"zerombr" : self.kickstartData.setZeroMbr ,
"interactive" : self.kickstartData.setInteractive ,
## "autostep" : self.kickstartData.setAutoStep ,
## "firstboot" : self.kickstartData.setFirstboot ,
}
self.readKickstartFile(file)
def readKickstartFile(self, file):
try:
self.lines = open(file, "r").readlines()
except IOError, e:
print _("Cannot open %s: %s") % (file, e.strerror)
sys.exit(2)
try:
fd = open(file, "r")
except IOError, e:
print _("Cannot open %s: %s") % (file, e.strerror)
sys.exit(2)
line = fd.readline()
mainList = []
packageList = []
preList = []
postList = []
list = mainList
#Separate the file into main, package, pre and post lists
for line in self.lines:
line = string.strip(line)
if line == "":
continue
elif line[:9] == "%packages":
list = packageList
elif line[:4] == "%pre":
list = preList
elif line[:5] == "%post":
list = postList
list.append(line)
for line in mainList:
line = string.strip(line)
if line == "":
continue
elif line[:10] == "#platform=":
key, value = string.split(line, "=")
self.kickstartData.setPlatform(value)
elif line[0] == "#":
continue
elif line != "":
tokens = string.split(line)
if tokens[0] in self.handlers.keys():
if self.handlers[tokens[0]]:
self.handlers[tokens[0]](tokens[1:])
if packageList != []:
tokens = string.split(packageList[0])
groupList = []
individualList = []
for pkg in packageList[1:]:
if pkg[0] == "@":
pkg = string.replace(pkg, "@", "")
pkg = string.strip(pkg)
if pkg[:10] == "everything":
self.kickstartData.setEverything(True)
break
else:
groupList.append(pkg)
else:
individualList.append(pkg)
self.kickstartData.setPackageGroupList(groupList)
self.kickstartData.setIndividualPackageList(individualList)
if preList != []:
tokens = string.split(preList[0])
self.kickstartData.setPreLine(tokens[1:])
self.kickstartData.setPreList(preList[1:])
if postList != []:
tokens = string.split(postList[0])
self.kickstartData.setPostLine(tokens[1:])
self.kickstartData.setPostList(postList[1:])
|