summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/wic/help.py6
-rw-r--r--scripts/lib/wic/ksparser.py1
-rw-r--r--scripts/lib/wic/partition.py1
-rw-r--r--scripts/lib/wic/plugins/source/rootfs.py43
-rwxr-xr-xscripts/wic2
5 files changed, 52 insertions, 1 deletions
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index 1bd411deeb..63bbc23a83 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -721,6 +721,12 @@ DESCRIPTION
721 partition table. It may be useful for 721 partition table. It may be useful for
722 bootloaders. 722 bootloaders.
723 723
724 --exclude-path: This option is specific to wic. It excludes the given
725 absolute path from the resulting image. If the path
726 ends with a slash, only the content of the directory
727 is omitted, not the directory itself. This option only
728 has an effect with the rootfs source plugin.
729
724 --extra-space: This option is specific to wic. It adds extra 730 --extra-space: This option is specific to wic. It adds extra
725 space after the space filled by the content 731 space after the space filled by the content
726 of the partition. The final size can go 732 of the partition. The final size can go
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index 41d3cc667f..f0aa5d0389 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -130,6 +130,7 @@ class KickStart():
130 part.add_argument('mountpoint', nargs='?') 130 part.add_argument('mountpoint', nargs='?')
131 part.add_argument('--active', action='store_true') 131 part.add_argument('--active', action='store_true')
132 part.add_argument('--align', type=int) 132 part.add_argument('--align', type=int)
133 part.add_argument('--exclude-path', nargs='+')
133 part.add_argument("--extra-space", type=sizetype) 134 part.add_argument("--extra-space", type=sizetype)
134 part.add_argument('--fsoptions', dest='fsopts') 135 part.add_argument('--fsoptions', dest='fsopts')
135 part.add_argument('--fstype') 136 part.add_argument('--fstype')
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 754ad757d0..1221f691dc 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -40,6 +40,7 @@ class Partition():
40 self.disk = args.disk 40 self.disk = args.disk
41 self.device = None 41 self.device = None
42 self.extra_space = args.extra_space 42 self.extra_space = args.extra_space
43 self.exclude_path = args.exclude_path
43 self.fsopts = args.fsopts 44 self.fsopts = args.fsopts
44 self.fstype = args.fstype 45 self.fstype = args.fstype
45 self.label = args.label 46 self.label = args.label
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py
index 9d959fa7d7..c57a4341d1 100644
--- a/scripts/lib/wic/plugins/source/rootfs.py
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -26,10 +26,13 @@
26# 26#
27 27
28import os 28import os
29import shutil
30
31from oe.path import copyhardlinktree
29 32
30from wic import msger 33from wic import msger
31from wic.pluginbase import SourcePlugin 34from wic.pluginbase import SourcePlugin
32from wic.utils.misc import get_bitbake_var 35from wic.utils.misc import get_bitbake_var, exec_cmd
33 36
34class RootfsPlugin(SourcePlugin): 37class RootfsPlugin(SourcePlugin):
35 """ 38 """
@@ -78,6 +81,44 @@ class RootfsPlugin(SourcePlugin):
78 81
79 real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) 82 real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir)
80 83
84 # Handle excluded paths.
85 if part.exclude_path is not None:
86 # We need a new rootfs directory we can delete files from. Copy to
87 # workdir.
88 new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs"))
89
90 if os.path.lexists(new_rootfs):
91 shutil.rmtree(os.path.join(new_rootfs))
92
93 copyhardlinktree(real_rootfs_dir, new_rootfs)
94
95 real_rootfs_dir = new_rootfs
96
97 for orig_path in part.exclude_path:
98 path = orig_path
99 if os.path.isabs(path):
100 msger.error("Must be relative: --exclude-path=%s" % orig_path)
101
102 full_path = os.path.realpath(os.path.join(new_rootfs, path))
103
104 # Disallow climbing outside of parent directory using '..',
105 # because doing so could be quite disastrous (we will delete the
106 # directory).
107 if not full_path.startswith(new_rootfs):
108 msger.error("'%s' points to a path outside the rootfs" % orig_path)
109
110 if path.endswith(os.sep):
111 # Delete content only.
112 for entry in os.listdir(full_path):
113 full_entry = os.path.join(full_path, entry)
114 if os.path.isdir(full_entry) and not os.path.islink(full_entry):
115 shutil.rmtree(full_entry)
116 else:
117 os.remove(full_entry)
118 else:
119 # Delete whole directory.
120 shutil.rmtree(full_path)
121
81 part.rootfs_dir = real_rootfs_dir 122 part.rootfs_dir = real_rootfs_dir
82 part.prepare_rootfs(cr_workdir, oe_builddir, 123 part.prepare_rootfs(cr_workdir, oe_builddir,
83 real_rootfs_dir, native_sysroot) 124 real_rootfs_dir, native_sysroot)
diff --git a/scripts/wic b/scripts/wic
index 1b7d7dfa4e..10a03eeea6 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -41,6 +41,8 @@ from distutils import spawn
41scripts_path = os.path.abspath(os.path.dirname(__file__)) 41scripts_path = os.path.abspath(os.path.dirname(__file__))
42lib_path = scripts_path + '/lib' 42lib_path = scripts_path + '/lib'
43sys.path.insert(0, lib_path) 43sys.path.insert(0, lib_path)
44oe_lib_path = os.path.join(os.path.dirname(scripts_path), 'meta', 'lib')
45sys.path.insert(0, oe_lib_path)
44 46
45bitbake_exe = spawn.find_executable('bitbake') 47bitbake_exe = spawn.find_executable('bitbake')
46if bitbake_exe: 48if bitbake_exe: