blob: 9fe1687ac31d067b47ff1e2d004f77d00a8fcab6 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001from abc import ABCMeta, abstractmethod
2from oe.utils import execute_pre_post_process
3from oe.manifest import *
4from oe.package_manager import *
5import os
6import shutil
7import glob
Patrick Williamsf1e5d692016-03-30 15:21:19 -05008import traceback
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
10
Patrick Williamsc0f7c042017-02-23 20:41:17 -060011class Sdk(object, metaclass=ABCMeta):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012 def __init__(self, d, manifest_dir):
13 self.d = d
Brad Bishop6e60e8b2018-02-01 10:27:11 -050014 self.sdk_output = self.d.getVar('SDK_OUTPUT')
15 self.sdk_native_path = self.d.getVar('SDKPATHNATIVE').strip('/')
16 self.target_path = self.d.getVar('SDKTARGETSYSROOT').strip('/')
17 self.sysconfdir = self.d.getVar('sysconfdir').strip('/')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018
19 self.sdk_target_sysroot = os.path.join(self.sdk_output, self.target_path)
20 self.sdk_host_sysroot = self.sdk_output
21
22 if manifest_dir is None:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023 self.manifest_dir = self.d.getVar("SDK_DIR")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 else:
25 self.manifest_dir = manifest_dir
26
Patrick Williamsf1e5d692016-03-30 15:21:19 -050027 self.remove(self.sdk_output, True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028
29 self.install_order = Manifest.INSTALL_ORDER
30
31 @abstractmethod
32 def _populate(self):
33 pass
34
35 def populate(self):
Patrick Williamsf1e5d692016-03-30 15:21:19 -050036 self.mkdirhier(self.sdk_output)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037
38 # call backend dependent implementation
39 self._populate()
40
41 # Don't ship any libGL in the SDK
Patrick Williamsf1e5d692016-03-30 15:21:19 -050042 self.remove(os.path.join(self.sdk_output, self.sdk_native_path,
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043 self.d.getVar('libdir_nativesdk').strip('/'),
Patrick Williamsf1e5d692016-03-30 15:21:19 -050044 "libGL*"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045
46 # Fix or remove broken .la files
Patrick Williamsf1e5d692016-03-30 15:21:19 -050047 self.remove(os.path.join(self.sdk_output, self.sdk_native_path,
Brad Bishop6e60e8b2018-02-01 10:27:11 -050048 self.d.getVar('libdir_nativesdk').strip('/'),
Patrick Williamsf1e5d692016-03-30 15:21:19 -050049 "*.la"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050
51 # Link the ld.so.cache file into the hosts filesystem
52 link_name = os.path.join(self.sdk_output, self.sdk_native_path,
53 self.sysconfdir, "ld.so.cache")
Patrick Williamsf1e5d692016-03-30 15:21:19 -050054 self.mkdirhier(os.path.dirname(link_name))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055 os.symlink("/etc/ld.so.cache", link_name)
56
Brad Bishop6e60e8b2018-02-01 10:27:11 -050057 execute_pre_post_process(self.d, self.d.getVar('SDK_POSTPROCESS_COMMAND'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058
Patrick Williamsf1e5d692016-03-30 15:21:19 -050059 def movefile(self, sourcefile, destdir):
60 try:
61 # FIXME: this check of movefile's return code to None should be
62 # fixed within the function to use only exceptions to signal when
63 # something goes wrong
64 if (bb.utils.movefile(sourcefile, destdir) == None):
65 raise OSError("moving %s to %s failed"
66 %(sourcefile, destdir))
67 #FIXME: using umbrella exc catching because bb.utils method raises it
68 except Exception as e:
69 bb.debug(1, "printing the stack trace\n %s" %traceback.format_exc())
70 bb.error("unable to place %s in final SDK location" % sourcefile)
71
72 def mkdirhier(self, dirpath):
73 try:
74 bb.utils.mkdirhier(dirpath)
75 except OSError as e:
76 bb.debug(1, "printing the stack trace\n %s" %traceback.format_exc())
77 bb.fatal("cannot make dir for SDK: %s" % dirpath)
78
79 def remove(self, path, recurse=False):
80 try:
81 bb.utils.remove(path, recurse)
82 #FIXME: using umbrella exc catching because bb.utils method raises it
83 except Exception as e:
84 bb.debug(1, "printing the stack trace\n %s" %traceback.format_exc())
85 bb.warn("cannot remove SDK dir: %s" % path)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086
87class RpmSdk(Sdk):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050088 def __init__(self, d, manifest_dir=None, rpm_workdir="oe-sdk-repo"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050089 super(RpmSdk, self).__init__(d, manifest_dir)
90
91 self.target_manifest = RpmManifest(d, self.manifest_dir,
92 Manifest.MANIFEST_TYPE_SDK_TARGET)
93 self.host_manifest = RpmManifest(d, self.manifest_dir,
94 Manifest.MANIFEST_TYPE_SDK_HOST)
95
96 target_providename = ['/bin/sh',
97 '/bin/bash',
98 '/usr/bin/env',
99 '/usr/bin/perl',
100 'pkgconfig'
101 ]
102
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500103 rpm_repo_workdir = "oe-sdk-repo"
104 if "sdk_ext" in d.getVar("BB_RUNTASK"):
105 rpm_repo_workdir = "oe-sdk-ext-repo"
106
107
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108 self.target_pm = RpmPM(d,
109 self.sdk_target_sysroot,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500110 self.d.getVar('TARGET_VENDOR'),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111 'target',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500112 target_providename,
113 rpm_repo_workdir=rpm_repo_workdir
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500114 )
115
116 sdk_providename = ['/bin/sh',
117 '/bin/bash',
118 '/usr/bin/env',
119 '/usr/bin/perl',
120 'pkgconfig',
121 'libGL.so()(64bit)',
122 'libGL.so'
123 ]
124
125 self.host_pm = RpmPM(d,
126 self.sdk_host_sysroot,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500127 self.d.getVar('SDK_VENDOR'),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128 'host',
129 sdk_providename,
130 "SDK_PACKAGE_ARCHS",
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500131 "SDK_OS",
132 rpm_repo_workdir=rpm_repo_workdir
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500133 )
134
135 def _populate_sysroot(self, pm, manifest):
136 pkgs_to_install = manifest.parse_initial_manifest()
137
138 pm.create_configs()
139 pm.write_index()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140 pm.update()
141
142 pkgs = []
143 pkgs_attempt = []
144 for pkg_type in pkgs_to_install:
145 if pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY:
146 pkgs_attempt += pkgs_to_install[pkg_type]
147 else:
148 pkgs += pkgs_to_install[pkg_type]
149
150 pm.install(pkgs)
151
152 pm.install(pkgs_attempt, True)
153
154 def _populate(self):
155 bb.note("Installing TARGET packages")
156 self._populate_sysroot(self.target_pm, self.target_manifest)
157
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500158 self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500159
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500160 execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500161
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600162 if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d):
163 self.target_pm.remove_packaging_data()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500164
165 bb.note("Installing NATIVESDK packages")
166 self._populate_sysroot(self.host_pm, self.host_manifest)
167
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500168 execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500169
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600170 if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d):
171 self.host_pm.remove_packaging_data()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500172
173 # Move host RPM library data
174 native_rpm_state_dir = os.path.join(self.sdk_output,
175 self.sdk_native_path,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500176 self.d.getVar('localstatedir_nativesdk').strip('/'),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177 "lib",
178 "rpm"
179 )
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500180 self.mkdirhier(native_rpm_state_dir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500181 for f in glob.glob(os.path.join(self.sdk_output,
182 "var",
183 "lib",
184 "rpm",
185 "*")):
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500186 self.movefile(f, native_rpm_state_dir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500187
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500188 self.remove(os.path.join(self.sdk_output, "var"), True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500189
190 # Move host sysconfig data
191 native_sysconf_dir = os.path.join(self.sdk_output,
192 self.sdk_native_path,
193 self.d.getVar('sysconfdir',
194 True).strip('/'),
195 )
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500196 self.mkdirhier(native_sysconf_dir)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500197 for f in glob.glob(os.path.join(self.sdk_output, "etc", "rpm*")):
198 self.movefile(f, native_sysconf_dir)
199 for f in glob.glob(os.path.join(self.sdk_output, "etc", "dnf", "*")):
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500200 self.movefile(f, native_sysconf_dir)
201 self.remove(os.path.join(self.sdk_output, "etc"), True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500202
203
204class OpkgSdk(Sdk):
205 def __init__(self, d, manifest_dir=None):
206 super(OpkgSdk, self).__init__(d, manifest_dir)
207
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500208 self.target_conf = self.d.getVar("IPKGCONF_TARGET")
209 self.host_conf = self.d.getVar("IPKGCONF_SDK")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500210
211 self.target_manifest = OpkgManifest(d, self.manifest_dir,
212 Manifest.MANIFEST_TYPE_SDK_TARGET)
213 self.host_manifest = OpkgManifest(d, self.manifest_dir,
214 Manifest.MANIFEST_TYPE_SDK_HOST)
215
216 self.target_pm = OpkgPM(d, self.sdk_target_sysroot, self.target_conf,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500217 self.d.getVar("ALL_MULTILIB_PACKAGE_ARCHS"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500218
219 self.host_pm = OpkgPM(d, self.sdk_host_sysroot, self.host_conf,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500220 self.d.getVar("SDK_PACKAGE_ARCHS"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500221
222 def _populate_sysroot(self, pm, manifest):
223 pkgs_to_install = manifest.parse_initial_manifest()
224
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500225 if (self.d.getVar('BUILD_IMAGES_FROM_FEEDS') or "") != "1":
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500226 pm.write_index()
227
228 pm.update()
229
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500230 for pkg_type in self.install_order:
231 if pkg_type in pkgs_to_install:
232 pm.install(pkgs_to_install[pkg_type],
233 [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500234
235 def _populate(self):
236 bb.note("Installing TARGET packages")
237 self._populate_sysroot(self.target_pm, self.target_manifest)
238
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500239 self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500240
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500241 execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500242
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600243 if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d):
244 self.target_pm.remove_packaging_data()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500245
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500246 bb.note("Installing NATIVESDK packages")
247 self._populate_sysroot(self.host_pm, self.host_manifest)
248
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500249 execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500250
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600251 if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d):
252 self.host_pm.remove_packaging_data()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500253
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500254 target_sysconfdir = os.path.join(self.sdk_target_sysroot, self.sysconfdir)
255 host_sysconfdir = os.path.join(self.sdk_host_sysroot, self.sysconfdir)
256
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500257 self.mkdirhier(target_sysconfdir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500258 shutil.copy(self.target_conf, target_sysconfdir)
259 os.chmod(os.path.join(target_sysconfdir,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600260 os.path.basename(self.target_conf)), 0o644)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500261
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500262 self.mkdirhier(host_sysconfdir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500263 shutil.copy(self.host_conf, host_sysconfdir)
264 os.chmod(os.path.join(host_sysconfdir,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600265 os.path.basename(self.host_conf)), 0o644)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500266
267 native_opkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500268 self.d.getVar('localstatedir_nativesdk').strip('/'),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500269 "lib", "opkg")
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500270 self.mkdirhier(native_opkg_state_dir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500271 for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "opkg", "*")):
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500272 self.movefile(f, native_opkg_state_dir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500273
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500274 self.remove(os.path.join(self.sdk_output, "var"), True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500275
276
277class DpkgSdk(Sdk):
278 def __init__(self, d, manifest_dir=None):
279 super(DpkgSdk, self).__init__(d, manifest_dir)
280
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500281 self.target_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt")
282 self.host_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt-sdk")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500283
284 self.target_manifest = DpkgManifest(d, self.manifest_dir,
285 Manifest.MANIFEST_TYPE_SDK_TARGET)
286 self.host_manifest = DpkgManifest(d, self.manifest_dir,
287 Manifest.MANIFEST_TYPE_SDK_HOST)
288
289 self.target_pm = DpkgPM(d, self.sdk_target_sysroot,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500290 self.d.getVar("PACKAGE_ARCHS"),
291 self.d.getVar("DPKG_ARCH"),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500292 self.target_conf_dir)
293
294 self.host_pm = DpkgPM(d, self.sdk_host_sysroot,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500295 self.d.getVar("SDK_PACKAGE_ARCHS"),
296 self.d.getVar("DEB_SDK_ARCH"),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500297 self.host_conf_dir)
298
299 def _copy_apt_dir_to(self, dst_dir):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500300 staging_etcdir_native = self.d.getVar("STAGING_ETCDIR_NATIVE")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500301
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500302 self.remove(dst_dir, True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500303
304 shutil.copytree(os.path.join(staging_etcdir_native, "apt"), dst_dir)
305
306 def _populate_sysroot(self, pm, manifest):
307 pkgs_to_install = manifest.parse_initial_manifest()
308
309 pm.write_index()
310 pm.update()
311
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500312 for pkg_type in self.install_order:
313 if pkg_type in pkgs_to_install:
314 pm.install(pkgs_to_install[pkg_type],
315 [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500316
317 def _populate(self):
318 bb.note("Installing TARGET packages")
319 self._populate_sysroot(self.target_pm, self.target_manifest)
320
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500321 self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500322
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500323 execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500324
325 self._copy_apt_dir_to(os.path.join(self.sdk_target_sysroot, "etc", "apt"))
326
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600327 if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d):
328 self.target_pm.remove_packaging_data()
329
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500330 bb.note("Installing NATIVESDK packages")
331 self._populate_sysroot(self.host_pm, self.host_manifest)
332
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500333 execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500334
335 self._copy_apt_dir_to(os.path.join(self.sdk_output, self.sdk_native_path,
336 "etc", "apt"))
337
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600338 if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d):
339 self.host_pm.remove_packaging_data()
340
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500341 native_dpkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path,
342 "var", "lib", "dpkg")
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500343 self.mkdirhier(native_dpkg_state_dir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500344 for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "dpkg", "*")):
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500345 self.movefile(f, native_dpkg_state_dir)
346 self.remove(os.path.join(self.sdk_output, "var"), True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500347
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500348
349
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500350def sdk_list_installed_packages(d, target, rootfs_dir=None):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500351 if rootfs_dir is None:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500352 sdk_output = d.getVar('SDK_OUTPUT')
353 target_path = d.getVar('SDKTARGETSYSROOT').strip('/')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500354
355 rootfs_dir = [sdk_output, os.path.join(sdk_output, target_path)][target is True]
356
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500357 img_type = d.getVar('IMAGE_PKGTYPE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500358 if img_type == "rpm":
359 arch_var = ["SDK_PACKAGE_ARCHS", None][target is True]
360 os_var = ["SDK_OS", None][target is True]
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500361 return RpmPkgsList(d, rootfs_dir).list_pkgs()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500362 elif img_type == "ipk":
363 conf_file_var = ["IPKGCONF_SDK", "IPKGCONF_TARGET"][target is True]
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500364 return OpkgPkgsList(d, rootfs_dir, d.getVar(conf_file_var)).list_pkgs()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500365 elif img_type == "deb":
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500366 return DpkgPkgsList(d, rootfs_dir).list_pkgs()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500367
368def populate_sdk(d, manifest_dir=None):
369 env_bkp = os.environ.copy()
370
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500371 img_type = d.getVar('IMAGE_PKGTYPE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500372 if img_type == "rpm":
373 RpmSdk(d, manifest_dir).populate()
374 elif img_type == "ipk":
375 OpkgSdk(d, manifest_dir).populate()
376 elif img_type == "deb":
377 DpkgSdk(d, manifest_dir).populate()
378
379 os.environ.clear()
380 os.environ.update(env_bkp)
381
382if __name__ == "__main__":
383 pass