summaryrefslogtreecommitdiffstats
path: root/scripts/wic
diff options
context:
space:
mode:
authorJoão Henrique Ferreira de Freitas <joaohf@gmail.com>2014-03-29 00:12:08 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-30 10:10:35 +0100
commitba65fe654a66102e84582886cb0cc19889f5d3dd (patch)
treeb9ad9aa0452bee7a93d0ebc5227a9700b70e57bb /scripts/wic
parent3c0038488491374e745ebcfbd091c3f28cc8c089 (diff)
downloadpoky-ba65fe654a66102e84582886cb0cc19889f5d3dd.tar.gz
wic: Extend --rootfs-dir to connect rootfs-dirs
The wic command-line param --rootfs-dir gets generalized to support multiple directories. Each '--rootfs-dir' could be connected using a special string, that should be present in .wks. I.e: wic create ... --rootfs-dir rootfs1=/some/rootfs/dir \ --rootfs-dir rootfs2=/some/other/rootfs/dir part / --source rootfs --rootfs-dir="rootfs1" --ondisk sda --fstype=ext3 \ --label primary --align 1024 part /standby --source rootfs --rootfs-dir="rootfs2" \ --ondisk sda --fstype=ext3 --label secondary --align 1024 The user could use harded-code directory instead of connectors. Like this: wic create ... hard-coded-path.wks -r /some/rootfs/dir part / --source rootfs --ondisk sda --fstype=ext3 --label primary --align 1024 part /standby --source rootfs --rootfs-dir=/some/rootfs/dir \ --ondisk sda --fstype=ext3 --label secondary --align 1024 (From OE-Core rev: 719d093c40e4c259a4c97d6c8a5efb5aeef5fd38) Signed-off-by: João Henrique Ferreira de Freitas <joaohf@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/wic')
-rwxr-xr-xscripts/wic40
1 files changed, 37 insertions, 3 deletions
diff --git a/scripts/wic b/scripts/wic
index 824acaebd3..442334030f 100755
--- a/scripts/wic
+++ b/scripts/wic
@@ -45,6 +45,30 @@ sys.path = sys.path + [lib_path]
45from image.help import * 45from image.help import *
46from image.engine import * 46from image.engine import *
47 47
48def rootfs_dir_to_args(krootfs_dir):
49 """
50 Get a rootfs_dir dict and serialize to string
51 """
52 rootfs_dir = ''
53 for k, v in krootfs_dir.items():
54 rootfs_dir += ' '
55 rootfs_dir += '='.join([k, v])
56 return rootfs_dir.strip()
57
58def callback_rootfs_dir(option, opt, value, parser):
59 """
60 Build a dict using --rootfs_dir connection=dir
61 """
62 if not type(parser.values.rootfs_dir) is dict:
63 parser.values.rootfs_dir = dict()
64
65 if '=' in value:
66 (key, rootfs_dir) = value.split('=')
67 else:
68 key = 'ROOTFS_DIR'
69 rootfs_dir = value
70
71 parser.values.rootfs_dir[key] = rootfs_dir
48 72
49def wic_create_subcommand(args, usage_str): 73def wic_create_subcommand(args, usage_str):
50 """ 74 """
@@ -60,7 +84,8 @@ def wic_create_subcommand(args, usage_str):
60 parser.add_option("-e", "--image-name", dest = "image_name", 84 parser.add_option("-e", "--image-name", dest = "image_name",
61 action = "store", help = "name of the image to use the artifacts from e.g. core-image-sato") 85 action = "store", help = "name of the image to use the artifacts from e.g. core-image-sato")
62 parser.add_option("-r", "--rootfs-dir", dest = "rootfs_dir", 86 parser.add_option("-r", "--rootfs-dir", dest = "rootfs_dir",
63 action = "store", help = "path to the /rootfs dir to use as the .wks rootfs source") 87 action = "callback", callback = callback_rootfs_dir, type = "string",
88 help = "path to the /rootfs dir to use as the .wks rootfs source")
64 parser.add_option("-b", "--bootimg-dir", dest = "bootimg_dir", 89 parser.add_option("-b", "--bootimg-dir", dest = "bootimg_dir",
65 action = "store", help = "path to the dir containing the boot artifacts (e.g. /EFI or /syslinux dirs) to use as the .wks bootimg source") 90 action = "store", help = "path to the dir containing the boot artifacts (e.g. /EFI or /syslinux dirs) to use as the .wks bootimg source")
66 parser.add_option("-k", "--kernel-dir", dest = "kernel_dir", 91 parser.add_option("-k", "--kernel-dir", dest = "kernel_dir",
@@ -125,11 +150,13 @@ def wic_create_subcommand(args, usage_str):
125 image_output_dir = options.outdir 150 image_output_dir = options.outdir
126 151
127 if not options.image_name: 152 if not options.image_name:
128 rootfs_dir = options.rootfs_dir 153 rootfs_dir = ''
154 if 'ROOTFS_DIR' in options.rootfs_dir:
155 rootfs_dir = options.rootfs_dir['ROOTFS_DIR']
129 bootimg_dir = options.bootimg_dir 156 bootimg_dir = options.bootimg_dir
130 kernel_dir = options.kernel_dir 157 kernel_dir = options.kernel_dir
131 native_sysroot = options.native_sysroot 158 native_sysroot = options.native_sysroot
132 if not os.path.isdir(rootfs_dir): 159 if rootfs_dir and not os.path.isdir(rootfs_dir):
133 print "--roofs-dir (-r) not found, exiting\n" 160 print "--roofs-dir (-r) not found, exiting\n"
134 sys.exit(1) 161 sys.exit(1)
135 if not os.path.isdir(bootimg_dir): 162 if not os.path.isdir(bootimg_dir):
@@ -162,6 +189,13 @@ def wic_create_subcommand(args, usage_str):
162 (not_found, not_found_dir) 189 (not_found, not_found_dir)
163 sys.exit(1) 190 sys.exit(1)
164 191
192 krootfs_dir = options.rootfs_dir
193 if krootfs_dir is None:
194 krootfs_dir = {}
195 krootfs_dir['ROOTFS_DIR'] = rootfs_dir
196
197 rootfs_dir = rootfs_dir_to_args(krootfs_dir)
198
165 wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir, 199 wic_create(args, wks_file, rootfs_dir, bootimg_dir, kernel_dir,
166 native_sysroot, hdddir, staging_data_dir, scripts_path, 200 native_sysroot, hdddir, staging_data_dir, scripts_path,
167 image_output_dir, options.debug, options.properties_file) 201 image_output_dir, options.debug, options.properties_file)