3 # Simple script to take a kickstart config, read it in, parse any %includes,
4 # etc to write out a flattened config that is stand-alone
6 # Copyright 2007, Red Hat, Inc.
7 # Jeremy Katz <katzj@redhat.com>
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; version 2 of the License.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Library General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 import pykickstart
.parser
26 from pykickstart
.version
import *
29 parser
= optparse
.OptionParser()
31 parser
.add_option("-c", "--config", type="string", dest
="kscfg",
32 help="Path to kickstart config file")
33 parser
.add_option("-v", "--version", dest
="version", default
=DEVEL
,
34 help="Kickstart version to use for interpreting config")
35 parser
.add_option("-o", "--output", type="string", dest
="output",
36 help="Write flattened config to OUTPUT")
38 (options
, args
) = parser
.parse_args()
42 (opts
, args
) = parse_args()
43 if not opts
.kscfg
and len(args
) >= 1:
46 print >> sys
.stderr
, "Need to specify a config to flatten"
49 ksversion
= makeVersion(opts
.version
)
50 ksparser
= pykickstart
.parser
.KickstartParser(ksversion
)
52 ksparser
.readKickstart(opts
.kscfg
)
53 except IOError, (err
, msg
):
54 print >> sys
.stderr
, "Failed to read kickstart file '%s' : %s" % (opts
.kscfg
, msg
)
56 except pykickstart
.errors
.KickstartError
, e
:
57 print >> sys
.stderr
, "Failed to parse kickstart file '%s' : %s" % (opts
.kscfg
, e
)
61 f
= open(opts
.output
, 'w')
62 except IOError, (err
, msg
):
63 print >> sys
.stderr
, "Failed to open output file '%s' : %s" %(opts
.output
, msg
)
67 f
.write("%s" %(ksparser
.handler
,))
70 if __name__
== "__main__":