summaryrefslogtreecommitdiffstats
path: root/bitbake/bin/bbimage
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/bin/bbimage')
-rwxr-xr-xbitbake/bin/bbimage160
1 files changed, 0 insertions, 160 deletions
diff --git a/bitbake/bin/bbimage b/bitbake/bin/bbimage
deleted file mode 100755
index 96b7dca323..0000000000
--- a/bitbake/bin/bbimage
+++ /dev/null
@@ -1,160 +0,0 @@
1#!/usr/bin/env python
2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4#
5# Copyright (C) 2003 Chris Larson
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License version 2 as
9# published by the Free Software Foundation.
10#
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 General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program; if not, write to the Free Software Foundation, Inc.,
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20import sys, os
21sys.path.insert(0,os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
22import bb
23from bb import *
24
25__version__ = 1.1
26type = "jffs2"
27cfg_bb = data.init()
28cfg_oespawn = data.init()
29
30bb.msg.set_debug_level(0)
31
32def usage():
33 print "Usage: bbimage [options ...]"
34 print "Creates an image for a target device from a root filesystem,"
35 print "obeying configuration parameters from the BitBake"
36 print "configuration files, thereby easing handling of deviceisms."
37 print ""
38 print " %s\t\t%s" % ("-r [arg], --root [arg]", "root directory (default=${IMAGE_ROOTFS})")
39 print " %s\t\t%s" % ("-t [arg], --type [arg]", "image type (jffs2[default], cramfs)")
40 print " %s\t\t%s" % ("-n [arg], --name [arg]", "image name (override IMAGE_NAME variable)")
41 print " %s\t\t%s" % ("-v, --version", "output version information and exit")
42 sys.exit(0)
43
44def version():
45 print "BitBake Build Tool Core version %s" % bb.__version__
46 print "BBImage version %s" % __version__
47
48def emit_bb(d, base_d = {}):
49 for v in d.keys():
50 if d[v] != base_d[v]:
51 data.emit_var(v, d)
52
53def getopthash(l):
54 h = {}
55 for (opt, val) in l:
56 h[opt] = val
57 return h
58
59import getopt
60try:
61 (opts, args) = getopt.getopt(sys.argv[1:], 'vr:t:e:n:', [ 'version', 'root=', 'type=', 'bbfile=', 'name=' ])
62except getopt.GetoptError:
63 usage()
64
65# handle opts
66opthash = getopthash(opts)
67
68if '--version' in opthash or '-v' in opthash:
69 version()
70 sys.exit(0)
71
72try:
73 cfg_bb = parse.handle(os.path.join('conf', 'bitbake.conf'), cfg_bb)
74except IOError:
75 fatal("Unable to open bitbake.conf")
76
77# sanity check
78if cfg_bb is None:
79 fatal("Unable to open/parse %s" % os.path.join('conf', 'bitbake.conf'))
80 usage(1)
81
82# Handle any INHERITs and inherit the base class
83inherits = ["base"] + (bb.data.getVar('INHERIT', cfg_bb, True ) or "").split()
84for inherit in inherits:
85 cfg_bb = bb.parse.handle(os.path.join('classes', '%s.bbclass' % inherit), cfg_bb, True )
86
87rootfs = None
88extra_files = []
89
90if '--root' in opthash:
91 rootfs = opthash['--root']
92if '-r' in opthash:
93 rootfs = opthash['-r']
94
95if '--type' in opthash:
96 type = opthash['--type']
97if '-t' in opthash:
98 type = opthash['-t']
99
100if '--bbfile' in opthash:
101 extra_files.append(opthash['--bbfile'])
102if '-e' in opthash:
103 extra_files.append(opthash['-e'])
104
105for f in extra_files:
106 try:
107 cfg_bb = parse.handle(f, cfg_bb)
108 except IOError:
109 print "unable to open %s" % f
110
111if not rootfs:
112 rootfs = data.getVar('IMAGE_ROOTFS', cfg_bb, 1)
113
114if not rootfs:
115 bb.fatal("IMAGE_ROOTFS not defined")
116
117data.setVar('IMAGE_ROOTFS', rootfs, cfg_bb)
118
119from copy import copy, deepcopy
120localdata = data.createCopy(cfg_bb)
121
122overrides = data.getVar('OVERRIDES', localdata)
123if not overrides:
124 bb.fatal("OVERRIDES not defined.")
125data.setVar('OVERRIDES', '%s:%s' % (overrides, type), localdata)
126data.update_data(localdata)
127data.setVar('OVERRIDES', overrides, localdata)
128
129if '-n' in opthash:
130 data.setVar('IMAGE_NAME', opthash['-n'], localdata)
131if '--name' in opthash:
132 data.setVar('IMAGE_NAME', opthash['--name'], localdata)
133
134topdir = data.getVar('TOPDIR', localdata, 1) or os.getcwd()
135
136cmd = data.getVar('IMAGE_CMD', localdata, 1)
137if not cmd:
138 bb.fatal("IMAGE_CMD not defined")
139
140outdir = data.getVar('DEPLOY_DIR_IMAGE', localdata, 1)
141if not outdir:
142 bb.fatal('DEPLOY_DIR_IMAGE not defined')
143mkdirhier(outdir)
144
145#depends = data.getVar('IMAGE_DEPENDS', localdata, 1) or ""
146#if depends:
147# bb.note("Spawning bbmake to satisfy dependencies: %s" % depends)
148# ret = os.system('bbmake %s' % depends)
149# if ret != 0:
150# bb.error("executing bbmake to satisfy dependencies")
151
152bb.note("Executing %s" % cmd)
153data.setVar('image_cmd', cmd, localdata)
154data.setVarFlag('image_cmd', 'func', 1, localdata)
155try:
156 bb.build.exec_func('image_cmd', localdata)
157except bb.build.FuncFailed:
158 sys.exit(1)
159#ret = os.system(cmd)
160#sys.exit(ret)