diff options
author | Laurentiu Palcu <laurentiu.palcu@intel.com> | 2014-01-13 10:13:51 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-02-11 11:53:39 +0000 |
commit | 31906d8e916f72da8493655672bd6731e46b20f5 (patch) | |
tree | c0e94ef3153d5df20b434020c267ca4fd6e65b18 /meta | |
parent | ed83ace10a850aec516d492c5a2f7508d9749910 (diff) | |
download | poky-31906d8e916f72da8493655672bd6731e46b20f5.tar.gz |
lib/oe/rootfs.py: add support for opkg backend
(From OE-Core rev: 0650e1f2354cdb6f925040d9d07e2c785274a592)
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oe/rootfs.py | 158 |
1 files changed, 149 insertions, 9 deletions
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py index abdb0dd18a..bada5ca467 100644 --- a/meta/lib/oe/rootfs.py +++ b/meta/lib/oe/rootfs.py | |||
@@ -15,17 +15,20 @@ class Rootfs(object): | |||
15 | """ | 15 | """ |
16 | __metaclass__ = ABCMeta | 16 | __metaclass__ = ABCMeta |
17 | 17 | ||
18 | def __init__(self, d, manifest_dir=None): | 18 | def __init__(self, d): |
19 | self.d = d | 19 | self.d = d |
20 | self.pm = None | 20 | self.pm = None |
21 | self.manifest = None | ||
22 | self.image_rootfs = self.d.getVar('IMAGE_ROOTFS', True) | 21 | self.image_rootfs = self.d.getVar('IMAGE_ROOTFS', True) |
23 | self.deploy_dir_image = self.d.getVar('DEPLOY_DIR_IMAGE', True) | 22 | self.deploy_dir_image = self.d.getVar('DEPLOY_DIR_IMAGE', True) |
24 | 23 | ||
25 | bb.utils.remove(self.image_rootfs, True) | 24 | bb.utils.remove(self.image_rootfs, True) |
26 | bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS', True), True) | 25 | bb.utils.remove(self.d.getVar('MULTILIB_TEMP_ROOTFS', True), True) |
27 | 26 | ||
28 | self.install_order = ["lgp", "mip", "aop", "mlp"] | 27 | self.install_order = [ |
28 | Manifest.PKG_TYPE_LANGUAGE, | ||
29 | Manifest.PKG_TYPE_MUST_INSTALL, | ||
30 | Manifest.PKG_TYPE_ATTEMPT_ONLY, | ||
31 | Manifest.PKG_TYPE_MULTILIB] | ||
29 | 32 | ||
30 | @abstractmethod | 33 | @abstractmethod |
31 | def _create(self): | 34 | def _create(self): |
@@ -225,7 +228,7 @@ class RpmRootfs(Rootfs): | |||
225 | 228 | ||
226 | class DpkgRootfs(Rootfs): | 229 | class DpkgRootfs(Rootfs): |
227 | def __init__(self, d, manifest_dir): | 230 | def __init__(self, d, manifest_dir): |
228 | super(DpkgRootfs, self).__init__(d, manifest_dir) | 231 | super(DpkgRootfs, self).__init__(d) |
229 | 232 | ||
230 | self.manifest = DpkgManifest(d, manifest_dir) | 233 | self.manifest = DpkgManifest(d, manifest_dir) |
231 | self.pm = DpkgPM(d, d.getVar('IMAGE_ROOTFS', True), | 234 | self.pm = DpkgPM(d, d.getVar('IMAGE_ROOTFS', True), |
@@ -246,7 +249,7 @@ class DpkgRootfs(Rootfs): | |||
246 | for pkg_type in self.install_order: | 249 | for pkg_type in self.install_order: |
247 | if pkg_type in pkgs_to_install: | 250 | if pkg_type in pkgs_to_install: |
248 | self.pm.install(pkgs_to_install[pkg_type], | 251 | self.pm.install(pkgs_to_install[pkg_type], |
249 | [False, True][pkg_type == "aop"]) | 252 | [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) |
250 | 253 | ||
251 | self.pm.install_complementary() | 254 | self.pm.install_complementary() |
252 | 255 | ||
@@ -297,11 +300,148 @@ class DpkgRootfs(Rootfs): | |||
297 | 300 | ||
298 | 301 | ||
299 | class OpkgRootfs(Rootfs): | 302 | class OpkgRootfs(Rootfs): |
300 | def __init__(self, manifest): | 303 | def __init__(self, d, manifest_dir): |
301 | super(OpkgRootfs, self).__init__(manifest) | 304 | super(OpkgRootfs, self).__init__(d) |
305 | |||
306 | self.manifest = OpkgManifest(d, manifest_dir) | ||
307 | self.opkg_conf = self.d.getVar("IPKGCONF_TARGET", True) | ||
308 | self.pkg_archs = self.d.getVar("ALL_MULTILIB_PACKAGE_ARCHS", True) | ||
309 | |||
310 | self.pm = OpkgPM(d, self.image_rootfs, self.opkg_conf, self.pkg_archs) | ||
311 | |||
302 | """ | 312 | """ |
303 | TBD | 313 | This function was reused from the old implementation. |
314 | See commit: "image.bbclass: Added variables for multilib support." by | ||
315 | Lianhao Lu. | ||
304 | """ | 316 | """ |
317 | def _multilib_sanity_test(self, dirs): | ||
318 | import filecmp | ||
319 | |||
320 | allow_replace = self.d.getVar("MULTILIBRE_ALLOW_REP", True) | ||
321 | if allow_replace is None: | ||
322 | allow_replace = "" | ||
323 | |||
324 | allow_rep = re.compile(re.sub("\|$", "", allow_replace)) | ||
325 | error_prompt = "Multilib check error:" | ||
326 | |||
327 | files = {} | ||
328 | for dir in dirs: | ||
329 | for root, subfolders, subfiles in os.walk(dir): | ||
330 | for file in subfiles: | ||
331 | item = os.path.join(root, file) | ||
332 | key = str(os.path.join("/", os.path.relpath(item, dir))) | ||
333 | |||
334 | valid = True | ||
335 | if key in files: | ||
336 | #check whether the file is allow to replace | ||
337 | if allow_rep.match(key): | ||
338 | valid = True | ||
339 | else: | ||
340 | if not filecmp.cmp(files[key], item): | ||
341 | valid = False | ||
342 | bb.fatal("%s duplicate files %s %s is not the same\n" % | ||
343 | (error_prompt, item, files[key])) | ||
344 | |||
345 | #pass the check, add to list | ||
346 | if valid: | ||
347 | files[key] = item | ||
348 | |||
349 | def _multilib_test_install(self, pkgs): | ||
350 | ml_temp = self.d.getVar("MULTILIB_TEMP_ROOTFS", True) | ||
351 | bb.utils.mkdirhier(ml_temp) | ||
352 | |||
353 | dirs = [self.image_rootfs] | ||
354 | |||
355 | for variant in self.d.getVar("MULTILIB_VARIANTS", True).split(): | ||
356 | ml_target_rootfs = os.path.join(ml_temp, variant) | ||
357 | |||
358 | bb.utils.remove(ml_target_rootfs, True) | ||
359 | |||
360 | ml_opkg_conf = os.path.join(ml_temp, | ||
361 | variant + "-" + os.path.basename(self.opkg_conf)) | ||
362 | |||
363 | ml_pm = OpkgPM(self.d, ml_target_rootfs, ml_opkg_conf, self.pkg_archs) | ||
364 | |||
365 | ml_pm.update() | ||
366 | ml_pm.install(pkgs) | ||
367 | |||
368 | dirs.append(ml_target_rootfs) | ||
369 | |||
370 | self._multilib_sanity_test(dirs) | ||
371 | |||
372 | def _create(self): | ||
373 | pkgs_to_install = self.manifest.parse_initial_manifest() | ||
374 | opkg_pre_process_cmds = self.d.getVar('OPKG_PREPROCESS_COMMANDS', True) | ||
375 | opkg_post_process_cmds = self.d.getVar('OPKG_POSTPROCESS_COMMANDS', True) | ||
376 | rootfs_post_install_cmds = self.d.getVar('ROOTFS_POSTINSTALL_COMMAND', True) | ||
377 | |||
378 | # update PM index files | ||
379 | self.pm.write_index() | ||
380 | |||
381 | execute_pre_post_process(self.d, opkg_pre_process_cmds) | ||
382 | |||
383 | self.pm.update() | ||
384 | |||
385 | self.pm.handle_bad_recommendations() | ||
386 | |||
387 | for pkg_type in self.install_order: | ||
388 | if pkg_type in pkgs_to_install: | ||
389 | # For multilib, we perform a sanity test before final install | ||
390 | # If sanity test fails, it will automatically do a bb.fatal() | ||
391 | # and the installation will stop | ||
392 | if pkg_type == Manifest.PKG_TYPE_MULTILIB: | ||
393 | self._multilib_test_install(pkgs_to_install[pkg_type]) | ||
394 | |||
395 | self.pm.install(pkgs_to_install[pkg_type], | ||
396 | [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) | ||
397 | |||
398 | self.pm.install_complementary() | ||
399 | |||
400 | execute_pre_post_process(self.d, opkg_post_process_cmds) | ||
401 | execute_pre_post_process(self.d, rootfs_post_install_cmds) | ||
402 | |||
403 | def _get_delayed_postinsts(self): | ||
404 | pkg_list = [] | ||
405 | status_file = os.path.join(self.image_rootfs, | ||
406 | self.d.getVar('OPKGLIBDIR', True), | ||
407 | "opkg", "status") | ||
408 | |||
409 | with open(status_file) as status: | ||
410 | for line in status: | ||
411 | m_pkg = re.match("^Package: (.*)", line) | ||
412 | m_status = re.match("^Status:.*unpacked", line) | ||
413 | if m_pkg is not None: | ||
414 | pkg_name = m_pkg.group(1) | ||
415 | elif m_status is not None: | ||
416 | pkg_list.append(pkg_name) | ||
417 | |||
418 | if len(pkg_list) == 0: | ||
419 | return None | ||
420 | |||
421 | return pkg_list | ||
422 | |||
423 | def _save_postinsts(self): | ||
424 | num = 0 | ||
425 | for p in self._get_delayed_postinsts(): | ||
426 | dst_postinst_dir = self.d.expand("${IMAGE_ROOTFS}${sysconfdir}/ipk-postinsts") | ||
427 | src_postinst_dir = self.d.expand("${IMAGE_ROOTFS}${OPKGLIBDIR}/opkg/info") | ||
428 | |||
429 | bb.utils.mkdirhier(dst_postinst_dir) | ||
430 | |||
431 | if os.path.exists(os.path.join(src_postinst_dir, p + ".postinst")): | ||
432 | shutil.copy(os.path.join(src_postinst_dir, p + ".postinst"), | ||
433 | os.path.join(dst_postinst_dir, "%03d-%s" % (num, p))) | ||
434 | |||
435 | num += 1 | ||
436 | |||
437 | def _handle_intercept_failure(self, registered_pkgs): | ||
438 | self.pm.mark_packages("unpacked", registered_pkgs.split()) | ||
439 | |||
440 | def _log_check(self): | ||
441 | pass | ||
442 | |||
443 | def _insert_feed_uris(self): | ||
444 | pass | ||
305 | 445 | ||
306 | 446 | ||
307 | def create_rootfs(d, manifest_dir=None): | 447 | def create_rootfs(d, manifest_dir=None): |
@@ -311,7 +451,7 @@ def create_rootfs(d, manifest_dir=None): | |||
311 | if img_type == "rpm": | 451 | if img_type == "rpm": |
312 | bb.fatal("RPM backend was not implemented yet...") | 452 | bb.fatal("RPM backend was not implemented yet...") |
313 | elif img_type == "ipk": | 453 | elif img_type == "ipk": |
314 | bb.fatal("IPK backend was not implemented yet...") | 454 | OpkgRootfs(d, manifest_dir).create() |
315 | elif img_type == "deb": | 455 | elif img_type == "deb": |
316 | DpkgRootfs(d, manifest_dir).create() | 456 | DpkgRootfs(d, manifest_dir).create() |
317 | 457 | ||