2 # ex:ts=4:sw=4:sts=4:et
3 # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
11 cfg_oespawn = data.init()
15 print "Usage: oeimage [options ...]"
16 print "Creates an image for a target device from a root filesystem,"
17 print "obeying configuration parameters from the OpenEmbedded"
18 print "configuration files, thereby easing handling of deviceisms."
20 print " %s\t\t%s" % ("-r [arg], --root [arg]", "root directory (default=${IMAGE_ROOTFS})")
21 print " %s\t\t%s" % ("-t [arg], --type [arg]", "image type (jffs2[default], cramfs)")
22 print " %s\t\t%s" % ("-v, --version", "output version information and exit")
26 print "OpenEmbedded Build Infrastructure Core version %s" % oe.__version__
27 print "OEImage version %s" % __version__
29 def emit_oe(d, base_d = {}):
42 (opts, args) = getopt.getopt(sys.argv[1:], 'vr:t:e:', [ 'version', 'root=', 'type=', 'oefile=' ])
43 except getopt.GetoptError:
47 opthash = getopthash(opts)
49 if '--version' in opthash or '-v' in opthash:
54 cfg_oe = parse.handle("conf/oe.conf", cfg_oe)
56 fatal("Unable to open oe.conf")
60 fatal("Unable to open/parse conf/oe.conf")
66 if '--root' in opthash:
67 rootfs = opthash['--root']
69 rootfs = opthash['-r']
71 if '--type' in opthash:
72 type = opthash['--type']
76 if '--oefile' in opthash:
77 extra_files.append(opthash['--oefile'])
79 extra_files.append(opthash['-e'])
83 cfg_oe = parse.handle(f, cfg_oe)
85 print "unable to open %s" % f
88 rootfs = data.getVar('IMAGE_ROOTFS', cfg_oe, 1)
91 oe.fatal("IMAGE_ROOTFS not defined")
93 data.setVar('IMAGE_ROOTFS', rootfs, cfg_oe)
95 from copy import copy, deepcopy
96 localdata = deepcopy(cfg_oe)
98 overrides = data.getVar('OVERRIDES', localdata)
100 oe.fatal("OVERRIDES not defined.")
101 data.setVar('OVERRIDES', '%s:%s' % (overrides, type), localdata)
102 data.update_data(localdata)
103 data.setVar('OVERRIDES', overrides, localdata)
105 topdir = data.getVar('TOPDIR', localdata, 1) or os.getcwd()
107 cmd = data.getVar('IMAGE_CMD', localdata, 1)
109 oe.fatal("IMAGE_CMD not defined")
111 outdir = data.getVar('DEPLOY_DIR_IMAGE', localdata, 1)
113 oe.fatal('DEPLOY_DIR_IMAGE not defined')
116 #depends = data.getVar('IMAGE_DEPENDS', localdata, 1) or ""
118 # oe.note("Spawning oemake to satisfy dependencies: %s" % depends)
119 # ret = os.system('oemake %s' % depends)
121 # oe.error("executing oemake to satisfy dependencies")
123 oe.note("Executing %s" % cmd)
124 data.setVar('T', '${TMPDIR}', localdata)
125 data.setVar('image_cmd', cmd, localdata)
126 data.setVarFlag('image_cmd', 'func', 1, localdata)
128 oe.build.exec_func('image_cmd', localdata)
129 except oe.build.FuncFailed:
131 #ret = os.system(cmd)