Skip to contentSkip to conversation

Add fake entry to Target_File for filesystem root

PATCH New brian avery 1 participant 2 messages Sep 22, 2015

lore
Share & tools
lore
#0 lore raw

cover Add fake entry to Target_File for filesystem root

The files-in-image.txt file is produced by bitbake after an image is created, listing all the files in the image. However, this list doesn't include the root directory ('/').

Fix this by creating a fake entry for the root directory in the Target_File table, so that the direct subdirectories of / can be assigned a parent. Note that it doesn't matter that the root is faked, as its properties are never shown in the directory structure tree.

The following changes since commit 7b86c771c80d0759c2ca0e57c46c4c966f89c49e:

bitbake: bitbake: bb.fetch2.git: Import errno module (2015-09-19 22:38:44 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib bavery/submit/elliot/20150921_add-fake-root-to-Target-File
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=bavery/submit/elliot/20150921_add-fake-root-to-Target-File

Elliot Smith (1):
toaster: Add fake entry to Target_File for filesystem root

 lib/bb/ui/buildinfohelper.py | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 toaster: Add fake entry to Target_File for filesystem root

From: Elliot Smith <[email protected]>

The files-in-image.txt file is produced by bitbake after an image is created, listing all the files in the image. However, this list doesn't include the root directory ('/').

buildinfohelper.py then tries to construct the filesystem tree from this file, assuming that every directory apart from the root directory (which is special-cased) can be assigned a parent. But because the root directory isn't listed in files-in-image.txt, an object for the root directory is never created.

The direct subdirectories of the root ('./bin', './usr' etc.) then can't be assigned a parent directory, as the object representing the root directory doesn't exist. This results in a Target_File lookup error and causes the directory listing page to fail.

Fix this by creating a fake entry for the root directory in the Target_File table, so that the direct subdirectories of / can be assigned a parent. Note that it doesn't matter that the root is faked, as its properties are never shown in the directory structure tree.

[YOCTO #8280]

---
 lib/bb/ui/buildinfohelper.py | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)
lib/bb/ui/buildinfohelper.py +17 -14
index 6e313fe..b2201f6 100644
@@ -353,26 +353,29 @@ class ORMWrapper(object):
         files = filedata['files']
         syms = filedata['syms']
 
-        # we insert directories, ordered by name depth
+        # always create the root directory as a special case;
+        # note that this is never displayed, so the owner, group,
+        # size, permission are irrelevant
+        tf_obj = Target_File.objects.create(target = target_obj,
+                                            path = '/',
+                                            size = 0,
+                                            owner = '',
+                                            group = '',
+                                            permission = '',
+                                            inodetype = Target_File.ITYPE_DIRECTORY)
+        tf_obj.save()
+
+        # insert directories, ordered by name depth
         for d in sorted(dirs, key=lambda x:len(x[-1].split("/"))):
             (user, group, size) = d[1:4]
             permission = d[0][1:]
             path = d[4].lstrip(".")
+
+            # we already created the root directory, so ignore any
+            # entry for it
             if len(path) == 0:
-                # we create the root directory as a special case
-                path = "/"
-                tf_obj = Target_File.objects.create(
-                        target = target_obj,
-                        path = path,
-                        size = size,
-                        inodetype = Target_File.ITYPE_DIRECTORY,
-                        permission = permission,
-                        owner = user,
-                        group = group,
-                        )
-                tf_obj.directory = tf_obj
-                tf_obj.save()
                 continue
+
             parent_path = "/".join(path.split("/")[:len(path.split("/")) - 1])
             if len(parent_path) == 0:
                 parent_path = "/"
Signature · 1 line
1.9.1