diff options
-rw-r--r-- | scripts/lib/wic/help.py | 6 | ||||
-rw-r--r-- | scripts/lib/wic/ksparser.py | 1 | ||||
-rw-r--r-- | scripts/lib/wic/partition.py | 1 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/rootfs.py | 21 |
4 files changed, 26 insertions, 3 deletions
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py index 1e3d06a87b..62a2a90e79 100644 --- a/scripts/lib/wic/help.py +++ b/scripts/lib/wic/help.py | |||
@@ -980,6 +980,12 @@ DESCRIPTION | |||
980 | copies. This option only has an effect with the rootfs | 980 | copies. This option only has an effect with the rootfs |
981 | source plugin. | 981 | source plugin. |
982 | 982 | ||
983 | --change-directory: This option is specific to wic. It changes to the | ||
984 | given directory before copying the files. This | ||
985 | option is useful when we want to split a rootfs in | ||
986 | multiple partitions and we want to keep the right | ||
987 | permissions and usernames in all the partitions. | ||
988 | |||
983 | --extra-space: This option is specific to wic. It adds extra | 989 | --extra-space: This option is specific to wic. It adds extra |
984 | space after the space filled by the content | 990 | space after the space filled by the content |
985 | of the partition. The final size can go | 991 | of the partition. The final size can go |
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py index 127ca79ade..452a160232 100644 --- a/scripts/lib/wic/ksparser.py +++ b/scripts/lib/wic/ksparser.py | |||
@@ -152,6 +152,7 @@ class KickStart(): | |||
152 | part.add_argument('--offset', type=sizetype("K", True)) | 152 | part.add_argument('--offset', type=sizetype("K", True)) |
153 | part.add_argument('--exclude-path', nargs='+') | 153 | part.add_argument('--exclude-path', nargs='+') |
154 | part.add_argument('--include-path', nargs='+') | 154 | part.add_argument('--include-path', nargs='+') |
155 | part.add_argument('--change-directory') | ||
155 | part.add_argument("--extra-space", type=sizetype("M")) | 156 | part.add_argument("--extra-space", type=sizetype("M")) |
156 | part.add_argument('--fsoptions', dest='fsopts') | 157 | part.add_argument('--fsoptions', dest='fsopts') |
157 | part.add_argument('--fstype', default='vfat', | 158 | part.add_argument('--fstype', default='vfat', |
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py index cc0382ce54..286c7867cb 100644 --- a/scripts/lib/wic/partition.py +++ b/scripts/lib/wic/partition.py | |||
@@ -31,6 +31,7 @@ class Partition(): | |||
31 | self.extra_space = args.extra_space | 31 | self.extra_space = args.extra_space |
32 | self.exclude_path = args.exclude_path | 32 | self.exclude_path = args.exclude_path |
33 | self.include_path = args.include_path | 33 | self.include_path = args.include_path |
34 | self.change_directory = args.change_directory | ||
34 | self.fsopts = args.fsopts | 35 | self.fsopts = args.fsopts |
35 | self.fstype = args.fstype | 36 | self.fstype = args.fstype |
36 | self.label = args.label | 37 | self.label = args.label |
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py index c96c539d03..ff1313717e 100644 --- a/scripts/lib/wic/plugins/source/rootfs.py +++ b/scripts/lib/wic/plugins/source/rootfs.py | |||
@@ -86,14 +86,29 @@ class RootfsPlugin(SourcePlugin): | |||
86 | new_rootfs = None | 86 | new_rootfs = None |
87 | new_pseudo = None | 87 | new_pseudo = None |
88 | # Handle excluded paths. | 88 | # Handle excluded paths. |
89 | if part.exclude_path or part.include_path: | 89 | if part.exclude_path or part.include_path or part.change_directory: |
90 | # 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 |
91 | # workdir. | 91 | # workdir. |
92 | new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno)) | 92 | new_rootfs = os.path.realpath(os.path.join(cr_workdir, "rootfs%d" % part.lineno)) |
93 | 93 | ||
94 | if os.path.lexists(new_rootfs): | 94 | if os.path.lexists(new_rootfs): |
95 | shutil.rmtree(os.path.join(new_rootfs)) | 95 | shutil.rmtree(os.path.join(new_rootfs)) |
96 | copyhardlinktree(part.rootfs_dir, new_rootfs) | 96 | |
97 | if part.change_directory: | ||
98 | cd = part.change_directory | ||
99 | if cd[-1] == '/': | ||
100 | cd = cd[:-1] | ||
101 | if os.path.isabs(cd): | ||
102 | logger.error("Must be relative: --change-directory=%s" % cd) | ||
103 | sys.exit(1) | ||
104 | orig_dir = os.path.realpath(os.path.join(part.rootfs_dir, cd)) | ||
105 | if not orig_dir.startswith(part.rootfs_dir): | ||
106 | logger.error("'%s' points to a path outside the rootfs" % orig_dir) | ||
107 | sys.exit(1) | ||
108 | |||
109 | else: | ||
110 | orig_dir = part.rootfs_dir | ||
111 | copyhardlinktree(orig_dir, new_rootfs) | ||
97 | 112 | ||
98 | # Convert the pseudo directory to its new location | 113 | # Convert the pseudo directory to its new location |
99 | if (pseudo_dir): | 114 | if (pseudo_dir): |
@@ -108,7 +123,7 @@ class RootfsPlugin(SourcePlugin): | |||
108 | pseudo_cmd = "%s -B -m %s -M %s" % (cls.__get_pseudo(native_sysroot, | 123 | pseudo_cmd = "%s -B -m %s -M %s" % (cls.__get_pseudo(native_sysroot, |
109 | new_rootfs, | 124 | new_rootfs, |
110 | new_pseudo), | 125 | new_pseudo), |
111 | part.rootfs_dir, new_rootfs) | 126 | orig_dir, new_rootfs) |
112 | exec_native_cmd(pseudo_cmd, native_sysroot) | 127 | exec_native_cmd(pseudo_cmd, native_sysroot) |
113 | 128 | ||
114 | for path in part.include_path or []: | 129 | for path in part.include_path or []: |