summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo@ribalda.com>2020-03-04 14:49:35 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-06 15:45:11 (GMT)
commit6bac089383d725793485ab559209a1bbcaf2719e (patch)
treed96723a9f9238b70aeb4f6fb9ee3caa3d3707fa8
parentf4c7f9ebae9f4afc16a1ca31290665a6e7f4f83f (diff)
downloadpoky-6bac089383d725793485ab559209a1bbcaf2719e.tar.gz
wic: Fix permissions when using exclude or include path
When parameters include_path or exclude_path are passed to the rootfs plugin, it will copy the partition content into a folder and make all the modifications there. This is done using copyhardlinktree(), which does not take into consideration the content of the pseudo folder, which contains the information about the right permissions and ownership of the folders. This results in a rootfs owned by the user that is running the wic command (usually UID 1000), which makes some rootfs unbootable. To fix this we copy the content of the pseudo folders to the new folder and modify the pseudo database using the "pseudo -B" command. (From OE-Core rev: 36993eea89d1c011397b7692b9b8d61b499d0171) Signed-off-by: Ricardo Ribalda Delgado <ricardo@ribalda.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/wic/plugins/source/rootfs.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index 705aeb5..40419a6 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -16,11 +16,11 @@ import os
16import shutil 16import shutil
17import sys 17import sys
18 18
19from oe.path import copyhardlinktree 19from oe.path import copyhardlinktree, copytree
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):
49 pseudo = "export PSEUDO_PREFIX=%s/usr;" % native_sysroot
50 pseudo += "export PSEUDO_LOCALSTATEDIR=%s;" % os.path.join(rootfs, "../pseudo")
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,
@@ -78,9 +87,16 @@ class RootfsPlugin(SourcePlugin):
78 87
79 if os.path.lexists(new_rootfs): 88 if os.path.lexists(new_rootfs):
80 shutil.rmtree(os.path.join(new_rootfs)) 89 shutil.rmtree(os.path.join(new_rootfs))
81
82 copyhardlinktree(part.rootfs_dir, new_rootfs) 90 copyhardlinktree(part.rootfs_dir, new_rootfs)
83 91
92 if os.path.lexists(os.path.join(new_rootfs, "../pseudo")):
93 shutil.rmtree(os.path.join(new_rootfs, "../pseudo"))
94 copytree(os.path.join(part.rootfs_dir, "../pseudo"),
95 os.path.join(new_rootfs, "../pseudo"))
96 pseudo_cmd = "%s -B -m %s -M %s" % (cls.__get_pseudo(native_sysroot,new_rootfs),
97 part.rootfs_dir, new_rootfs)
98 exec_native_cmd(pseudo_cmd, native_sysroot)
99
84 for path in part.include_path or []: 100 for path in part.include_path or []:
85 copyhardlinktree(path, new_rootfs) 101 copyhardlinktree(path, new_rootfs)
86 102