blob: 3813f68e8b58a5e313c84a4e9f2feb0ceaedf172 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: GPL-2.0-only
3#
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004from abc import ABCMeta, abstractmethod
5from oe.utils import execute_pre_post_process
6from oe.package_manager import *
7from oe.manifest import *
8import oe.path
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009import shutil
10import os
11import subprocess
12import re
Andrew Geissler635e0e42020-08-21 15:58:33 -050013from oe.package_manager.rpm.manifest import RpmManifest
14from oe.package_manager.ipk.manifest import OpkgManifest
15from oe.package_manager.deb.manifest import DpkgManifest
16from oe.package_manager.rpm import RpmPkgsList
17from oe.package_manager.ipk import OpkgPkgsList
18from oe.package_manager.deb import DpkgPkgsList
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019
Patrick Williamsc0f7c042017-02-23 20:41:17 -060020class Rootfs(object, metaclass=ABCMeta):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021 """
22 This is an abstract class. Do not instantiate this directly.
23 """
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025 def __init__(self, d, progress_reporter=None, logcatcher=None):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 self.d = d
27 self.pm = None
Brad Bishop6e60e8b2018-02-01 10:27:11 -050028 self.image_rootfs = self.d.getVar('IMAGE_ROOTFS')
29 self.deploydir = self.d.getVar('IMGDEPLOYDIR')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060030 self.progress_reporter = progress_reporter
Brad Bishop6e60e8b2018-02-01 10:27:11 -050031 self.logcatcher = logcatcher
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032
33 self.install_order = Manifest.INSTALL_ORDER
34
35 @abstractmethod
36 def _create(self):
37 pass
38
39 @abstractmethod
40 def _get_delayed_postinsts(self):
41 pass
42
43 @abstractmethod
44 def _save_postinsts(self):
45 pass
46
47 @abstractmethod
48 def _log_check(self):
49 pass
50
Patrick Williamsc0f7c042017-02-23 20:41:17 -060051 def _log_check_common(self, type, match):
52 # Ignore any lines containing log_check to avoid recursion, and ignore
53 # lines beginning with a + since sh -x may emit code which isn't
54 # actually executed, but may contain error messages
55 excludes = [ 'log_check', r'^\+' ]
56 if hasattr(self, 'log_check_expected_regexes'):
57 excludes.extend(self.log_check_expected_regexes)
58 excludes = [re.compile(x) for x in excludes]
59 r = re.compile(match)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060 log_path = self.d.expand("${T}/log.do_rootfs")
Patrick Williamsc0f7c042017-02-23 20:41:17 -060061 messages = []
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062 with open(log_path, 'r') as log:
63 for line in log:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064 if self.logcatcher and self.logcatcher.contains(line.rstrip()):
65 continue
Patrick Williamsc0f7c042017-02-23 20:41:17 -060066 for ee in excludes:
67 m = ee.search(line)
68 if m:
69 break
70 if m:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071 continue
72
73 m = r.search(line)
74 if m:
Patrick Williamsc0f7c042017-02-23 20:41:17 -060075 messages.append('[log_check] %s' % line)
76 if messages:
77 if len(messages) == 1:
78 msg = '1 %s message' % type
79 else:
80 msg = '%d %s messages' % (len(messages), type)
81 msg = '[log_check] %s: found %s in the logfile:\n%s' % \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050082 (self.d.getVar('PN'), msg, ''.join(messages))
Patrick Williamsc0f7c042017-02-23 20:41:17 -060083 if type == 'error':
84 bb.fatal(msg)
85 else:
86 bb.warn(msg)
87
88 def _log_check_warn(self):
89 self._log_check_common('warning', '^(warn|Warn|WARNING:)')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050090
91 def _log_check_error(self):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060092 self._log_check_common('error', self.log_check_regex)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093
94 def _insert_feed_uris(self):
95 if bb.utils.contains("IMAGE_FEATURES", "package-management",
96 True, False, self.d):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050097 self.pm.insert_feeds_uris(self.d.getVar('PACKAGE_FEED_URIS') or "",
98 self.d.getVar('PACKAGE_FEED_BASE_PATHS') or "",
99 self.d.getVar('PACKAGE_FEED_ARCHS'))
100
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102 """
103 The _cleanup() method should be used to clean-up stuff that we don't really
104 want to end up on target. For example, in the case of RPM, the DB locks.
105 The method is called, once, at the end of create() method.
106 """
107 @abstractmethod
108 def _cleanup(self):
109 pass
110
111 def _setup_dbg_rootfs(self, dirs):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500112 gen_debugfs = self.d.getVar('IMAGE_GEN_DEBUGFS') or '0'
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113 if gen_debugfs != '1':
114 return
115
116 bb.note(" Renaming the original rootfs...")
117 try:
118 shutil.rmtree(self.image_rootfs + '-orig')
119 except:
120 pass
121 os.rename(self.image_rootfs, self.image_rootfs + '-orig')
122
123 bb.note(" Creating debug rootfs...")
124 bb.utils.mkdirhier(self.image_rootfs)
125
126 bb.note(" Copying back package database...")
127 for dir in dirs:
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600128 if not os.path.isdir(self.image_rootfs + '-orig' + dir):
129 continue
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130 bb.utils.mkdirhier(self.image_rootfs + os.path.dirname(dir))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600131 shutil.copytree(self.image_rootfs + '-orig' + dir, self.image_rootfs + dir, symlinks=True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500132
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500133 # Copy files located in /usr/lib/debug or /usr/src/debug
134 for dir in ["/usr/lib/debug", "/usr/src/debug"]:
135 src = self.image_rootfs + '-orig' + dir
Andrew Geissler82c905d2020-04-13 13:39:40 -0500136 if os.path.exists(src):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500137 dst = self.image_rootfs + dir
138 bb.utils.mkdirhier(os.path.dirname(dst))
139 shutil.copytree(src, dst)
140
141 # Copy files with suffix '.debug' or located in '.debug' dir.
Andrew Geissler82c905d2020-04-13 13:39:40 -0500142 for root, dirs, files in os.walk(self.image_rootfs + '-orig'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500143 relative_dir = root[len(self.image_rootfs + '-orig'):]
144 for f in files:
145 if f.endswith('.debug') or '/.debug' in relative_dir:
146 bb.utils.mkdirhier(self.image_rootfs + relative_dir)
147 shutil.copy(os.path.join(root, f),
148 self.image_rootfs + relative_dir)
149
150 bb.note(" Install complementary '*-dbg' packages...")
151 self.pm.install_complementary('*-dbg')
152
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800153 if self.d.getVar('PACKAGE_DEBUG_SPLIT_STYLE') == 'debug-with-srcpkg':
154 bb.note(" Install complementary '*-src' packages...")
155 self.pm.install_complementary('*-src')
156
157 """
158 Install additional debug packages. Possibility to install additional packages,
159 which are not automatically installed as complementary package of
160 standard one, e.g. debug package of static libraries.
161 """
162 extra_debug_pkgs = self.d.getVar('IMAGE_INSTALL_DEBUGFS')
163 if extra_debug_pkgs:
164 bb.note(" Install extra debug packages...")
165 self.pm.install(extra_debug_pkgs.split(), True)
166
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500167 bb.note(" Rename debug rootfs...")
168 try:
169 shutil.rmtree(self.image_rootfs + '-dbg')
170 except:
171 pass
172 os.rename(self.image_rootfs, self.image_rootfs + '-dbg')
173
174 bb.note(" Restoreing original rootfs...")
175 os.rename(self.image_rootfs + '-orig', self.image_rootfs)
176
177 def _exec_shell_cmd(self, cmd):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500178 fakerootcmd = self.d.getVar('FAKEROOT')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500179 if fakerootcmd is not None:
180 exec_cmd = [fakerootcmd, cmd]
181 else:
182 exec_cmd = cmd
183
184 try:
185 subprocess.check_output(exec_cmd, stderr=subprocess.STDOUT)
186 except subprocess.CalledProcessError as e:
187 return("Command '%s' returned %d:\n%s" % (e.cmd, e.returncode, e.output))
188
189 return None
190
191 def create(self):
192 bb.note("###### Generate rootfs #######")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500193 pre_process_cmds = self.d.getVar("ROOTFS_PREPROCESS_COMMAND")
194 post_process_cmds = self.d.getVar("ROOTFS_POSTPROCESS_COMMAND")
195 rootfs_post_install_cmds = self.d.getVar('ROOTFS_POSTINSTALL_COMMAND')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500196
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500197 bb.utils.mkdirhier(self.image_rootfs)
198
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600199 bb.utils.mkdirhier(self.deploydir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500200
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500201 execute_pre_post_process(self.d, pre_process_cmds)
202
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600203 if self.progress_reporter:
204 self.progress_reporter.next_stage()
205
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500206 # call the package manager dependent create method
207 self._create()
208
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500209 sysconfdir = self.image_rootfs + self.d.getVar('sysconfdir')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500210 bb.utils.mkdirhier(sysconfdir)
211 with open(sysconfdir + "/version", "w+") as ver:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500212 ver.write(self.d.getVar('BUILDNAME') + "\n")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500213
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500214 execute_pre_post_process(self.d, rootfs_post_install_cmds)
215
Brad Bishop316dfdd2018-06-25 12:45:53 -0400216 self.pm.run_intercepts()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500217
218 execute_pre_post_process(self.d, post_process_cmds)
219
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600220 if self.progress_reporter:
221 self.progress_reporter.next_stage()
222
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500223 if bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs",
224 True, False, self.d):
225 delayed_postinsts = self._get_delayed_postinsts()
226 if delayed_postinsts is not None:
227 bb.fatal("The following packages could not be configured "
228 "offline and rootfs is read-only: %s" %
229 delayed_postinsts)
230
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500231 if self.d.getVar('USE_DEVFS') != "1":
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500232 self._create_devfs()
233
234 self._uninstall_unneeded()
235
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600236 if self.progress_reporter:
237 self.progress_reporter.next_stage()
238
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500239 self._insert_feed_uris()
240
241 self._run_ldconfig()
242
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500243 if self.d.getVar('USE_DEPMOD') != "0":
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500244 self._generate_kernel_module_deps()
245
246 self._cleanup()
247 self._log_check()
248
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600249 if self.progress_reporter:
250 self.progress_reporter.next_stage()
251
252
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500253 def _uninstall_unneeded(self):
254 # Remove unneeded init script symlinks
255 delayed_postinsts = self._get_delayed_postinsts()
256 if delayed_postinsts is None:
257 if os.path.exists(self.d.expand("${IMAGE_ROOTFS}${sysconfdir}/init.d/run-postinsts")):
258 self._exec_shell_cmd(["update-rc.d", "-f", "-r",
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500259 self.d.getVar('IMAGE_ROOTFS'),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500260 "run-postinsts", "remove"])
261
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500262 image_rorfs = bb.utils.contains("IMAGE_FEATURES", "read-only-rootfs",
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500263 True, False, self.d)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500264 image_rorfs_force = self.d.getVar('FORCE_RO_REMOVE')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600265
266 if image_rorfs or image_rorfs_force == "1":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500267 # Remove components that we don't need if it's a read-only rootfs
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500268 unneeded_pkgs = self.d.getVar("ROOTFS_RO_UNNEEDED").split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500269 pkgs_installed = image_list_installed_packages(self.d)
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500270 # Make sure update-alternatives is removed last. This is
271 # because its database has to available while uninstalling
272 # other packages, allowing alternative symlinks of packages
273 # to be uninstalled or to be managed correctly otherwise.
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500274 provider = self.d.getVar("VIRTUAL-RUNTIME_update-alternatives")
275 pkgs_to_remove = sorted([pkg for pkg in pkgs_installed if pkg in unneeded_pkgs], key=lambda x: x == provider)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500276
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500277 # update-alternatives provider is removed in its own remove()
278 # call because all package managers do not guarantee the packages
279 # are removed in the order they given in the list (which is
280 # passed to the command line). The sorting done earlier is
281 # utilized to implement the 2-stage removal.
282 if len(pkgs_to_remove) > 1:
283 self.pm.remove(pkgs_to_remove[:-1], False)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500284 if len(pkgs_to_remove) > 0:
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500285 self.pm.remove([pkgs_to_remove[-1]], False)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500286
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500287 if delayed_postinsts:
288 self._save_postinsts()
289 if image_rorfs:
290 bb.warn("There are post install scripts "
291 "in a read-only rootfs")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500292
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500293 post_uninstall_cmds = self.d.getVar("ROOTFS_POSTUNINSTALL_COMMAND")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500294 execute_pre_post_process(self.d, post_uninstall_cmds)
295
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500296 runtime_pkgmanage = bb.utils.contains("IMAGE_FEATURES", "package-management",
297 True, False, self.d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500298 if not runtime_pkgmanage:
299 # Remove the package manager data files
300 self.pm.remove_packaging_data()
301
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500302 def _run_ldconfig(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500303 if self.d.getVar('LDCONFIGDEPEND'):
Andrew Geissler475cb722020-07-10 16:00:51 -0500304 bb.note("Executing: ldconfig -r " + self.image_rootfs + " -c new -v -X")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500305 self._exec_shell_cmd(['ldconfig', '-r', self.image_rootfs, '-c',
Andrew Geissler475cb722020-07-10 16:00:51 -0500306 'new', '-v', '-X'])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500307
308 def _check_for_kernel_modules(self, modules_dir):
309 for root, dirs, files in os.walk(modules_dir, topdown=True):
310 for name in files:
311 found_ko = name.endswith(".ko")
312 if found_ko:
313 return found_ko
314 return False
315
316 def _generate_kernel_module_deps(self):
317 modules_dir = os.path.join(self.image_rootfs, 'lib', 'modules')
318 # if we don't have any modules don't bother to do the depmod
319 if not self._check_for_kernel_modules(modules_dir):
320 bb.note("No Kernel Modules found, not running depmod")
321 return
322
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500323 kernel_abi_ver_file = oe.path.join(self.d.getVar('PKGDATA_DIR'), "kernel-depmod",
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500324 'kernel-abiversion')
325 if not os.path.exists(kernel_abi_ver_file):
326 bb.fatal("No kernel-abiversion file found (%s), cannot run depmod, aborting" % kernel_abi_ver_file)
327
328 kernel_ver = open(kernel_abi_ver_file).read().strip(' \n')
329 versioned_modules_dir = os.path.join(self.image_rootfs, modules_dir, kernel_ver)
330
331 bb.utils.mkdirhier(versioned_modules_dir)
332
333 self._exec_shell_cmd(['depmodwrapper', '-a', '-b', self.image_rootfs, kernel_ver])
334
335 """
336 Create devfs:
337 * IMAGE_DEVICE_TABLE is the old name to an absolute path to a device table file
338 * IMAGE_DEVICE_TABLES is a new name for a file, or list of files, seached
339 for in the BBPATH
340 If neither are specified then the default name of files/device_table-minimal.txt
341 is searched for in the BBPATH (same as the old version.)
342 """
343 def _create_devfs(self):
344 devtable_list = []
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500345 devtable = self.d.getVar('IMAGE_DEVICE_TABLE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500346 if devtable is not None:
347 devtable_list.append(devtable)
348 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500349 devtables = self.d.getVar('IMAGE_DEVICE_TABLES')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500350 if devtables is None:
351 devtables = 'files/device_table-minimal.txt'
352 for devtable in devtables.split():
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500353 devtable_list.append("%s" % bb.utils.which(self.d.getVar('BBPATH'), devtable))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500354
355 for devtable in devtable_list:
356 self._exec_shell_cmd(["makedevs", "-r",
357 self.image_rootfs, "-D", devtable])
358
359
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500360def get_class_for_type(imgtype):
Andrew Geissler635e0e42020-08-21 15:58:33 -0500361 from oe.package_manager.rpm.rootfs import RpmRootfs
362 from oe.package_manager.ipk.rootfs import OpkgRootfs
363 from oe.package_manager.deb.rootfs import DpkgRootfs
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500364 return {"rpm": RpmRootfs,
365 "ipk": OpkgRootfs,
366 "deb": DpkgRootfs}[imgtype]
367
368def variable_depends(d, manifest_dir=None):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500369 img_type = d.getVar('IMAGE_PKGTYPE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500370 cls = get_class_for_type(img_type)
371 return cls._depends_list()
372
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500373def create_rootfs(d, manifest_dir=None, progress_reporter=None, logcatcher=None):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500374 env_bkp = os.environ.copy()
375
Andrew Geissler635e0e42020-08-21 15:58:33 -0500376 from oe.package_manager.rpm.rootfs import RpmRootfs
377 from oe.package_manager.ipk.rootfs import OpkgRootfs
378 from oe.package_manager.deb.rootfs import DpkgRootfs
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500379 img_type = d.getVar('IMAGE_PKGTYPE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500380 if img_type == "rpm":
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500381 RpmRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500382 elif img_type == "ipk":
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500383 OpkgRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500384 elif img_type == "deb":
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500385 DpkgRootfs(d, manifest_dir, progress_reporter, logcatcher).create()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500386
387 os.environ.clear()
388 os.environ.update(env_bkp)
389
390
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500391def image_list_installed_packages(d, rootfs_dir=None):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500392 if not rootfs_dir:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500393 rootfs_dir = d.getVar('IMAGE_ROOTFS')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500394
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500395 img_type = d.getVar('IMAGE_PKGTYPE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500396 if img_type == "rpm":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500397 return RpmPkgsList(d, rootfs_dir).list_pkgs()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500398 elif img_type == "ipk":
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500399 return OpkgPkgsList(d, rootfs_dir, d.getVar("IPKGCONF_TARGET")).list_pkgs()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500400 elif img_type == "deb":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500401 return DpkgPkgsList(d, rootfs_dir).list_pkgs()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500402
403if __name__ == "__main__":
404 """
405 We should be able to run this as a standalone script, from outside bitbake
406 environment.
407 """
408 """
409 TBD
410 """