11 print "Usage: oeinstall [options ...]"
13 print "Installs specified files of supported types into a root filesystem."
14 print "Currently only supports installing OEFILES into the rootfs directly"
15 print "using their do_install target."
18 print " %s\t\t%s" % ("-r [arg], --root [arg]", "root directory (default=${IMAGE_ROOTFS})")
19 print " %s\t\t%s" % ("-f [arg], --files [arg]", ".oe files available (default=${OEFILES})")
20 print " %s\t\t%s" % ("-t [arg], --type [arg]", "installation type (direct, and any for which package_[type].oeclass exists)")
21 print " %s\t\t%s" % ("-V, --version", "output version information and exit")
26 print "OpenEmbedded Build Infrastructure Core version %s" % oe.__version__
27 print "OEInstall version %s" % __version__
37 (opts, args) = getopt.getopt(sys.argv[1:], 'Vr:f:t:', [ 'version', 'root=', 'files=', 'type=' ])
38 except getopt.GetoptError:
42 opthash = getopthash(opts)
44 if '--version' in opthash or '-V' in opthash:
49 cfg_oe = parse.handle("conf/oe.conf", cfg_oe)
51 fatal("Unable to open oe.conf: %s" % e)
55 fatal("Unable to open/parse conf/oe.conf")
58 rootfs = data.getVar('IMAGE_ROOTFS', cfg_oe, 1)
60 if '--root' in opthash:
61 rootfs = opthash['--root']
63 rootfs = opthash['-r']
66 oe.fatal("root filesystem not specified")
68 data.setVar('IMAGE_ROOTFS', rootfs, cfg_oe)
73 if '--type' in opthash:
74 type = opthash['--type']
78 topdir = data.getVar('TOPDIR', cfg_oe, 1) or os.getcwd()
80 # Iterate through .oe files
81 files = (data.getVar("OEFILES", cfg_oe, 1) or "").split()
83 files.extend(opthash['-f'])
84 if '--files' in opthash:
85 files.extend(opthash['--files'])
86 data.setVar("OEFILES", ''.join(files), cfg_oe)
89 """Get default oefiles"""
90 dirs = os.listdir(os.getcwd())
93 (root, ext) = os.path.splitext(f)
95 oefiles.append(os.path.abspath(os.path.join(os.getcwd(),f)))
105 from oe import data, build, error
106 if data.getVar('pkg_preinst', d):
108 build.exec_func('pkg_preinst', d)
109 except build.FuncFailed:
110 oe.note("preinst execution failure")
112 if type is not 'direct':
114 build.exec_func('package_%s_fn' % type, d)
115 except build.FuncFailed:
116 oe.error("failed obtaining the filename of the outputted package for %s" % type)
118 if data.getVar('package_%s_install' % type, d):
120 build.exec_func('package_%s_install' % type, d)
121 print "package %s (%s) installed." % (p, data.getVar('PN', d, 1))
122 except build.FuncFailed:
125 oe.error("no package_%s_install function to execute. skipping." % type)
127 if data.getVar('pkg_postinst', d):
129 build.exec_func('pkg_postinst', d)
130 except build.FuncFailed:
131 oe.note("postinst execution failure")
136 # if type is not direct, add 'package_[type]' to INHERIT
137 if type is not 'direct':
138 inherit = data.getVar('INHERIT', cfg_oe, 1) or ""
139 inherit += " base package_%s" % type
140 data.setVarFlag('INHERIT', 'export', 1, cfg_oe)
141 data.setVar('INHERIT', inherit, cfg_oe)
143 pkgs_to_install = None
145 if not pkgs_to_install:
147 pkgs_to_install.extend(args)
148 if not pkgs_to_install:
149 inst_oepkgs = data.getVar('INST_OEPKGS', cfg_oe, 1)
151 pkgs_to_install = inst_oepkgs.split()
152 debug(1, "installing: %s" % pkgs_to_install)
156 if pkgs_to_install is not None and len(pkgs_to_install) == 0:
159 globbed = glob.glob(f) or [ f ]
164 from copy import deepcopy
165 fdata = deepcopy(cfg_oe)
167 parse.handle(f, fdata)
173 # allow metadata files to add items to OEFILES
174 data.update_data(fdata)
175 addoefiles = data.getVar('OEFILES', fdata) or None
177 for aof in addoefiles.split():
178 if not files.count(aof):
179 if not os.path.isabs(aof):
180 aof = os.path.join(os.path.dirname(f),aof)
182 pkgs = (data.getVar('PACKAGES', fdata, 1) or "").split()
183 # Iterate through PACKAGES
185 if pkgs_to_install is not None:
186 if not p in pkgs_to_install:
189 data.setVar('PKG', p, d)
190 # Add package to overrides, collapse the metadata
191 overrides = data.getVar('OVERRIDES', d, 1) or ""
192 overrides += ":%s" % p
193 data.setVar('OVERRIDES', overrides, d)
195 data.setVarFlag('INHERIT', 'export', 1, d)
196 # Look at vars to determine the file names for the package type in question
197 # Call installer for a given package type as pulled from the metadata with INHERIT set properly
198 data.setVar('D', rootfs, d)
200 if pkgs_to_install is not None:
201 del pkgs_to_install[pkgs_to_install.index(p)]
202 if pkgs_to_install is not None and len(pkgs_to_install) == 0: