summaryrefslogtreecommitdiff
path: root/meta/lib
diff options
context:
space:
mode:
authorMark Hatle <mark.hatle@windriver.com>2015-05-22 12:56:53 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-23 08:10:14 +0100
commit1a6ed48c65f922c66b005aa966d7ee4878ee95e3 (patch)
tree1cf1d67c49d79be48b4d09f36a530679fd5087d6 /meta/lib
parent40016c7c19abdbdae4fcd86fab9672631f26712b (diff)
downloadopenembedded-core-1a6ed48c65f922c66b005aa966d7ee4878ee95e3.tar.gz
openembedded-core-1a6ed48c65f922c66b005aa966d7ee4878ee95e3.tar.bz2
openembedded-core-1a6ed48c65f922c66b005aa966d7ee4878ee95e3.zip
image.bbclass: Add a method for creating a companion debug filesystem
The companion debug filesystem contains only the package database and the complementary *-dbg packages for the main filesystem component. This is useful in a production environment to produce a companion filesystem capable of remote system debugging, without requiring corresponding debug symbols or source code on the device. Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Robert Yang <liezhi.yang@windriver.com> If dbg pkgs have already been installed to the rootfs image, the installation to companion debug filesystem will fail, because both of image creation make use of the same pm database. In this situation, try to copy installed dbg files from rootfs image to companion debug filesystem. Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Acked-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/rootfs.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py
index a9a6c85a2c..5f1f7b3e5d 100644
--- a/meta/lib/oe/rootfs.py
+++ b/meta/lib/oe/rootfs.py
@@ -95,6 +95,57 @@ class Rootfs(object):
def _cleanup(self):
pass
+ def _setup_dbg_rootfs(self, dirs):
+ gen_debugfs = self.d.getVar('IMAGE_GEN_DEBUGFS', True) or '0'
+ if gen_debugfs != '1':
+ return
+
+ bb.note(" Renaming the original rootfs...")
+ try:
+ shutil.rmtree(self.image_rootfs + '-orig')
+ except:
+ pass
+ os.rename(self.image_rootfs, self.image_rootfs + '-orig')
+
+ bb.note(" Creating debug rootfs...")
+ bb.utils.mkdirhier(self.image_rootfs)
+
+ bb.note(" Copying back package database...")
+ for dir in dirs:
+ bb.utils.mkdirhier(self.image_rootfs + os.path.dirname(dir))
+ shutil.copytree(self.image_rootfs + '-orig' + dir, self.image_rootfs + dir)
+
+ cpath = oe.cachedpath.CachedPath()
+ # Copy files located in /usr/lib/debug or /usr/src/debug
+ for dir in ["/usr/lib/debug", "/usr/src/debug"]:
+ src = self.image_rootfs + '-orig' + dir
+ if cpath.exists(src):
+ dst = self.image_rootfs + dir
+ bb.utils.mkdirhier(os.path.dirname(dst))
+ shutil.copytree(src, dst)
+
+ # Copy files with suffix '.debug' or located in '.debug' dir.
+ for root, dirs, files in cpath.walk(self.image_rootfs + '-orig'):
+ relative_dir = root[len(self.image_rootfs + '-orig'):]
+ for f in files:
+ if f.endswith('.debug') or '/.debug' in relative_dir:
+ bb.utils.mkdirhier(self.image_rootfs + relative_dir)
+ shutil.copy(os.path.join(root, f),
+ self.image_rootfs + relative_dir)
+
+ bb.note(" Install complementary '*-dbg' packages...")
+ self.pm.install_complementary('*-dbg')
+
+ bb.note(" Rename debug rootfs...")
+ try:
+ shutil.rmtree(self.image_rootfs + '-dbg')
+ except:
+ pass
+ os.rename(self.image_rootfs, self.image_rootfs + '-dbg')
+
+ bb.note(" Restoreing original rootfs...")
+ os.rename(self.image_rootfs + '-orig', self.image_rootfs)
+
def _exec_shell_cmd(self, cmd):
fakerootcmd = self.d.getVar('FAKEROOT', True)
if fakerootcmd is not None:
@@ -369,6 +420,8 @@ class RpmRootfs(Rootfs):
self.pm.install_complementary()
+ self._setup_dbg_rootfs(['/etc/rpm', '/var/lib/rpm', '/var/lib/smart'])
+
if self.inc_rpm_image_gen == "1":
self.pm.backup_packaging_data()
@@ -475,6 +528,8 @@ class DpkgRootfs(Rootfs):
self.pm.install_complementary()
+ self._setup_dbg_rootfs(['/var/lib/dpkg'])
+
self.pm.fix_broken_dependencies()
self.pm.mark_packages("installed")
@@ -743,6 +798,8 @@ class OpkgRootfs(Rootfs):
self.pm.install_complementary()
+ self._setup_dbg_rootfs(['/var/lib/opkg'])
+
execute_pre_post_process(self.d, opkg_post_process_cmds)
execute_pre_post_process(self.d, rootfs_post_install_cmds)