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" % ("-n [arg], --name [arg]", "image name (override IMAGE_NAME variable)")
23 print " %s\t\t%s" % ("-v, --version", "output version information and exit")
27 print "OpenEmbedded Build Infrastructure Core version %s" % oe.__version__
28 print "OEImage version %s" % __version__
30 def emit_oe(d, base_d = {}):
43 (opts, args) = getopt.getopt(sys.argv[1:], 'vr:t:e:n:', [ 'version', 'root=', 'type=', 'oefile=', 'name=' ])
44 except getopt.GetoptError:
48 opthash = getopthash(opts)
50 if '--version' in opthash or '-v' in opthash:
55 cfg_oe = parse.handle("conf/oe.conf", cfg_oe)
57 fatal("Unable to open oe.conf")
61 fatal("Unable to open/parse conf/oe.conf")
67 if '--root' in opthash:
68 rootfs = opthash['--root']
70 rootfs = opthash['-r']
72 if '--type' in opthash:
73 type = opthash['--type']
77 if '--oefile' in opthash:
78 extra_files.append(opthash['--oefile'])
80 extra_files.append(opthash['-e'])
84 cfg_oe = parse.handle(f, cfg_oe)
86 print "unable to open %s" % f
89 rootfs = data.getVar('IMAGE_ROOTFS', cfg_oe, 1)
92 oe.fatal("IMAGE_ROOTFS not defined")
94 data.setVar('IMAGE_ROOTFS', rootfs, cfg_oe)
96 from copy import copy, deepcopy
97 localdata = deepcopy(cfg_oe)
99 overrides = data.getVar('OVERRIDES', localdata)
101 oe.fatal("OVERRIDES not defined.")
102 data.setVar('OVERRIDES', '%s:%s' % (overrides, type), localdata)
103 data.update_data(localdata)
104 data.setVar('OVERRIDES', overrides, localdata)
107 data.setVar('IMAGE_NAME', opthash['-n'], localdata)
108 if '--name' in opthash:
109 data.setVar('IMAGE_NAME', opthash['--name'], localdata)
111 topdir = data.getVar('TOPDIR', localdata, 1) or os.getcwd()
113 cmd = data.getVar('IMAGE_CMD', localdata, 1)
115 oe.fatal("IMAGE_CMD not defined")
117 outdir = data.getVar('DEPLOY_DIR_IMAGE', localdata, 1)
119 oe.fatal('DEPLOY_DIR_IMAGE not defined')
122 #depends = data.getVar('IMAGE_DEPENDS', localdata, 1) or ""
124 # oe.note("Spawning oemake to satisfy dependencies: %s" % depends)
125 # ret = os.system('oemake %s' % depends)
127 # oe.error("executing oemake to satisfy dependencies")
129 oe.note("Executing %s" % cmd)
130 data.setVar('T', '${TMPDIR}', localdata)
131 data.setVar('image_cmd', cmd, localdata)
132 data.setVarFlag('image_cmd', 'func', 1, localdata)
134 oe.build.exec_func('image_cmd', localdata)
135 except oe.build.FuncFailed:
137 #ret = os.system(cmd)