3 # image-creator: Create an ext3 system image
5 # Copyright 2007, Red Hat Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; version 2 of the License.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Library General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 def parse_options(args
):
29 parser
= optparse
.OptionParser(usage
= "%prog [--name=<name>] <kickstart>")
31 parser
.add_option("-n", "--name", type="string", dest
="name",
32 help="Image name and filesystem label")
34 imgcreate
.setup_logging(parser
)
36 (options
, args
) = parser
.parse_args()
42 return (args
[0], options
)
45 (kscfg
, options
) = parse_options(sys
.argv
[1:])
47 if os
.geteuid () != 0:
48 print >> sys
.stderr
, "You must run image-creator as root"
52 ks
= imgcreate
.read_kickstart(kscfg
)
53 except imgcreate
.CreatorError
, e
:
54 logging
.error("Unable to load kickstart file '%s' : %s" % (kscfg
, e
))
60 name
= imgcreate
.build_name(kscfg
)
62 creator
= imgcreate
.LoopImageCreator(ks
, name
)
66 except imgcreate
.CreatorError
, e
:
67 logging
.error("Unable to create image : %s" % e
)
74 if __name__
== "__main__":