summaryrefslogtreecommitdiffstats
path: root/src/kadmin/testing/scripts/init_db
diff options
context:
space:
mode:
Diffstat (limited to 'src/kadmin/testing/scripts/init_db')
0 files changed, 0 insertions, 0 deletions
d='n79' href='#n79'>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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270
#
# kickstart.py: kickstart install support
#
# Copyright 1999-2003 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

import iutil
import isys
import os
from installclass import BaseInstallClass
from partitioning import *
from autopart import *
from fsset import *
from flags import flags
from constants import *
import sys
import raid
import string
import partRequests

from rhpl.translate import _

KS_MISSING_PROMPT = 0
KS_MISSING_IGNORE = 1

class Script:
    def __repr__(self):
	str = ("(s: '%s' i: %s c: %d)") %  \
	    (self.script, self.interp, self.inChroot)
	return string.replace(str, "\n", "|")

    def __init__(self, script, interp, inChroot):
	self.script = script
	self.interp = interp
	self.inChroot = inChroot

    def run(self, chroot, serial):
	scriptRoot = "/"
	if self.inChroot:
	    scriptRoot = chroot

	path = scriptRoot + "/tmp/ks-script"

	f = open(path, "w")
	f.write(self.script)
	f.close()
	os.chmod(path, 0700)

	if serial:
	    messages = "/tmp/ks-script.log"
	else:
	    messages = "/dev/tty3"

	rc = iutil.execWithRedirect(self.interp,
				    [self.interp,"/tmp/ks-script"],
				    stdout = messages, stderr = messages,
				    root = scriptRoot)

	if rc != 0:
	    log("WARNING - Error code %s encountered running a kickstart %%pre/%%post script", rc)

	os.unlink(path)

class KickstartBase(BaseInstallClass):
    name = "kickstart"
    
    def postAction(self, rootPath, serial):
	log("Running kickstart %%post script(s)")
	for script in self.postScripts:
	    script.run(rootPath, serial)
	log("All kickstart %%post script(s) have been run")

    def doRootPw(self, id, args):
	(args, extra) = isys.getopt(args, '', [ 'iscrypted' ])

	isCrypted = 0
	for n in args:
	    (str, arg) = n
	    if (str == '--iscrypted'):
		isCrypted = 1
                
	if len(extra) != 1:
	    raise ValueError, "a single argument is expected to rootPw"

	self.setRootPassword(id, extra[0], isCrypted = isCrypted)
	self.skipSteps.append("accounts")
	
    def doFirewall(self, id, args):
	(args, extra) = isys.getopt(args, '',
		[ 'dhcp', 'ssh', 'telnet', 'smtp', 'http', 'ftp',
		  'port=', 'high', 'medium', 'disabled', 'trust=' ])
		  
	dhcp = 0
	ssh = 0
	telnet = 0
	smtp = 0
	http = 0
	ftp = 0
	policy = 0
	enable = -1
	trusts = []
	ports = ""
	
	for n in args:
	    (str, arg) = n
	    if str == '--dhcp':
		dhcp = 1
	    elif str == '--ssh':
		ssh = 1
	    elif str == '--telnet':
		telnet = 1
	    elif str == '--smtp':
		smtp = 1
	    elif str == '--http':
		http = 1
	    elif str == '--ftp':
		ftp = 1
	    elif str == '--high':
		policy = 0
		enable = 1
	    elif str == '--medium':
		policy = 1
		enable = 1
	    elif str == '--disabled':
		enable = 0
	    elif str == '--trust':
		trusts.append(arg)
	    elif str == '--port':
		if ports:
		    ports = '%s,%s' % (ports, arg)
		else:
		    ports = arg
	    
	self.setFirewall(id, enable, policy, trusts, ports, dhcp, ssh, telnet,
			smtp, http, ftp)
	    
    def doAuthconfig(self, id, args):
	(args, extra) = isys.getopt(args, '',
                [ 'useshadow', 'enableshadow',
		  'enablemd5',
                  'enablenis', 'nisdomain=', 'nisserver=',
                  'enableldap', 'enableldapauth', 'ldapserver=', 'ldapbasedn=',
                  'enableldaptls', 
                  'enablekrb5', 'krb5realm=', 'krb5kdc=', 'krb5adminserver=',
                  'enablehesiod', 'hesiodlhs=', 'hesiodrhs=',
                  'enablesmbauth', 'smbservers=', 'smbworkgroup=',
                  'enablecache'])

	useShadow = 0

	useMd5 = 0

	useNis = 0
	nisServer = ""
	nisDomain = ""
	nisBroadcast = 0

        useLdap = 0
        useLdapauth = 0
        useLdaptls = 0
        ldapServer = ""
        ldapBasedn = ""

        useKrb5 = 0
        krb5Realm = ""
        krb5Kdc = ""
        krb5Admin = ""

        useHesiod = 0
        hesiodLhs = ""
        hesiodRhs = ""

        useSamba = 0
        smbServers = ""
        smbWorkgroup = ""

        enableCache = 0
	
	for n in args:
	    (str, arg) = n
	    if (str == '--enablenis'):
		useNis = 1
	    elif (str == '--useshadow') or (str == '--enableshadow'):
		useShadow = 1
	    elif (str == '--enablemd5'):
		useMd5 = 1
	    elif (str == '--nisserver'):
		nisServer = arg
	    elif (str == '--nisdomain'):
		nisDomain = arg
            elif (str == '--enableldap'):
                useLdap = 1
            elif (str == '--enableldapauth'):
                useLdapauth = 1
            elif (str == '--ldapserver'):
                ldapServer = arg
            elif (str == '--ldapbasedn'):
                ldapBasedn = arg
            elif (str == '--enableldaptls'):
                useLdaptls = 1
            elif (str == '--enablekrb5'):
                useKrb5 = 1
            elif (str == '--krb5realm'):
                krb5Realm = arg
            elif (str == '--krb5kdc'):
                krb5Kdc = arg
            elif (str == '--krb5adminserver'):
                krb5Admin = arg
            elif (str == '--enablehesiod'):
                useHesiod = 1
            elif (str == '--hesiodlhs'):
                hesiodLhs = arg
            elif (str == '--hesiodrhs'):
                hesiodRhs = arg
            elif (str == '--enablesmbauth'):
                useSamba = 1
            elif (str == '--smbservers'):
                smbServers = arg
            elif (str == '--smbworkgroup'):
                smbWorkgroup = arg
            elif (str == '--enablecache'):
                enableCache = 1
                

	if useNis and not nisServer: nisBroadcast = 1
	    
	self.setAuthentication(id, useShadow, useMd5,
                               useNis, nisDomain, nisBroadcast, nisServer,
                               useLdap, useLdapauth, ldapServer,
                               ldapBasedn, useLdaptls,
                               useKrb5, krb5Realm, krb5Kdc, krb5Admin,
                               useHesiod, hesiodLhs, hesiodRhs,
                               useSamba, smbServers, smbWorkgroup,
                               enableCache)
        
	self.skipSteps.append("authentication")

    def doBootloader (self, id, args, useLilo = 0):
        (args, extra) = isys.getopt(args, '',
                [ 'append=', 'location=', 'useLilo', 'lba32',
                  'password=', 'md5pass=', 'linear', 'nolinear',
                  'upgrade'])

        validLocations = [ "mbr", "partition", "none" ]
        appendLine = ""
        location = "mbr"
        password = None
        md5pass = None
        forceLBA = 0
        linear = 1
        upgrade = 0

        for n in args:
            (str, arg) = n
            if str == '--append':
                appendLine = arg
            elif str == '--location':
                location = arg
            elif str == '--useLilo':
                useLilo = 1
	    elif str == '--linear':
		linear = 1
	    elif str == '--nolinear':
		linear = 0
            elif str == '--lba32':
                forceLBA = 1
            elif str == '--password':
                password = arg
            elif str == '--md5pass':
                md5pass = arg
            elif str == '--upgrade':
                upgrade = 1

        if location not in validLocations:
            raise ValueError, "mbr, partition, or none expected for bootloader command"
        if location == "none":
            location = None
        elif location == "partition":
            location = "boot"

        if upgrade and not id.upgrade.get():
            raise RuntimeError, "Selected upgrade mode for bootloader but not doing an upgrade"

        if upgrade:
            id.bootloader.kickstart = 1
            id.bootloader.doUpgradeOnly = 1

        
        self.showSteps.append("bootloadersetup")
                
        self.setBootloader(id, useLilo, location, linear, forceLBA,
                           password, md5pass, appendLine)
        self.skipSteps.append("upgbootloader")
        self.skipSteps.append("bootloader")
        self.skipSteps.append("bootloaderadvanced")

        if location is None:
            self.skipSteps.append("instbootloader")

    def doLilo	(self, id, args):
        self.doBootloader(id, args, useLilo = 1)

    def doFirstboot(self, id, args):
        (args, extra) = isys.getopt(args, '',
                                    ['reconfig', 'enable', 'disable'])

        fb = FIRSTBOOT_SKIP

	for n in args:
	    (str, arg) = n
	    if str == '--reconfig':
                fb = FIRSTBOOT_RECONFIG
            elif str == '--enable':
                fb = FIRSTBOOT_DEFAULT
            elif str == '--disable':
                fb = FIRSTBOOT_SKIP

        id.firstboot = fb
        
        
    def doLiloCheck (self, id, args):
        drives = isys.hardDriveDict ().keys()
	drives.sort(isys.compareDrives)
	device = drives[0]
	isys.makeDevInode(device, '/tmp/' + device)
	fd = os.open('/tmp/' + device, os.O_RDONLY)
	os.unlink('/tmp/' + device)
	block = os.read(fd, 512)
	os.close(fd)
	if block[6:10] == "LILO":
	    sys.exit(0)

    def doTimezone(self, id, args):
	(args, extra) = isys.getopt(args, '',
		[ 'utc' ])

	isUtc = 0
	
	for n in args:
	    (str, arg) = n
	    if str == '--utc':
		isUtc = 1

	self.setTimezoneInfo(id, extra[0], asUtc = isUtc)

	self.skipSteps.append("timezone")


    def doXconfig(self, id, args):
	(args, extra) = isys.getopt(args, '',
		[ 'server=', 'card=', 'videoram=',
                  'monitor=', 'hsync=', 'vsync=',
                  'resolution=', 'depth=', 
		  'startxonboot', 'noprobe', 'defaultdesktop=' ])

	if extra:
	    raise ValueError, "unexpected arguments to xconfig command"

	server = None
	card = None
        videoRam = None
	monitor = None
	hsync = None
	vsync = None
        resolution = None
        depth = None
        noProbe = 0
	startX = 0
        defaultdesktop = ""

	for n in args:
	    (str, arg) = n
	    if (str == "--noprobe"):
		noProbe = 1
	    elif (str == "--server"):
		server = arg
	    elif (str == "--card"):
		card = arg
            elif (str == "--videoram"):
                videoRam = arg
	    elif (str == "--monitor"):
		monitor = arg
	    elif (str == "--hsync"):
		hsync = arg
	    elif (str == "--vsync"):
		vsync = arg
            elif (str == "--resolution"):
                resolution = arg
            elif (str == "--depth"):
                depth = string.atoi(arg)
	    elif (str == "--startxonboot"):
		startX = 1
            elif (str == "--defaultdesktop"):
                defaultdesktop = arg

	self.configureX(id, server, card, videoRam, monitor, hsync, vsync,
                        resolution, depth, noProbe, startX)
        self.setDesktop(id, defaultdesktop)

        self.skipSteps.append("videocard")
        self.skipSteps.append("monitor")
        self.skipSteps.append("xcustom")
        self.skipSteps.append("handleX11pkgs")


    def doUpgrade(self, id, args):
	self.installType = "upgrade"
        id.upgrade.set(1)

    def doNetwork(self, id, args):
	# nodns is only used by the loader
	(args, extra) = isys.getopt(args, '',
		[ 'bootproto=', 'ip=', 'netmask=', 'gateway=', 'nameserver=',
		  'nodns', 'device=', 'hostname='])
	bootProto = "dhcp"
	ip = None
	netmask = ""
	gateway = ""
	nameserver = ""
	hostname = ""
        device = None
	for n in args:
	    (str, arg) = n
	    if str == "--bootproto":
		bootProto = arg
	    elif str == "--ip":
		ip = arg
	    elif str == "--netmask":
		netmask = arg
	    elif str == "--gateway":
		gateway = arg
	    elif str == "--nameserver":
		nameserver = arg
	    elif str == "--device":
		device = arg
	    elif str == "--hostname":
		hostname = arg

	self.setNetwork(id, bootProto, ip, netmask, device=device)
	if hostname != "":
	    self.setHostname(id, hostname)
        if nameserver != "":
            self.setNameserver(id, nameserver)
        if gateway != "":
            self.setGateway(id, gateway)

    def doLang(self, id, args):
        self.setLanguage(id, args[0])
	self.skipSteps.append("language")

    def doLangSupport (self, id, args):
        (args, extra) = isys.getopt(args, '', [ 'default=' ])
	deflang = "en_US.UTF-8"
        if args:
	    deflang = args[0][1]
	else:
	    # if they specified no default we default to en_US if
	    # they installed support for more than one lang, otherwise
	    # we default to the one language they specified support for
	    if extra is None:
		deflang = "en_US.UTF-8"
	    elif len(extra) >= 1:
		deflang = extra[0]
	    else:
		deflang = "en_US.UTF-8"
		
	self.setLanguageDefault (id, deflang)
        self.setLanguageSupport(id, extra)

        self.skipSteps.append("languagesupport")

    def doKeyboard(self, id, args):
        self.setKeyboard(id, args[0])
        id.keyboard.beenset = 1
	self.skipSteps.append("keyboard")

    def doZeroMbr(self, id, args):
        self.setZeroMbr(id, 1)

    def doMouse(self, id, args):
	(args, extra) = isys.getopt(args, '', [ 'device=', 'emulthree' ])
        mouseType = "none"
	device = None
	emulThree = 0

	for n in args:
	    (str, arg) = n
	    if str == "--device":
		device = arg
	    elif str == "--emulthree":
		emulThree = 1

	if extra:
	    mouseType = extra[0]

	if mouseType != "none":
            self.setMouse(id, mouseType, device, emulThree)

        self.skipSteps.append("mouse")

    def doReboot(self, id, args):
        self.skipSteps.append("complete")

    def doSkipX(self, id, args):
        self.skipSteps.append("videocard")
        self.skipSteps.append("monitor")
        self.skipSteps.append("xcustom")
        self.skipSteps.append("handleX11pkgs")
        self.skipSteps.append("writexconfig")
        id.xsetup.skipx = 1

    def doInteractive(self, id, args):
        self.interactive = 1

    def doAutoStep(self, id, args):
        flags.autostep = 1

    # read the kickstart config...  if parsePre is set, only parse
    # the %pre, otherwise ignore the %pre.  assume we're starting in where
    def readKickstart(self, id, file, parsePre = 0, where = "commands"):
	handlers = { 
		     "auth"		: self.doAuthconfig	,
		     "authconfig"	: self.doAuthconfig	,
		     "cdrom"		: None			,
		     "clearpart"	: self.doClearPart	,
		     "device"		: None			,
		     "deviceprobe"	: None			,
		     "driverdisk"	: None			,
		     "firewall"		: self.doFirewall	,
		     "harddrive"	: None			,
		     "install"		: None          	,
		     "keyboard"		: self.doKeyboard	,
		     "lang"		: self.doLang		,
                     "langsupport"	: self.doLangSupport	,
		     "lilo"		: self.doLilo		,
                     "bootloader"       : self.doBootloader     ,
		     "lilocheck"	: self.doLiloCheck	,
		     "mouse"		: self.doMouse		,
		     "network"		: self.doNetwork	,
		     "nfs"		: None			,
		     "part"		: self.definePartition	,
		     "partition"	: self.definePartition	,
		     "raid"		: self.defineRaid	,
                     "volgroup"         : self.defineVolumeGroup,
                     "logvol"           : self.defineLogicalVolume,
		     "reboot"		: self.doReboot		,
		     "rootpw"		: self.doRootPw		,
		     "skipx"		: self.doSkipX		,
		     "text"		: None			,
		     "timezone"		: self.doTimezone	,
		     "url"		: None			,
		     "upgrade"		: self.doUpgrade	,
		     "xconfig"		: self.doXconfig	,
		     "xdisplay"		: None			,
		     "zerombr"		: self.doZeroMbr	,
                     "interactive"      : self.doInteractive    ,
                     "autostep"         : self.doAutoStep       ,
                     "firstboot"        : self.doFirstboot      ,
		   }

	packages = []
	groups = []
        excludedPackages = []
	for n in open(file).readlines():
	    args = isys.parseArgv(n)

	    # don't eliminate white space or comments from scripts
	    if where != "pre" and where != "post":
		if not args or args[0][0] == '#': continue

	    if args and (args[0] == "%post" or args[0] == "%pre"):
		if ((where =="pre" and parsePre) or
                    (where == "post" and not parsePre)):
		    s = Script(script, scriptInterp, scriptChroot)
		    if where == "pre":
                        self.preScripts.append(s)
		    else:
			self.postScripts.append(s)

		where = args[0][1:]
		args = isys.parseArgv(n)

		scriptInterp = "/bin/sh"
		if where == "pre":
		    scriptChroot = 0
		else:
		    scriptChroot = 1

		script = ""

		argList = [ 'interpreter=' ]
		if where == "post":
		    argList.append('nochroot')

		(args, extra) = isys.getopt(args, '', argList)
		for n in args:
		    (str, arg) = n
		    
		    if str == "--nochroot":
			scriptChroot = 0
		    elif str == "--interpreter":
			scriptInterp = arg

            elif args and args[0] == "%include" and not parsePre:
                if len(args) < 2:
                    raise RuntimeError, "Invalid %include line"
                else:
                    # read in the included file and set our where appropriately
                    where = self.readKickstart(id, args[1], where = where)
            elif args and args[0] == "%packages":
		if ((where =="pre" and parsePre) or
                    (where == "post" and not parsePre)):
		    s = Script(script, scriptInterp, scriptChroot)
		    if where == "pre":
			self.preScripts.append(s)
		    else:
			self.postScripts.append(s)

                # if we're parsing the %pre, we don't need to continue
                if parsePre:
                    continue

                if len(args) > 1:
                    for arg in args[1:]:
                        if arg == "--resolvedeps":
                            id.handleDeps = RESOLVE_DEPS
                        elif arg == "--ignoredeps":
                            id.handleDeps = IGNORE_DEPS
                        elif arg == "--ignoremissing":
                            self.handleMissing = KS_MISSING_IGNORE
                
		where = "packages"
                self.skipSteps.append("package-selection")
	    else:
                # if we're parsing the %pre and not in the pre, continue
                if parsePre and where != "pre":
                    continue
		elif where == "packages":
                    #Scan for comments in package list...drop off
                    #everything after "#" mark
                    try:
                        ind = string.index(n, "#")
                        n = n[:ind]
                    except:
                        #No "#" found in line
                        pass
                    
		    if n[0] == '@':
			n = n[1:]
                        n = string.strip (n)
			groups.append(n)
                    elif n[0] == '-':
                        n = n[1:]
                        n = string.strip(n)
                        excludedPackages.append(n)
		    else:
                        n = string.strip (n)
			packages.append(n)
		elif where == "commands":
		    if handlers[args[0]]:
			handlers[args[0]](id, args[1:])
		elif where == "pre" or where == "post":
		    script = script + n
		else:
		    raise SyntaxError, "I'm lost in kickstart"

        self.groupList.extend(groups)
        self.packageList.extend(packages)
        self.excludedList.extend(excludedPackages)

        # test to see if they specified to clear partitions and also
        # tried to --onpart on a logical partition
	#
	# XXX
	#
        #if iutil.getArch() == 'i386' and self.fstab:
            #clear = self.getClearParts()
            #if clear == FSEDIT_CLEAR_LINUX or clear == FSEDIT_CLEAR_ALL:
		#for (mntpoint, (dev, fstype, reformat)) in self.fstab:
		    #if int(dev[-1:]) > 4:
			#raise RuntimeError, "Clearpart and --onpart on non-primary partition %s not allowed" % dev
                
	if ((where =="pre" and parsePre) or
            (where == "post" and not parsePre)):
	    s = Script(script, scriptInterp, scriptChroot)
	    if where == "pre":
		self.preScripts.append(s)
	    else:
		self.postScripts.append(s)

        return where

    def doClearPart(self, id, args):
        type = CLEARPART_TYPE_NONE
        drives = None
        initAll = 0

        (args, extra) = isys.getopt(args, '', [ 'linux', 'all', 'drives=',
                                                'initlabel', 'none'])

        for n in args:
            (str, arg) = n
            if str == '--linux':
                type = CLEARPART_TYPE_LINUX
            elif str == '--all':
                type = CLEARPART_TYPE_ALL
            elif str == '--drives':
                drives = string.split(arg, ',')
            elif str == '--initlabel':
                initAll = 1
            elif str == '--none':
                type = CLEARPART_TYPE_NONE
            
        self.setClearParts(id, type, drives, initAll = initAll)

    def defineLogicalVolume(self, id, args):
        (args, extra) = isys.getopt(args, '', [ 'vgname=',
                                                'size=',
                                                'name=',
                                                'fstype=',
                                                'percent=',
						'maxsize=',
						'grow',
                                                'recommended',
                                                'noformat',
                                                'useexisting'])

        mountpoint = None
        vgname = None
        size = None
        name = None
        fstype = None
        percent = None
	grow = 0
	maxSizeMB = 0
        format = 1
        recommended = None
        preexist = 0

        for n in args:
            (str, arg) = n
            if str == '--vgname':
                vgname = arg
            elif str == '--size':
                size = int(arg)
            elif str == '--name':
                name = arg
            elif str == '--fstype':
                fstype = arg
            elif str == '--percent':
                percent = int(arg)
	    elif str == '--maxsize':
		maxSizeMB = int(arg)
	    elif str == '--grow':
		grow = 1
            elif str == '--recommended':
                recommended = 1
            elif str == "--noformat":
                format = 0
                preexist = 1
            elif str == "--useexisting":
                preexist = 1
            else:
                print str, " ", arg

        if extra[0] == 'swap':
            filesystem = fileSystemTypeGet('swap')
            mountpoint = None
            if recommended:
                (size, maxSizeMB) = iutil.swapSuggestion()
                grow = 1
        else:
            if fstype:
                filesystem = fileSystemTypeGet(fstype)
            else:
                filesystem = fileSystemTypeGetDefault()

            mountpoint = extra[0]

        if not vgname:
            raise RuntimeError, "Must specify the volume group for the logical volume to be in"
        if not size and not percent and not preexist:
            raise RuntimeError, "Must specify the size of a logical volume"
        if percent and percent <= 0 or percent > 100:
            raise ValueError, "Logical Volume percentage must be between 0 and 100 percent"
        if not name:
            raise RuntimeError, "Must specify a logical volume name"

        if not self.ksVGMapping.has_key(vgname):
            raise ValueError, "Logical volume specifies a non-existent volume group"
        vgid = self.ksVGMapping[vgname]

        request = partRequests.LogicalVolumeRequestSpec(filesystem,
                                                        format = format,
                                                        mountpoint = mountpoint,
                                                        size = size,
                                                        percent = percent,
                                                        volgroup = vgid,
                                                        lvname = name,
							grow = grow,
							maxSizeMB=maxSizeMB,
                                                        preexist = preexist)
        id.partitions.autoPartitionRequests.append(request)        
                                                        

    def defineVolumeGroup(self, id, args):
        (args, extra) = isys.getopt(args, '', ['noformat','useexisting'])

        preexist = 0
        format = 1

        vgname = extra[0]

	for n in args:
	    (str, arg) = n
	    if str == '--noformat' or str == '--useexisting':
                preexist = 1
                format = 0

        pvs = []
        # get the unique ids of each of the physical volumes
        for pv in extra[1:]:
            if pv not in self.ksPVMapping.keys():
                raise RuntimeError, "Tried to use an undefined partition in Volume Group specification"
            pvs.append(self.ksPVMapping[pv])

        if len(pvs) == 0 and not preexist:
            raise ValueError, "Volume group defined without any physical volumes"

        # get a sort of hackish id
        uniqueID = self.ksID
        self.ksVGMapping[extra[0]] = uniqueID
        self.ksID = self.ksID + 1
            
        request = partRequests.VolumeGroupRequestSpec(vgname = vgname,
                                                      physvols = pvs,
                                                      preexist = preexist,
                                                      format = format)
        request.uniqueID = uniqueID
        id.partitions.autoPartitionRequests.append(request)

    def defineRaid(self, id, args):
	(args, extra) = isys.getopt(args, '', [ 'level=', 'device=',
                                                'spares=', 'fstype=',
                                                'noformat', 'useexisting'] )

        level = None
        raidDev = None
        spares = 0
        fstype = None
        format = 1
        uniqueID = None
        preexist = 0
					
	for n in args:
	    (str, arg) = n
	    if str == '--level':
		level = arg
	    elif str == "--device":
		raidDev = arg
                if raidDev[0:2] == "md":
                    raidDev = raidDev[2:]
                raidDev = int(raidDev)
            elif str == "--spares":
                spares = int(arg)
            elif str == "--noformat":
                format = 0
                preexist = 1
            elif str == "--useexisting":
                preexist = 1
            elif str == "--fstype":
                fstype = arg

        if extra[0] == 'swap':
            filesystem = fileSystemTypeGet('swap')
            mountpoint = None
        elif extra[0].startswith("pv."):
            filesystem = fileSystemTypeGet("physical volume (LVM)")
            mountpoint = None

            if self.ksPVMapping.has_key(extra[0]):
                raise RuntimeError, "Defined PV partition %s multiple times" % (extra[0],)

            # get a sort of hackish id
            uniqueID = self.ksID
            self.ksPVMapping[extra[0]] = uniqueID
            self.ksID = self.ksID + 1
        else:
            if fstype:
                filesystem = fileSystemTypeGet(fstype)
            else:
                filesystem = fileSystemTypeGetDefault()

            mountpoint = extra[0]

        raidmems = []
        # get the unique ids of each of the raid members
        for member in extra[1:]:
            if member not in self.ksRaidMapping.keys():
                raise RuntimeError, "Tried to use an undefined partition in RAID specification"
            raidmems.append(self.ksRaidMapping[member])

        # XXX this shouldn't have to happen =\
        if raid.isRaid0(level):
            level = "RAID0"
        elif raid.isRaid1(level):
            level = "RAID1"
        elif raid.isRaid5(level):
            level = "RAID5"

        if not level and preexist == 0:
            raise ValueError, "RAID Partition defined without RAID level"
        if len(raidmems) == 0 and preexist == 0:
            raise ValueError, "RAID Partition defined without any RAID members"

        request = partRequests.RaidRequestSpec(filesystem,
                                               mountpoint = mountpoint,
                                               raidmembers = raidmems,
                                               raidlevel = level,
                                               raidspares = spares,
                                               format = format,
                                               raidminor = raidDev,
                                               preexist = preexist)
        
        if uniqueID:
            request.uniqueID = uniqueID
            
        id.partitions.autoPartitionRequests.append(request)


    def definePartition(self, id, args):
	# we set up partition requests (whee!)
	size = None
	grow = None
	maxSize = None
	disk = None
	onPart = None
        fsopts = None
        type = None
        primOnly = None
        format = 1
        fstype = None
        mountpoint = None
        uniqueID = None
        start = None
        end = None
        badblocks = None
        recommended = None

	(args, extra) = isys.getopt(args, '', [ 'size=', 'maxsize=', 
					'grow', 'onpart=', 'ondisk=',
                                        'bytes-per-inode=', 'usepart=',
                                        'type=', 'fstype=', 'asprimary',
                                        'noformat', 'start=', 'end=',
                                        'badblocks', 'recommended',
                                        'ondrive='])

	for n in args:
	    (str, arg) = n
	    if str == '--size':
		size = int(arg)
	    elif str == '--maxsize':
		maxSize = int(arg)
	    elif str == '--grow':
		grow = 1
	    elif str == '--onpart' or str == '--usepart':
		onPart = arg
	    elif str == '--ondisk' or str == '--ondrive':
		disk = arg
            elif str == '--bytes-per-inode':
                fsopts = ['-i', arg]
            # XXX this doesn't do anything right now
            elif str == '--type':
                type = int(arg)
            elif str == "--active":
                active = 1
            elif str == "--asprimary":
                primOnly = 1
            elif str == "--noformat":
                format = 0
            elif str == "--fstype":
                fstype = arg
            elif str == "--start":
                start = int(arg)
            elif str == "--end":
                end = int(arg)
            elif str == "--badblocks":
                badblocks = 1
            elif str == "--recommended":
                recommended = 1

	if len(extra) != 1:
	    raise ValueError, "partition command requires one anonymous argument"

        if extra[0] == 'swap':
            filesystem = fileSystemTypeGet('swap')
            mountpoint = None
            if recommended:
                (size, maxSize) = iutil.swapSuggestion()
                grow = 1
        elif extra[0].startswith("raid."):
            filesystem = fileSystemTypeGet("software RAID")
            
            if self.ksRaidMapping.has_key(extra[0]):
                raise RuntimeError, "Defined RAID partition %s multiple times" % (extra[0],)
            
            # get a sort of hackish id
            uniqueID = self.ksID
            self.ksRaidMapping[extra[0]] = uniqueID
            self.ksID = self.ksID + 1
        elif extra[0].startswith("pv."):
            filesystem = fileSystemTypeGet("physical volume (LVM)")

            if self.ksPVMapping.has_key(extra[0]):
                raise RuntimeError, "Defined PV partition %s multiple times" % (extra[0],)

            # get a sort of hackish id
            uniqueID = self.ksID
            self.ksPVMapping[extra[0]] = uniqueID
            self.ksID = self.ksID + 1
        # XXX should we let people not do this for some reason?
        elif extra[0] == "/boot/efi":
            filesystem = fileSystemTypeGet("vfat")
            mountpoint = extra[0]
        else:
            if fstype:
                filesystem = fileSystemTypeGet(fstype)
                mountpoint = extra[0]                
            else:
                filesystem = fileSystemTypeGetDefault()
                mountpoint = extra[0]

        if (not size) and (not start and not end) and (not onPart):
            raise ValueError, "partition command requires a size specification"
        if start and not disk:
            raise ValueError, "partition command with start cylinder requires a drive specification"
        
        # XXX bytes per inode is the only per fs option at the moment
        # and we can assume that it works like this since it only works
        # with ext[23]
        if fsopts:
            filesystem.extraFormatArgs.extend(fsopts)

        request = partRequests.PartitionSpec(filesystem,
                                             mountpoint = mountpoint,
                                             format = 1)
        if size:
            request.size = size
        if start:
            request.start = start
        if end:
            request.end = end
        if grow:
            request.grow = 1
        if maxSize:
            request.maxSizeMB = maxSize
        if disk:
            request.drive = [ disk ]
        if primOnly:
            request.primary = 1
        if not format:
            request.format = 0
        if uniqueID:
            request.uniqueID = uniqueID
        if badblocks:
            request.badblocks = badblocks
        if onPart:
            request.device = onPart

        id.partitions.autoPartitionRequests.append(request)
        id.partitions.isKickstart = 1

        self.skipSteps.append("partition")
        self.skipSteps.append("partitionmethod")
        self.skipSteps.append("partitionmethodsetup")
        self.skipSteps.append("fdisk")
        self.skipSteps.append("fdasd")
        self.skipSteps.append("autopartition")

    def setSteps(self, dispatch):
        if self.installType == "upgrade":
            from upgradeclass import InstallClass
            theUpgradeclass = InstallClass(0)
            theUpgradeclass.setSteps(dispatch)
            
            # we have no way to specify migrating yet
            dispatch.skipStep("upgrademigfind")
            dispatch.skipStep("upgrademigratefs")
            dispatch.skipStep("upgradecontinue")
            dispatch.skipStep("findinstall", permanent = 1)
            dispatch.skipStep("language")
            dispatch.skipStep("keyboard")
            dispatch.skipStep("mouse")
            dispatch.skipStep("welcome")
            dispatch.skipStep("betanag")
            dispatch.skipStep("installtype")
        else:
            BaseInstallClass.setSteps(self, dispatch)
            dispatch.skipStep("findrootparts")

        if self.interactive or flags.autostep:
            dispatch.skipStep("installtype")
            dispatch.skipStep("partitionmethod")
            dispatch.skipStep("partitionmethodsetup")
            dispatch.skipStep("fdisk")
            dispatch.skipStep("fdasd")
            dispatch.skipStep("autopartition")
            dispatch.skipStep("bootdisk")            
            return
        
	dispatch.skipStep("bootdisk")
        dispatch.skipStep("welcome")
        dispatch.skipStep("betanag")
        dispatch.skipStep("confirminstall")
        dispatch.skipStep("confirmupgrade")
        dispatch.skipStep("network")
        dispatch.skipStep("installtype")

        # skipping firewall by default, disabled by default
	dispatch.skipStep("firewall")

	for n in self.skipSteps:
	    dispatch.skipStep(n)
        for n in self.showSteps:
            dispatch.skipStep(n, skip = 0)

    def setInstallData(self, id):
	BaseInstallClass.setInstallData(self, id)

	self.setEarlySwapOn(1)
	self.postScripts = []
	self.preScripts = []

	self.installType = "install"
        self.id = id
        self.id.firstboot = FIRSTBOOT_SKIP

        # parse the %pre
	self.readKickstart(id, self.file, parsePre = 1)

	log("Running kickstart %%pre script(s)")
	for script in self.preScripts:
	    script.run("/", self.serial)
	log("All kickstart %%pre script(s) have been run")

        # now read the kickstart file for real
	self.readKickstart(id, self.file)            

    # Note that this assumes setGroupSelection() is called after
    # setPackageSelection()
    def setPackageSelection(self, hdlist, intf):
	for pkg in hdlist.keys():
	    hdlist[pkg].setState((0, 0))

	for n in self.packageList:
            if hdlist.has_key(n):
                hdlist[n].select()
            elif self.handleMissing == KS_MISSING_IGNORE:
                log("package %s doesn't exist, ignoring" %(n,))
            else:
                rc = intf.messageWindow(_("Missing Package"),
                                        _("You have specified that the "
                                          "package '%s' should be installed.  "
                                          "This package does not exist. "
                                          "Would you like to continue or "
                                          "abort your installation?") %(n,),
                                        type="custom",
                                        custom_buttons=[_("_Abort"),
                                                        _("_Continue")])
                if rc == 0:
                    sys.exit(1)
                else:
                    pass
                                

    def setGroupSelection(self, comps, intf):
	for comp in comps:
	    comp.unselect()

	comps['Base'].select()
	for n in self.groupList:
            if comps.has_key(n):
                comps[n].select()
            elif self.handleMissing == KS_MISSING_IGNORE:
                log("group %s doesn't exist, ignoring" %(n,))
            else:
                rc = intf.messageWindow(_("Missing Group"),
                                        _("You have specified that the "
                                          "group '%s' should be installed.  "
                                          "This group does not exist. "
                                          "Would you like to continue or "
                                          "abort your installation?") %(n,),
                                        type="custom",
                                        custom_buttons=[_("_Abort"),
                                                        _("_Continue")])
                if rc == 0:
                    sys.exit(1)
                else:
                    pass
                

        for n in self.excludedList:
            if comps.packages.has_key(n):
                comps.packages[n].unselect()
            else:
                log("%s does not exist, can't exclude" %(n,))

    def __init__(self, file, serial):
	self.serial = serial
	self.file = file
	self.skipSteps = []
        self.showSteps = []
        self.interactive = 0
        self.packageList = []
        self.groupList = []
        self.excludedList = []