summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/source/rootfs.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/plugins/source/rootfs.py')
-rw-r--r--scripts/lib/wic/plugins/source/rootfs.py37
1 files changed, 34 insertions, 3 deletions
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index 705aeb5563..8b2a067385 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -20,7 +20,7 @@ from oe.path import copyhardlinktree
20 20
21from wic import WicError 21from wic import WicError
22from wic.pluginbase import SourcePlugin 22from wic.pluginbase import SourcePlugin
23from wic.misc import get_bitbake_var 23from wic.misc import get_bitbake_var, exec_native_cmd
24 24
25logger = logging.getLogger('wic') 25logger = logging.getLogger('wic')
26 26
@@ -44,6 +44,15 @@ class RootfsPlugin(SourcePlugin):
44 44
45 return os.path.realpath(image_rootfs_dir) 45 return os.path.realpath(image_rootfs_dir)
46 46
47 @staticmethod
48 def __get_pseudo(native_sysroot, rootfs, pseudo_dir):
49 pseudo = "export PSEUDO_PREFIX=%s/usr;" % native_sysroot
50 pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % pseudo_dir
51 pseudo += "export PSEUDO_PASSWD=%s;" % rootfs
52 pseudo += "export PSEUDO_NOSYMLINKEXP=1;"
53 pseudo += "%s " % get_bitbake_var("FAKEROOTCMD")
54 return pseudo
55
47 @classmethod 56 @classmethod
48 def do_prepare_partition(cls, part, source_params, cr, cr_workdir, 57 def do_prepare_partition(cls, part, source_params, cr, cr_workdir,
49 oe_builddir, bootimg_dir, kernel_dir, 58 oe_builddir, bootimg_dir, kernel_dir,
@@ -68,8 +77,14 @@ class RootfsPlugin(SourcePlugin):
68 "it is not a valid path, exiting" % part.rootfs_dir) 77 "it is not a valid path, exiting" % part.rootfs_dir)
69 78
70 part.rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) 79 part.rootfs_dir = cls.__get_rootfs_dir(rootfs_dir)
80 pseudo_dir = os.path.join(part.rootfs_dir, "../pseudo")
81 if not os.path.lexists(pseudo_dir):
82 logger.warn("%s folder does not exist. "
83 "Usernames and permissions will be invalid " % pseudo_dir)
84 pseudo_dir = None
71 85
72 new_rootfs = None 86 new_rootfs = None
87 new_pseudo = None
73 # Handle excluded paths. 88 # Handle excluded paths.
74 if part.exclude_path or part.include_path: 89 if part.exclude_path or part.include_path:
75 # We need a new rootfs directory we can delete files from. Copy to 90 # We need a new rootfs directory we can delete files from. Copy to
@@ -78,9 +93,24 @@ class RootfsPlugin(SourcePlugin):
78 93
79 if os.path.lexists(new_rootfs): 94 if os.path.lexists(new_rootfs):
80 shutil.rmtree(os.path.join(new_rootfs)) 95 shutil.rmtree(os.path.join(new_rootfs))
81
82 copyhardlinktree(part.rootfs_dir, new_rootfs) 96 copyhardlinktree(part.rootfs_dir, new_rootfs)
83 97
98 # Convert the pseudo directory to its new location
99 if (pseudo_dir):
100 new_pseudo = os.path.realpath(
101 os.path.join(cr_workdir, "pseudo%d" % part.lineno))
102 if os.path.lexists(new_pseudo):
103 shutil.rmtree(new_pseudo)
104 os.mkdir(new_pseudo)
105 shutil.copy(os.path.join(pseudo_dir, "files.db"),
106 os.path.join(new_pseudo, "files.db"))
107
108 pseudo_cmd = "%s -B -m %s -M %s" % (cls.__get_pseudo(native_sysroot,
109 new_rootfs,
110 new_pseudo),
111 part.rootfs_dir, new_rootfs)
112 exec_native_cmd(pseudo_cmd, native_sysroot)
113
84 for path in part.include_path or []: 114 for path in part.include_path or []:
85 copyhardlinktree(path, new_rootfs) 115 copyhardlinktree(path, new_rootfs)
86 116
@@ -112,4 +142,5 @@ class RootfsPlugin(SourcePlugin):
112 shutil.rmtree(full_path) 142 shutil.rmtree(full_path)
113 143
114 part.prepare_rootfs(cr_workdir, oe_builddir, 144 part.prepare_rootfs(cr_workdir, oe_builddir,
115 new_rootfs or part.rootfs_dir, native_sysroot) 145 new_rootfs or part.rootfs_dir, native_sysroot,
146 pseudo_dir = new_pseudo or pseudo_dir)