diff options
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r-- | scripts/lib/wic/conf.py | 4 | ||||
-rw-r--r-- | scripts/lib/wic/engine.py | 62 | ||||
-rw-r--r-- | scripts/lib/wic/imager/direct.py | 70 | ||||
-rw-r--r-- | scripts/lib/wic/kickstart/__init__.py | 66 | ||||
-rw-r--r-- | scripts/lib/wic/kickstart/custom_commands/partition.py | 72 | ||||
-rw-r--r-- | scripts/lib/wic/kickstart/custom_commands/wicboot.py | 12 | ||||
-rw-r--r-- | scripts/lib/wic/msger.py | 13 | ||||
-rw-r--r-- | scripts/lib/wic/plugin.py | 4 | ||||
-rw-r--r-- | scripts/lib/wic/pluginbase.py | 14 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/imager/direct_plugin.py | 4 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-efi.py | 26 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-pcbios.py | 28 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/isoimage-isohybrid.py | 32 | ||||
-rw-r--r-- | scripts/lib/wic/utils/partitionedfs.py | 154 | ||||
-rw-r--r-- | scripts/lib/wic/utils/runner.py | 16 |
15 files changed, 287 insertions, 290 deletions
diff --git a/scripts/lib/wic/conf.py b/scripts/lib/wic/conf.py index 942c0c106f..1d4363a526 100644 --- a/scripts/lib/wic/conf.py +++ b/scripts/lib/wic/conf.py | |||
@@ -87,9 +87,9 @@ class ConfigMgr(object): | |||
87 | if not ksconf: | 87 | if not ksconf: |
88 | return | 88 | return |
89 | 89 | ||
90 | ks = kickstart.read_kickstart(ksconf) | 90 | ksobj = kickstart.read_kickstart(ksconf) |
91 | 91 | ||
92 | self.create['ks'] = ks | 92 | self.create['ks'] = ksobj |
93 | self.create['name'] = os.path.splitext(os.path.basename(ksconf))[0] | 93 | self.create['name'] = os.path.splitext(os.path.basename(ksconf))[0] |
94 | 94 | ||
95 | self.create['name'] = misc.build_name(ksconf, | 95 | self.create['name'] = misc.build_name(ksconf, |
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index ce942ea4c4..76b93e82f2 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py | |||
@@ -53,17 +53,17 @@ def verify_build_env(): | |||
53 | CANNED_IMAGE_DIR = "lib/wic/canned-wks" # relative to scripts | 53 | CANNED_IMAGE_DIR = "lib/wic/canned-wks" # relative to scripts |
54 | SCRIPTS_CANNED_IMAGE_DIR = "scripts/" + CANNED_IMAGE_DIR | 54 | SCRIPTS_CANNED_IMAGE_DIR = "scripts/" + CANNED_IMAGE_DIR |
55 | 55 | ||
56 | def build_canned_image_list(dl): | 56 | def build_canned_image_list(path): |
57 | layers_path = misc.get_bitbake_var("BBLAYERS") | 57 | layers_path = misc.get_bitbake_var("BBLAYERS") |
58 | canned_wks_layer_dirs = [] | 58 | canned_wks_layer_dirs = [] |
59 | 59 | ||
60 | if layers_path is not None: | 60 | if layers_path is not None: |
61 | for layer_path in layers_path.split(): | 61 | for layer_path in layers_path.split(): |
62 | path = os.path.join(layer_path, SCRIPTS_CANNED_IMAGE_DIR) | 62 | cpath = os.path.join(layer_path, SCRIPTS_CANNED_IMAGE_DIR) |
63 | canned_wks_layer_dirs.append(path) | 63 | canned_wks_layer_dirs.append(cpath) |
64 | 64 | ||
65 | path = os.path.join(dl, CANNED_IMAGE_DIR) | 65 | cpath = os.path.join(path, CANNED_IMAGE_DIR) |
66 | canned_wks_layer_dirs.append(path) | 66 | canned_wks_layer_dirs.append(cpath) |
67 | 67 | ||
68 | return canned_wks_layer_dirs | 68 | return canned_wks_layer_dirs |
69 | 69 | ||
@@ -99,14 +99,13 @@ def list_canned_images(scripts_path): | |||
99 | continue | 99 | continue |
100 | if fname.endswith(".wks"): | 100 | if fname.endswith(".wks"): |
101 | fullpath = os.path.join(canned_wks_dir, fname) | 101 | fullpath = os.path.join(canned_wks_dir, fname) |
102 | f = open(fullpath, "r") | 102 | with open(fullpath) as wks: |
103 | lines = f.readlines() | 103 | for line in wks: |
104 | for line in lines: | 104 | desc = "" |
105 | desc = "" | 105 | idx = line.find("short-description:") |
106 | idx = line.find("short-description:") | 106 | if idx != -1: |
107 | if idx != -1: | 107 | desc = line[idx + len("short-description:"):].strip() |
108 | desc = line[idx + len("short-description:"):].strip() | 108 | break |
109 | break | ||
110 | basename = os.path.splitext(fname)[0] | 109 | basename = os.path.splitext(fname)[0] |
111 | print " %s\t\t%s" % (basename.ljust(30), desc) | 110 | print " %s\t\t%s" % (basename.ljust(30), desc) |
112 | 111 | ||
@@ -115,24 +114,23 @@ def list_canned_image_help(scripts_path, fullpath): | |||
115 | """ | 114 | """ |
116 | List the help and params in the specified canned image. | 115 | List the help and params in the specified canned image. |
117 | """ | 116 | """ |
118 | f = open(fullpath, "r") | ||
119 | lines = f.readlines() | ||
120 | found = False | 117 | found = False |
121 | for line in lines: | 118 | with open(fullpath) as wks: |
122 | if not found: | 119 | for line in wks: |
123 | idx = line.find("long-description:") | 120 | if not found: |
121 | idx = line.find("long-description:") | ||
122 | if idx != -1: | ||
123 | |||
124 | print line[idx + len("long-description:"):].strip() | ||
125 | found = True | ||
126 | continue | ||
127 | if not line.strip(): | ||
128 | break | ||
129 | idx = line.find("#") | ||
124 | if idx != -1: | 130 | if idx != -1: |
125 | 131 | print line[idx + len("#:"):].rstrip() | |
126 | print line[idx + len("long-description:"):].strip() | 132 | else: |
127 | found = True | 133 | break |
128 | continue | ||
129 | if not line.strip(): | ||
130 | break | ||
131 | idx = line.find("#") | ||
132 | if idx != -1: | ||
133 | print line[idx + len("#:"):].rstrip() | ||
134 | else: | ||
135 | break | ||
136 | 134 | ||
137 | 135 | ||
138 | def list_source_plugins(): | 136 | def list_source_plugins(): |
@@ -186,10 +184,10 @@ def wic_create(wks_file, rootfs_dir, bootimg_dir, kernel_dir, | |||
186 | if debug: | 184 | if debug: |
187 | msger.set_loglevel('debug') | 185 | msger.set_loglevel('debug') |
188 | 186 | ||
189 | cr = creator.Creator() | 187 | crobj = creator.Creator() |
190 | 188 | ||
191 | cr.main(["direct", native_sysroot, kernel_dir, bootimg_dir, rootfs_dir, | 189 | crobj.main(["direct", native_sysroot, kernel_dir, bootimg_dir, rootfs_dir, |
192 | wks_file, image_output_dir, oe_builddir, compressor or ""]) | 190 | wks_file, image_output_dir, oe_builddir, compressor or ""]) |
193 | 191 | ||
194 | print "\nThe image(s) were created using OE kickstart file:\n %s" % wks_file | 192 | print "\nThe image(s) were created using OE kickstart file:\n %s" % wks_file |
195 | 193 | ||
diff --git a/scripts/lib/wic/imager/direct.py b/scripts/lib/wic/imager/direct.py index 761e436db5..31c0edc7d3 100644 --- a/scripts/lib/wic/imager/direct.py +++ b/scripts/lib/wic/imager/direct.py | |||
@@ -80,11 +80,11 @@ class DirectImageCreator(BaseImageCreator): | |||
80 | in the partition table and logical partitions | 80 | in the partition table and logical partitions |
81 | """ | 81 | """ |
82 | realnum = 0 | 82 | realnum = 0 |
83 | for n, p in enumerate(parts, 1): | 83 | for pnum, part in enumerate(parts, 1): |
84 | if not p.no_table: | 84 | if not part.no_table: |
85 | realnum += 1 | 85 | realnum += 1 |
86 | if n == num: | 86 | if pnum == num: |
87 | if p.no_table: | 87 | if part.no_table: |
88 | return 0 | 88 | return 0 |
89 | if self.ptable_format == 'msdos' and realnum > 3: | 89 | if self.ptable_format == 'msdos' and realnum > 3: |
90 | # account for logical partition numbering, ex. sda5.. | 90 | # account for logical partition numbering, ex. sda5.. |
@@ -154,9 +154,9 @@ class DirectImageCreator(BaseImageCreator): | |||
154 | if not self.ks.handler.partition.partitions: | 154 | if not self.ks.handler.partition.partitions: |
155 | partstr = "part / --size 1900 --ondisk sda --fstype=ext3" | 155 | partstr = "part / --size 1900 --ondisk sda --fstype=ext3" |
156 | args = partstr.split() | 156 | args = partstr.split() |
157 | pd = self.ks.handler.partition.parse(args[1:]) | 157 | part = self.ks.handler.partition.parse(args[1:]) |
158 | if pd not in self.ks.handler.partition.partitions: | 158 | if part not in self.ks.handler.partition.partitions: |
159 | self.ks.handler.partition.partitions.append(pd) | 159 | self.ks.handler.partition.partitions.append(part) |
160 | 160 | ||
161 | # partitions list from kickstart file | 161 | # partitions list from kickstart file |
162 | return kickstart.get_partitions(self.ks) | 162 | return kickstart.get_partitions(self.ks) |
@@ -221,19 +221,19 @@ class DirectImageCreator(BaseImageCreator): | |||
221 | 221 | ||
222 | self.__image = Image(self.native_sysroot) | 222 | self.__image = Image(self.native_sysroot) |
223 | 223 | ||
224 | for p in parts: | 224 | for part in parts: |
225 | # as a convenience, set source to the boot partition source | 225 | # as a convenience, set source to the boot partition source |
226 | # instead of forcing it to be set via bootloader --source | 226 | # instead of forcing it to be set via bootloader --source |
227 | if not self.ks.handler.bootloader.source and p.mountpoint == "/boot": | 227 | if not self.ks.handler.bootloader.source and part.mountpoint == "/boot": |
228 | self.ks.handler.bootloader.source = p.source | 228 | self.ks.handler.bootloader.source = part.source |
229 | 229 | ||
230 | fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) | 230 | fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) |
231 | 231 | ||
232 | for p in parts: | 232 | for part in parts: |
233 | # get rootfs size from bitbake variable if it's not set in .ks file | 233 | # get rootfs size from bitbake variable if it's not set in .ks file |
234 | if not p.size: | 234 | if not part.size: |
235 | # and if rootfs name is specified for the partition | 235 | # and if rootfs name is specified for the partition |
236 | image_name = p.get_rootfs() | 236 | image_name = part.get_rootfs() |
237 | if image_name: | 237 | if image_name: |
238 | # Bitbake variable ROOTFS_SIZE is calculated in | 238 | # Bitbake variable ROOTFS_SIZE is calculated in |
239 | # Image._get_rootfs_size method from meta/lib/oe/image.py | 239 | # Image._get_rootfs_size method from meta/lib/oe/image.py |
@@ -242,7 +242,7 @@ class DirectImageCreator(BaseImageCreator): | |||
242 | rsize_bb = get_bitbake_var('ROOTFS_SIZE', image_name) | 242 | rsize_bb = get_bitbake_var('ROOTFS_SIZE', image_name) |
243 | if rsize_bb: | 243 | if rsize_bb: |
244 | # convert from Kb to Mb | 244 | # convert from Kb to Mb |
245 | p.size = int(rsize_bb) / 1024 | 245 | part.size = int(rsize_bb) / 1024 |
246 | # need to create the filesystems in order to get their | 246 | # need to create the filesystems in order to get their |
247 | # sizes before we can add them and do the layout. | 247 | # sizes before we can add them and do the layout. |
248 | # Image.create() actually calls __format_disks() to create | 248 | # Image.create() actually calls __format_disks() to create |
@@ -250,22 +250,22 @@ class DirectImageCreator(BaseImageCreator): | |||
250 | # self.assemble() calls Image.assemble() which calls | 250 | # self.assemble() calls Image.assemble() which calls |
251 | # __write_partitition() for each partition to dd the fs | 251 | # __write_partitition() for each partition to dd the fs |
252 | # into the partitions. | 252 | # into the partitions. |
253 | p.prepare(self, self.workdir, self.oe_builddir, self.rootfs_dir, | 253 | part.prepare(self, self.workdir, self.oe_builddir, self.rootfs_dir, |
254 | self.bootimg_dir, self.kernel_dir, self.native_sysroot) | 254 | self.bootimg_dir, self.kernel_dir, self.native_sysroot) |
255 | 255 | ||
256 | 256 | ||
257 | self.__image.add_partition(int(p.size), | 257 | self.__image.add_partition(int(part.size), |
258 | p.disk, | 258 | part.disk, |
259 | p.mountpoint, | 259 | part.mountpoint, |
260 | p.source_file, | 260 | part.source_file, |
261 | p.fstype, | 261 | part.fstype, |
262 | p.label, | 262 | part.label, |
263 | fsopts=p.fsopts, | 263 | fsopts=part.fsopts, |
264 | boot=p.active, | 264 | boot=part.active, |
265 | align=p.align, | 265 | align=part.align, |
266 | no_table=p.no_table, | 266 | no_table=part.no_table, |
267 | part_type=p.part_type, | 267 | part_type=part.part_type, |
268 | uuid=p.uuid) | 268 | uuid=part.uuid) |
269 | 269 | ||
270 | if fstab_path: | 270 | if fstab_path: |
271 | shutil.move(fstab_path + ".orig", fstab_path) | 271 | shutil.move(fstab_path + ".orig", fstab_path) |
@@ -336,14 +336,14 @@ class DirectImageCreator(BaseImageCreator): | |||
336 | msg += ' %s\n\n' % full_path | 336 | msg += ' %s\n\n' % full_path |
337 | 337 | ||
338 | msg += 'The following build artifacts were used to create the image(s):\n' | 338 | msg += 'The following build artifacts were used to create the image(s):\n' |
339 | for p in parts: | 339 | for part in parts: |
340 | if p.get_rootfs() is None: | 340 | if part.get_rootfs() is None: |
341 | continue | 341 | continue |
342 | if p.mountpoint == '/': | 342 | if part.mountpoint == '/': |
343 | suffix = ':' | 343 | suffix = ':' |
344 | else: | 344 | else: |
345 | suffix = '["%s"]:' % (p.mountpoint or p.label) | 345 | suffix = '["%s"]:' % (part.mountpoint or part.label) |
346 | msg += ' ROOTFS_DIR%s%s\n' % (suffix.ljust(20), p.get_rootfs()) | 346 | msg += ' ROOTFS_DIR%s%s\n' % (suffix.ljust(20), part.get_rootfs()) |
347 | 347 | ||
348 | msg += ' BOOTIMG_DIR: %s\n' % self.bootimg_dir | 348 | msg += ' BOOTIMG_DIR: %s\n' % self.bootimg_dir |
349 | msg += ' KERNEL_DIR: %s\n' % self.kernel_dir | 349 | msg += ' KERNEL_DIR: %s\n' % self.kernel_dir |
diff --git a/scripts/lib/wic/kickstart/__init__.py b/scripts/lib/wic/kickstart/__init__.py index 111723b133..c9b0e51f3c 100644 --- a/scripts/lib/wic/kickstart/__init__.py +++ b/scripts/lib/wic/kickstart/__init__.py | |||
@@ -58,65 +58,65 @@ def read_kickstart(path): | |||
58 | def __init__(self): | 58 | def __init__(self): |
59 | superclass.__init__(self, mapping=commandMap[using_version]) | 59 | superclass.__init__(self, mapping=commandMap[using_version]) |
60 | 60 | ||
61 | ks = ksparser.KickstartParser(KSHandlers(), errorsAreFatal=True) | 61 | kickstart = ksparser.KickstartParser(KSHandlers(), errorsAreFatal=True) |
62 | 62 | ||
63 | try: | 63 | try: |
64 | ks.readKickstart(path) | 64 | kickstart.readKickstart(path) |
65 | except (kserrors.KickstartParseError, kserrors.KickstartError), err: | 65 | except (kserrors.KickstartParseError, kserrors.KickstartError), err: |
66 | msger.warning("Errors occurred when parsing kickstart file: %s\n" % path) | 66 | msger.warning("Errors occurred when parsing kickstart file: %s\n" % path) |
67 | msger.error("%s" % err) | 67 | msger.error("%s" % err) |
68 | 68 | ||
69 | return ks | 69 | return kickstart |
70 | 70 | ||
71 | def get_image_size(ks, default=None): | 71 | def get_image_size(kickstart, default=None): |
72 | __size = 0 | 72 | __size = 0 |
73 | for p in ks.handler.partition.partitions: | 73 | for part in kickstart.handler.partition.partitions: |
74 | if p.mountpoint == "/" and p.size: | 74 | if part.mountpoint == "/" and part.size: |
75 | __size = p.size | 75 | __size = part.size |
76 | if __size > 0: | 76 | if __size > 0: |
77 | return int(__size) * 1024L | 77 | return int(__size) * 1024L |
78 | else: | 78 | else: |
79 | return default | 79 | return default |
80 | 80 | ||
81 | def get_image_fstype(ks, default=None): | 81 | def get_image_fstype(kickstart, default=None): |
82 | for p in ks.handler.partition.partitions: | 82 | for part in kickstart.handler.partition.partitions: |
83 | if p.mountpoint == "/" and p.fstype: | 83 | if part.mountpoint == "/" and part.fstype: |
84 | return p.fstype | 84 | return part.fstype |
85 | return default | 85 | return default |
86 | 86 | ||
87 | def get_image_fsopts(ks, default=None): | 87 | def get_image_fsopts(kickstart, default=None): |
88 | for p in ks.handler.partition.partitions: | 88 | for part in kickstart.handler.partition.partitions: |
89 | if p.mountpoint == "/" and p.fsopts: | 89 | if part.mountpoint == "/" and part.fsopts: |
90 | return p.fsopts | 90 | return part.fsopts |
91 | return default | 91 | return default |
92 | 92 | ||
93 | def get_timeout(ks, default=None): | 93 | def get_timeout(kickstart, default=None): |
94 | if not hasattr(ks.handler.bootloader, "timeout"): | 94 | if not hasattr(kickstart.handler.bootloader, "timeout"): |
95 | return default | 95 | return default |
96 | if ks.handler.bootloader.timeout is None: | 96 | if kickstart.handler.bootloader.timeout is None: |
97 | return default | 97 | return default |
98 | return int(ks.handler.bootloader.timeout) | 98 | return int(kickstart.handler.bootloader.timeout) |
99 | 99 | ||
100 | def get_kernel_args(ks, default="ro rd.live.image"): | 100 | def get_kernel_args(kickstart, default="ro rd.live.image"): |
101 | if not hasattr(ks.handler.bootloader, "appendLine"): | 101 | if not hasattr(kickstart.handler.bootloader, "appendLine"): |
102 | return default | 102 | return default |
103 | if ks.handler.bootloader.appendLine is None: | 103 | if kickstart.handler.bootloader.appendLine is None: |
104 | return default | 104 | return default |
105 | return "%s %s" %(default, ks.handler.bootloader.appendLine) | 105 | return "%s %s" %(default, kickstart.handler.bootloader.appendLine) |
106 | 106 | ||
107 | def get_menu_args(ks, default=""): | 107 | def get_menu_args(kickstart, default=""): |
108 | if not hasattr(ks.handler.bootloader, "menus"): | 108 | if not hasattr(kickstart.handler.bootloader, "menus"): |
109 | return default | 109 | return default |
110 | if ks.handler.bootloader.menus in (None, ""): | 110 | if kickstart.handler.bootloader.menus in (None, ""): |
111 | return default | 111 | return default |
112 | return "%s" % ks.handler.bootloader.menus | 112 | return "%s" % kickstart.handler.bootloader.menus |
113 | 113 | ||
114 | def get_default_kernel(ks, default=None): | 114 | def get_default_kernel(kickstart, default=None): |
115 | if not hasattr(ks.handler.bootloader, "default"): | 115 | if not hasattr(kickstart.handler.bootloader, "default"): |
116 | return default | 116 | return default |
117 | if not ks.handler.bootloader.default: | 117 | if not kickstart.handler.bootloader.default: |
118 | return default | 118 | return default |
119 | return ks.handler.bootloader.default | 119 | return kickstart.handler.bootloader.default |
120 | 120 | ||
121 | def get_partitions(ks): | 121 | def get_partitions(kickstart): |
122 | return ks.handler.partition.partitions | 122 | return kickstart.handler.partition.partitions |
diff --git a/scripts/lib/wic/kickstart/custom_commands/partition.py b/scripts/lib/wic/kickstart/custom_commands/partition.py index bac2067a5a..eee25a493d 100644 --- a/scripts/lib/wic/kickstart/custom_commands/partition.py +++ b/scripts/lib/wic/kickstart/custom_commands/partition.py | |||
@@ -154,7 +154,7 @@ class Wic_PartData(FC4_PartData): | |||
154 | else: | 154 | else: |
155 | return 0 | 155 | return 0 |
156 | 156 | ||
157 | def prepare(self, cr, cr_workdir, oe_builddir, rootfs_dir, bootimg_dir, | 157 | def prepare(self, creator, cr_workdir, oe_builddir, rootfs_dir, bootimg_dir, |
158 | kernel_dir, native_sysroot): | 158 | kernel_dir, native_sysroot): |
159 | """ | 159 | """ |
160 | Prepare content for individual partitions, depending on | 160 | Prepare content for individual partitions, depending on |
@@ -199,18 +199,18 @@ class Wic_PartData(FC4_PartData): | |||
199 | self._source_methods = pluginmgr.get_source_plugin_methods(\ | 199 | self._source_methods = pluginmgr.get_source_plugin_methods(\ |
200 | self.source, partition_methods) | 200 | self.source, partition_methods) |
201 | self._source_methods["do_configure_partition"](self, self.sourceparams_dict, | 201 | self._source_methods["do_configure_partition"](self, self.sourceparams_dict, |
202 | cr, cr_workdir, | 202 | creator, cr_workdir, |
203 | oe_builddir, | 203 | oe_builddir, |
204 | bootimg_dir, | 204 | bootimg_dir, |
205 | kernel_dir, | 205 | kernel_dir, |
206 | native_sysroot) | 206 | native_sysroot) |
207 | self._source_methods["do_stage_partition"](self, self.sourceparams_dict, | 207 | self._source_methods["do_stage_partition"](self, self.sourceparams_dict, |
208 | cr, cr_workdir, | 208 | creator, cr_workdir, |
209 | oe_builddir, | 209 | oe_builddir, |
210 | bootimg_dir, kernel_dir, | 210 | bootimg_dir, kernel_dir, |
211 | native_sysroot) | 211 | native_sysroot) |
212 | self._source_methods["do_prepare_partition"](self, self.sourceparams_dict, | 212 | self._source_methods["do_prepare_partition"](self, self.sourceparams_dict, |
213 | cr, cr_workdir, | 213 | creator, cr_workdir, |
214 | oe_builddir, | 214 | oe_builddir, |
215 | bootimg_dir, kernel_dir, rootfs_dir, | 215 | bootimg_dir, kernel_dir, rootfs_dir, |
216 | native_sysroot) | 216 | native_sysroot) |
@@ -441,21 +441,21 @@ class Wic_PartData(FC4_PartData): | |||
441 | msger.warning("Creating of an empty squashfs %s partition was attempted. " \ | 441 | msger.warning("Creating of an empty squashfs %s partition was attempted. " \ |
442 | "Proceeding as requested." % self.mountpoint) | 442 | "Proceeding as requested." % self.mountpoint) |
443 | 443 | ||
444 | fs = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) | 444 | path = "%s/fs_%s.%s" % (cr_workdir, self.label, self.fstype) |
445 | os.path.isfile(fs) and os.remove(fs) | 445 | os.path.isfile(path) and os.remove(path) |
446 | 446 | ||
447 | # it is not possible to create a squashfs without source data, | 447 | # it is not possible to create a squashfs without source data, |
448 | # thus prepare an empty temp dir that is used as source | 448 | # thus prepare an empty temp dir that is used as source |
449 | tmpdir = tempfile.mkdtemp() | 449 | tmpdir = tempfile.mkdtemp() |
450 | 450 | ||
451 | squashfs_cmd = "mksquashfs %s %s -noappend" % \ | 451 | squashfs_cmd = "mksquashfs %s %s -noappend" % \ |
452 | (tmpdir, fs) | 452 | (tmpdir, path) |
453 | exec_native_cmd(squashfs_cmd, native_sysroot) | 453 | exec_native_cmd(squashfs_cmd, native_sysroot) |
454 | 454 | ||
455 | os.rmdir(tmpdir) | 455 | os.rmdir(tmpdir) |
456 | 456 | ||
457 | # get the rootfs size in the right units for kickstart (kB) | 457 | # get the rootfs size in the right units for kickstart (kB) |
458 | du_cmd = "du -Lbks %s" % fs | 458 | du_cmd = "du -Lbks %s" % path |
459 | out = exec_cmd(du_cmd) | 459 | out = exec_cmd(du_cmd) |
460 | fs_size = out.split()[0] | 460 | fs_size = out.split()[0] |
461 | 461 | ||
@@ -465,17 +465,17 @@ class Wic_PartData(FC4_PartData): | |||
465 | """ | 465 | """ |
466 | Prepare a swap partition. | 466 | Prepare a swap partition. |
467 | """ | 467 | """ |
468 | fs = "%s/fs.%s" % (cr_workdir, self.fstype) | 468 | path = "%s/fs.%s" % (cr_workdir, self.fstype) |
469 | 469 | ||
470 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ | 470 | dd_cmd = "dd if=/dev/zero of=%s bs=1k seek=%d count=0" % \ |
471 | (fs, self.size) | 471 | (path, self.size) |
472 | exec_cmd(dd_cmd) | 472 | exec_cmd(dd_cmd) |
473 | 473 | ||
474 | import uuid | 474 | import uuid |
475 | label_str = "" | 475 | label_str = "" |
476 | if self.label: | 476 | if self.label: |
477 | label_str = "-L %s" % self.label | 477 | label_str = "-L %s" % self.label |
478 | mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), fs) | 478 | mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path) |
479 | exec_native_cmd(mkswap_cmd, native_sysroot) | 479 | exec_native_cmd(mkswap_cmd, native_sysroot) |
480 | 480 | ||
481 | 481 | ||
@@ -490,37 +490,37 @@ class Wic_Partition(FC4_Partition): | |||
490 | (option, value)) | 490 | (option, value)) |
491 | setattr(parser.values, option.dest, value) | 491 | setattr(parser.values, option.dest, value) |
492 | 492 | ||
493 | op = FC4_Partition._getParser(self) | 493 | parser = FC4_Partition._getParser(self) |
494 | 494 | ||
495 | # The alignment value is given in kBytes. e.g., value 8 means that | 495 | # The alignment value is given in kBytes. e.g., value 8 means that |
496 | # the partition is aligned to start from 8096 byte boundary. | 496 | # the partition is aligned to start from 8096 byte boundary. |
497 | op.add_option("--align", type="int", action="store", dest="align", | 497 | parser.add_option("--align", type="int", action="store", dest="align", |
498 | default=None) | 498 | default=None) |
499 | op.add_option("--extoptions", type="string", action="store", dest="extopts", | 499 | parser.add_option("--extoptions", type="string", action="store", dest="extopts", |
500 | default=None) | 500 | default=None) |
501 | op.add_option("--part-type", type="string", action="store", dest="part_type", | 501 | parser.add_option("--part-type", type="string", action="store", dest="part_type", |
502 | default=None) | 502 | default=None) |
503 | # use specified source file to fill the partition | 503 | # use specified source file to fill the partition |
504 | # and calculate partition size | 504 | # and calculate partition size |
505 | op.add_option("--source", type="string", action="store", | 505 | parser.add_option("--source", type="string", action="store", |
506 | dest="source", default=None) | 506 | dest="source", default=None) |
507 | # comma-separated list of param=value pairs | 507 | # comma-separated list of param=value pairs |
508 | op.add_option("--sourceparams", type="string", action="store", | 508 | parser.add_option("--sourceparams", type="string", action="store", |
509 | dest="sourceparams", default=None) | 509 | dest="sourceparams", default=None) |
510 | # use specified rootfs path to fill the partition | 510 | # use specified rootfs path to fill the partition |
511 | op.add_option("--rootfs-dir", type="string", action="store", | 511 | parser.add_option("--rootfs-dir", type="string", action="store", |
512 | dest="rootfs", default=None) | 512 | dest="rootfs", default=None) |
513 | # wether to add the partition in the partition table | 513 | # wether to add the partition in the partition table |
514 | op.add_option("--no-table", dest="no_table", action="store_true", | 514 | parser.add_option("--no-table", dest="no_table", action="store_true", |
515 | default=False) | 515 | default=False) |
516 | # extra space beyond the partition size | 516 | # extra space beyond the partition size |
517 | op.add_option("--extra-space", dest="extra_space", action="store", | 517 | parser.add_option("--extra-space", dest="extra_space", action="store", |
518 | type="size", nargs=1, default="10M") | 518 | type="size", nargs=1, default="10M") |
519 | op.add_option("--overhead-factor", dest="overhead_factor", | 519 | parser.add_option("--overhead-factor", dest="overhead_factor", |
520 | action="callback", callback=overhead_cb, type="float", | 520 | action="callback", callback=overhead_cb, type="float", |
521 | nargs=1, default=1.3) | 521 | nargs=1, default=1.3) |
522 | op.add_option("--use-uuid", dest="use_uuid", action="store_true", | 522 | parser.add_option("--use-uuid", dest="use_uuid", action="store_true", |
523 | default=False) | 523 | default=False) |
524 | op.add_option("--uuid") | 524 | parser.add_option("--uuid") |
525 | 525 | ||
526 | return op | 526 | return parser |
diff --git a/scripts/lib/wic/kickstart/custom_commands/wicboot.py b/scripts/lib/wic/kickstart/custom_commands/wicboot.py index 0230df2f4b..a3e1852be2 100644 --- a/scripts/lib/wic/kickstart/custom_commands/wicboot.py +++ b/scripts/lib/wic/kickstart/custom_commands/wicboot.py | |||
@@ -49,12 +49,12 @@ class Wic_Bootloader(F8_Bootloader): | |||
49 | return retval | 49 | return retval |
50 | 50 | ||
51 | def _getParser(self): | 51 | def _getParser(self): |
52 | op = F8_Bootloader._getParser(self) | 52 | parser = F8_Bootloader._getParser(self) |
53 | op.add_option("--menus", dest="menus") | 53 | parser.add_option("--menus", dest="menus") |
54 | op.add_option("--ptable", dest="ptable", choices=("msdos", "gpt"), | 54 | parser.add_option("--ptable", dest="ptable", choices=("msdos", "gpt"), |
55 | default="msdos") | 55 | default="msdos") |
56 | # use specified source plugin to implement bootloader-specific methods | 56 | # use specified source plugin to implement bootloader-specific methods |
57 | op.add_option("--source", type="string", action="store", | 57 | parser.add_option("--source", type="string", action="store", |
58 | dest="source", default=None) | 58 | dest="source", default=None) |
59 | return op | 59 | return parser |
60 | 60 | ||
diff --git a/scripts/lib/wic/msger.py b/scripts/lib/wic/msger.py index 1b60980296..b737554228 100644 --- a/scripts/lib/wic/msger.py +++ b/scripts/lib/wic/msger.py | |||
@@ -151,10 +151,10 @@ def _split_msg(head, msg): | |||
151 | msg = msg.lstrip() | 151 | msg = msg.lstrip() |
152 | head = '\r' + head | 152 | head = '\r' + head |
153 | 153 | ||
154 | m = PREFIX_RE.match(msg) | 154 | match = PREFIX_RE.match(msg) |
155 | if m: | 155 | if match: |
156 | head += ' <%s>' % m.group(1) | 156 | head += ' <%s>' % match.group(1) |
157 | msg = m.group(2) | 157 | msg = match.group(2) |
158 | 158 | ||
159 | return head, msg | 159 | return head, msg |
160 | 160 | ||
@@ -271,9 +271,8 @@ def set_logfile(fpath): | |||
271 | 271 | ||
272 | def _savelogf(): | 272 | def _savelogf(): |
273 | if LOG_FILE_FP: | 273 | if LOG_FILE_FP: |
274 | fp = open(LOG_FILE_FP, 'w') | 274 | with open(LOG_FILE_FP, 'w') as log: |
275 | fp.write(LOG_CONTENT) | 275 | log.write(LOG_CONTENT) |
276 | fp.close() | ||
277 | 276 | ||
278 | if LOG_FILE_FP is not None: | 277 | if LOG_FILE_FP is not None: |
279 | warning('duplicate log file configuration') | 278 | warning('duplicate log file configuration') |
diff --git a/scripts/lib/wic/plugin.py b/scripts/lib/wic/plugin.py index 7244989d86..ccfdfcb934 100644 --- a/scripts/lib/wic/plugin.py +++ b/scripts/lib/wic/plugin.py | |||
@@ -48,7 +48,7 @@ class PluginMgr(object): | |||
48 | self.plugin_dir = scripts_path + PLUGIN_DIR | 48 | self.plugin_dir = scripts_path + PLUGIN_DIR |
49 | self.layers_path = None | 49 | self.layers_path = None |
50 | 50 | ||
51 | def _build_plugin_dir_list(self, dl, ptype): | 51 | def _build_plugin_dir_list(self, plugin_dir, ptype): |
52 | if self.layers_path is None: | 52 | if self.layers_path is None: |
53 | self.layers_path = get_bitbake_var("BBLAYERS") | 53 | self.layers_path = get_bitbake_var("BBLAYERS") |
54 | layer_dirs = [] | 54 | layer_dirs = [] |
@@ -58,7 +58,7 @@ class PluginMgr(object): | |||
58 | path = os.path.join(layer_path, SCRIPTS_PLUGIN_DIR, ptype) | 58 | path = os.path.join(layer_path, SCRIPTS_PLUGIN_DIR, ptype) |
59 | layer_dirs.append(path) | 59 | layer_dirs.append(path) |
60 | 60 | ||
61 | path = os.path.join(dl, ptype) | 61 | path = os.path.join(plugin_dir, ptype) |
62 | layer_dirs.append(path) | 62 | layer_dirs.append(path) |
63 | 63 | ||
64 | return layer_dirs | 64 | return layer_dirs |
diff --git a/scripts/lib/wic/pluginbase.py b/scripts/lib/wic/pluginbase.py index 6d96de2be5..ee8fe95c6f 100644 --- a/scripts/lib/wic/pluginbase.py +++ b/scripts/lib/wic/pluginbase.py | |||
@@ -51,7 +51,7 @@ class SourcePlugin(_Plugin): | |||
51 | """ | 51 | """ |
52 | 52 | ||
53 | @classmethod | 53 | @classmethod |
54 | def do_install_disk(cls, disk, disk_name, cr, workdir, oe_builddir, | 54 | def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, |
55 | bootimg_dir, kernel_dir, native_sysroot): | 55 | bootimg_dir, kernel_dir, native_sysroot): |
56 | """ | 56 | """ |
57 | Called after all partitions have been prepared and assembled into a | 57 | Called after all partitions have been prepared and assembled into a |
@@ -61,7 +61,7 @@ class SourcePlugin(_Plugin): | |||
61 | msger.debug("SourcePlugin: do_install_disk: disk: %s" % disk_name) | 61 | msger.debug("SourcePlugin: do_install_disk: disk: %s" % disk_name) |
62 | 62 | ||
63 | @classmethod | 63 | @classmethod |
64 | def do_stage_partition(cls, part, source_params, cr, cr_workdir, | 64 | def do_stage_partition(cls, part, source_params, creator, cr_workdir, |
65 | oe_builddir, bootimg_dir, kernel_dir, | 65 | oe_builddir, bootimg_dir, kernel_dir, |
66 | native_sysroot): | 66 | native_sysroot): |
67 | """ | 67 | """ |
@@ -78,7 +78,7 @@ class SourcePlugin(_Plugin): | |||
78 | msger.debug("SourcePlugin: do_stage_partition: part: %s" % part) | 78 | msger.debug("SourcePlugin: do_stage_partition: part: %s" % part) |
79 | 79 | ||
80 | @classmethod | 80 | @classmethod |
81 | def do_configure_partition(cls, part, source_params, cr, cr_workdir, | 81 | def do_configure_partition(cls, part, source_params, creator, cr_workdir, |
82 | oe_builddir, bootimg_dir, kernel_dir, | 82 | oe_builddir, bootimg_dir, kernel_dir, |
83 | native_sysroot): | 83 | native_sysroot): |
84 | """ | 84 | """ |
@@ -89,7 +89,7 @@ class SourcePlugin(_Plugin): | |||
89 | msger.debug("SourcePlugin: do_configure_partition: part: %s" % part) | 89 | msger.debug("SourcePlugin: do_configure_partition: part: %s" % part) |
90 | 90 | ||
91 | @classmethod | 91 | @classmethod |
92 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, | 92 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, |
93 | oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, | 93 | oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, |
94 | native_sysroot): | 94 | native_sysroot): |
95 | """ | 95 | """ |
@@ -99,9 +99,9 @@ class SourcePlugin(_Plugin): | |||
99 | msger.debug("SourcePlugin: do_prepare_partition: part: %s" % part) | 99 | msger.debug("SourcePlugin: do_prepare_partition: part: %s" % part) |
100 | 100 | ||
101 | def get_plugins(typen): | 101 | def get_plugins(typen): |
102 | ps = ImagerPlugin.get_plugins() | 102 | plugins = ImagerPlugin.get_plugins() |
103 | if typen in ps: | 103 | if typen in plugins: |
104 | return ps[typen] | 104 | return plugins[typen] |
105 | else: | 105 | else: |
106 | return None | 106 | return None |
107 | 107 | ||
diff --git a/scripts/lib/wic/plugins/imager/direct_plugin.py b/scripts/lib/wic/plugins/imager/direct_plugin.py index e9672fe274..6d3f46cc61 100644 --- a/scripts/lib/wic/plugins/imager/direct_plugin.py +++ b/scripts/lib/wic/plugins/imager/direct_plugin.py | |||
@@ -50,8 +50,8 @@ class DirectPlugin(ImagerPlugin): | |||
50 | """ | 50 | """ |
51 | krootfs_dir = {} | 51 | krootfs_dir = {} |
52 | for rootfs_dir in rootfs_dirs.split(' '): | 52 | for rootfs_dir in rootfs_dirs.split(' '): |
53 | k, v = rootfs_dir.split('=') | 53 | key, val = rootfs_dir.split('=') |
54 | krootfs_dir[k] = v | 54 | krootfs_dir[key] = val |
55 | 55 | ||
56 | return krootfs_dir | 56 | return krootfs_dir |
57 | 57 | ||
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index b48cc835d6..fa63c6abda 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py | |||
@@ -41,16 +41,16 @@ class BootimgEFIPlugin(SourcePlugin): | |||
41 | name = 'bootimg-efi' | 41 | name = 'bootimg-efi' |
42 | 42 | ||
43 | @classmethod | 43 | @classmethod |
44 | def do_configure_grubefi(cls, hdddir, cr, cr_workdir): | 44 | def do_configure_grubefi(cls, hdddir, creator, cr_workdir): |
45 | """ | 45 | """ |
46 | Create loader-specific (grub-efi) config | 46 | Create loader-specific (grub-efi) config |
47 | """ | 47 | """ |
48 | options = cr.ks.handler.bootloader.appendLine | 48 | options = creator.ks.handler.bootloader.appendLine |
49 | 49 | ||
50 | grubefi_conf = "" | 50 | grubefi_conf = "" |
51 | grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n" | 51 | grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n" |
52 | grubefi_conf += "default=boot\n" | 52 | grubefi_conf += "default=boot\n" |
53 | timeout = kickstart.get_timeout(cr.ks) | 53 | timeout = kickstart.get_timeout(creator.ks) |
54 | if not timeout: | 54 | if not timeout: |
55 | timeout = 0 | 55 | timeout = 0 |
56 | grubefi_conf += "timeout=%s\n" % timeout | 56 | grubefi_conf += "timeout=%s\n" % timeout |
@@ -59,7 +59,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
59 | kernel = "/bzImage" | 59 | kernel = "/bzImage" |
60 | 60 | ||
61 | grubefi_conf += "linux %s root=%s rootwait %s\n" \ | 61 | grubefi_conf += "linux %s root=%s rootwait %s\n" \ |
62 | % (kernel, cr.rootdev, options) | 62 | % (kernel, creator.rootdev, options) |
63 | grubefi_conf += "}\n" | 63 | grubefi_conf += "}\n" |
64 | 64 | ||
65 | msger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg" \ | 65 | msger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg" \ |
@@ -69,7 +69,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
69 | cfg.close() | 69 | cfg.close() |
70 | 70 | ||
71 | @classmethod | 71 | @classmethod |
72 | def do_configure_gummiboot(cls, hdddir, cr, cr_workdir): | 72 | def do_configure_gummiboot(cls, hdddir, creator, cr_workdir): |
73 | """ | 73 | """ |
74 | Create loader-specific (gummiboot) config | 74 | Create loader-specific (gummiboot) config |
75 | """ | 75 | """ |
@@ -79,9 +79,9 @@ class BootimgEFIPlugin(SourcePlugin): | |||
79 | install_cmd = "install -d %s/loader/entries" % hdddir | 79 | install_cmd = "install -d %s/loader/entries" % hdddir |
80 | exec_cmd(install_cmd) | 80 | exec_cmd(install_cmd) |
81 | 81 | ||
82 | options = cr.ks.handler.bootloader.appendLine | 82 | options = creator.ks.handler.bootloader.appendLine |
83 | 83 | ||
84 | timeout = kickstart.get_timeout(cr.ks) | 84 | timeout = kickstart.get_timeout(creator.ks) |
85 | if not timeout: | 85 | if not timeout: |
86 | timeout = 0 | 86 | timeout = 0 |
87 | 87 | ||
@@ -100,7 +100,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
100 | boot_conf = "" | 100 | boot_conf = "" |
101 | boot_conf += "title boot\n" | 101 | boot_conf += "title boot\n" |
102 | boot_conf += "linux %s\n" % kernel | 102 | boot_conf += "linux %s\n" % kernel |
103 | boot_conf += "options LABEL=Boot root=%s %s\n" % (cr.rootdev, options) | 103 | boot_conf += "options LABEL=Boot root=%s %s\n" % (creator.rootdev, options) |
104 | 104 | ||
105 | msger.debug("Writing gummiboot config %s/hdd/boot/loader/entries/boot.conf" \ | 105 | msger.debug("Writing gummiboot config %s/hdd/boot/loader/entries/boot.conf" \ |
106 | % cr_workdir) | 106 | % cr_workdir) |
@@ -110,7 +110,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
110 | 110 | ||
111 | 111 | ||
112 | @classmethod | 112 | @classmethod |
113 | def do_configure_partition(cls, part, source_params, cr, cr_workdir, | 113 | def do_configure_partition(cls, part, source_params, creator, cr_workdir, |
114 | oe_builddir, bootimg_dir, kernel_dir, | 114 | oe_builddir, bootimg_dir, kernel_dir, |
115 | native_sysroot): | 115 | native_sysroot): |
116 | """ | 116 | """ |
@@ -125,9 +125,9 @@ class BootimgEFIPlugin(SourcePlugin): | |||
125 | 125 | ||
126 | try: | 126 | try: |
127 | if source_params['loader'] == 'grub-efi': | 127 | if source_params['loader'] == 'grub-efi': |
128 | cls.do_configure_grubefi(hdddir, cr, cr_workdir) | 128 | cls.do_configure_grubefi(hdddir, creator, cr_workdir) |
129 | elif source_params['loader'] == 'gummiboot': | 129 | elif source_params['loader'] == 'gummiboot': |
130 | cls.do_configure_gummiboot(hdddir, cr, cr_workdir) | 130 | cls.do_configure_gummiboot(hdddir, creator, cr_workdir) |
131 | else: | 131 | else: |
132 | msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader']) | 132 | msger.error("unrecognized bootimg-efi loader: %s" % source_params['loader']) |
133 | except KeyError: | 133 | except KeyError: |
@@ -135,7 +135,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
135 | 135 | ||
136 | 136 | ||
137 | @classmethod | 137 | @classmethod |
138 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, | 138 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, |
139 | oe_builddir, bootimg_dir, kernel_dir, | 139 | oe_builddir, bootimg_dir, kernel_dir, |
140 | rootfs_dir, native_sysroot): | 140 | rootfs_dir, native_sysroot): |
141 | """ | 141 | """ |
@@ -148,7 +148,7 @@ class BootimgEFIPlugin(SourcePlugin): | |||
148 | if not bootimg_dir: | 148 | if not bootimg_dir: |
149 | msger.error("Couldn't find HDDDIR, exiting\n") | 149 | msger.error("Couldn't find HDDDIR, exiting\n") |
150 | # just so the result notes display it | 150 | # just so the result notes display it |
151 | cr.set_bootimg_dir(bootimg_dir) | 151 | creator.set_bootimg_dir(bootimg_dir) |
152 | 152 | ||
153 | staging_kernel_dir = kernel_dir | 153 | staging_kernel_dir = kernel_dir |
154 | 154 | ||
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py index 3c2dbc9d1c..96ed54dbad 100644 --- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py | |||
@@ -41,36 +41,36 @@ class BootimgPcbiosPlugin(SourcePlugin): | |||
41 | name = 'bootimg-pcbios' | 41 | name = 'bootimg-pcbios' |
42 | 42 | ||
43 | @classmethod | 43 | @classmethod |
44 | def do_install_disk(cls, disk, disk_name, cr, workdir, oe_builddir, | 44 | def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, |
45 | bootimg_dir, kernel_dir, native_sysroot): | 45 | bootimg_dir, kernel_dir, native_sysroot): |
46 | """ | 46 | """ |
47 | Called after all partitions have been prepared and assembled into a | 47 | Called after all partitions have been prepared and assembled into a |
48 | disk image. In this case, we install the MBR. | 48 | disk image. In this case, we install the MBR. |
49 | """ | 49 | """ |
50 | mbrfile = "%s/syslinux/" % bootimg_dir | 50 | mbrfile = "%s/syslinux/" % bootimg_dir |
51 | if cr.ptable_format == 'msdos': | 51 | if creator.ptable_format == 'msdos': |
52 | mbrfile += "mbr.bin" | 52 | mbrfile += "mbr.bin" |
53 | elif cr.ptable_format == 'gpt': | 53 | elif creator.ptable_format == 'gpt': |
54 | mbrfile += "gptmbr.bin" | 54 | mbrfile += "gptmbr.bin" |
55 | else: | 55 | else: |
56 | msger.error("Unsupported partition table: %s" % cr.ptable_format) | 56 | msger.error("Unsupported partition table: %s" % creator.ptable_format) |
57 | 57 | ||
58 | if not os.path.exists(mbrfile): | 58 | if not os.path.exists(mbrfile): |
59 | msger.error("Couldn't find %s. If using the -e option, do you " | 59 | msger.error("Couldn't find %s. If using the -e option, do you " |
60 | "have the right MACHINE set in local.conf? If not, " | 60 | "have the right MACHINE set in local.conf? If not, " |
61 | "is the bootimg_dir path correct?" % mbrfile) | 61 | "is the bootimg_dir path correct?" % mbrfile) |
62 | 62 | ||
63 | full_path = cr._full_path(workdir, disk_name, "direct") | 63 | full_path = creator._full_path(workdir, disk_name, "direct") |
64 | msger.debug("Installing MBR on disk %s as %s with size %s bytes" \ | 64 | msger.debug("Installing MBR on disk %s as %s with size %s bytes" \ |
65 | % (disk_name, full_path, disk['min_size'])) | 65 | % (disk_name, full_path, disk['min_size'])) |
66 | 66 | ||
67 | rc = runner.show(['dd', 'if=%s' % mbrfile, | 67 | rcode = runner.show(['dd', 'if=%s' % mbrfile, |
68 | 'of=%s' % full_path, 'conv=notrunc']) | 68 | 'of=%s' % full_path, 'conv=notrunc']) |
69 | if rc != 0: | 69 | if rcode != 0: |
70 | raise ImageError("Unable to set MBR to %s" % full_path) | 70 | raise ImageError("Unable to set MBR to %s" % full_path) |
71 | 71 | ||
72 | @classmethod | 72 | @classmethod |
73 | def do_configure_partition(cls, part, source_params, cr, cr_workdir, | 73 | def do_configure_partition(cls, part, source_params, creator, cr_workdir, |
74 | oe_builddir, bootimg_dir, kernel_dir, | 74 | oe_builddir, bootimg_dir, kernel_dir, |
75 | native_sysroot): | 75 | native_sysroot): |
76 | """ | 76 | """ |
@@ -89,11 +89,11 @@ class BootimgPcbiosPlugin(SourcePlugin): | |||
89 | else: | 89 | else: |
90 | splashline = "" | 90 | splashline = "" |
91 | 91 | ||
92 | options = cr.ks.handler.bootloader.appendLine | 92 | options = creator.ks.handler.bootloader.appendLine |
93 | 93 | ||
94 | syslinux_conf = "" | 94 | syslinux_conf = "" |
95 | syslinux_conf += "PROMPT 0\n" | 95 | syslinux_conf += "PROMPT 0\n" |
96 | timeout = kickstart.get_timeout(cr.ks) | 96 | timeout = kickstart.get_timeout(creator.ks) |
97 | if not timeout: | 97 | if not timeout: |
98 | timeout = 0 | 98 | timeout = 0 |
99 | syslinux_conf += "TIMEOUT " + str(timeout) + "\n" | 99 | syslinux_conf += "TIMEOUT " + str(timeout) + "\n" |
@@ -110,7 +110,7 @@ class BootimgPcbiosPlugin(SourcePlugin): | |||
110 | syslinux_conf += "KERNEL " + kernel + "\n" | 110 | syslinux_conf += "KERNEL " + kernel + "\n" |
111 | 111 | ||
112 | syslinux_conf += "APPEND label=boot root=%s %s\n" % \ | 112 | syslinux_conf += "APPEND label=boot root=%s %s\n" % \ |
113 | (cr.rootdev, options) | 113 | (creator.rootdev, options) |
114 | 114 | ||
115 | msger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg" \ | 115 | msger.debug("Writing syslinux config %s/hdd/boot/syslinux.cfg" \ |
116 | % cr_workdir) | 116 | % cr_workdir) |
@@ -119,7 +119,7 @@ class BootimgPcbiosPlugin(SourcePlugin): | |||
119 | cfg.close() | 119 | cfg.close() |
120 | 120 | ||
121 | @classmethod | 121 | @classmethod |
122 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, | 122 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, |
123 | oe_builddir, bootimg_dir, kernel_dir, | 123 | oe_builddir, bootimg_dir, kernel_dir, |
124 | rootfs_dir, native_sysroot): | 124 | rootfs_dir, native_sysroot): |
125 | """ | 125 | """ |
@@ -141,7 +141,7 @@ class BootimgPcbiosPlugin(SourcePlugin): | |||
141 | if not _has_syslinux(bootimg_dir): | 141 | if not _has_syslinux(bootimg_dir): |
142 | msger.error("Please build syslinux first\n") | 142 | msger.error("Please build syslinux first\n") |
143 | # just so the result notes display it | 143 | # just so the result notes display it |
144 | cr.set_bootimg_dir(bootimg_dir) | 144 | creator.set_bootimg_dir(bootimg_dir) |
145 | 145 | ||
146 | staging_kernel_dir = kernel_dir | 146 | staging_kernel_dir = kernel_dir |
147 | 147 | ||
diff --git a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py index 1cee90637a..9472d8abb9 100644 --- a/scripts/lib/wic/plugins/source/isoimage-isohybrid.py +++ b/scripts/lib/wic/plugins/source/isoimage-isohybrid.py | |||
@@ -54,7 +54,7 @@ class IsoImagePlugin(SourcePlugin): | |||
54 | name = 'isoimage-isohybrid' | 54 | name = 'isoimage-isohybrid' |
55 | 55 | ||
56 | @classmethod | 56 | @classmethod |
57 | def do_configure_syslinux(cls, cr, cr_workdir): | 57 | def do_configure_syslinux(cls, creator, cr_workdir): |
58 | """ | 58 | """ |
59 | Create loader-specific (syslinux) config | 59 | Create loader-specific (syslinux) config |
60 | """ | 60 | """ |
@@ -64,9 +64,9 @@ class IsoImagePlugin(SourcePlugin): | |||
64 | else: | 64 | else: |
65 | splashline = "" | 65 | splashline = "" |
66 | 66 | ||
67 | options = cr.ks.handler.bootloader.appendLine | 67 | options = creator.ks.handler.bootloader.appendLine |
68 | 68 | ||
69 | timeout = kickstart.get_timeout(cr.ks, 10) | 69 | timeout = kickstart.get_timeout(creator.ks, 10) |
70 | 70 | ||
71 | syslinux_conf = "" | 71 | syslinux_conf = "" |
72 | syslinux_conf += "PROMPT 0\n" | 72 | syslinux_conf += "PROMPT 0\n" |
@@ -90,7 +90,7 @@ class IsoImagePlugin(SourcePlugin): | |||
90 | cfg.write(syslinux_conf) | 90 | cfg.write(syslinux_conf) |
91 | 91 | ||
92 | @classmethod | 92 | @classmethod |
93 | def do_configure_grubefi(cls, part, cr, cr_workdir): | 93 | def do_configure_grubefi(cls, part, creator, cr_workdir): |
94 | """ | 94 | """ |
95 | Create loader-specific (grub-efi) config | 95 | Create loader-specific (grub-efi) config |
96 | """ | 96 | """ |
@@ -100,13 +100,13 @@ class IsoImagePlugin(SourcePlugin): | |||
100 | else: | 100 | else: |
101 | splashline = "" | 101 | splashline = "" |
102 | 102 | ||
103 | options = cr.ks.handler.bootloader.appendLine | 103 | options = creator.ks.handler.bootloader.appendLine |
104 | 104 | ||
105 | grubefi_conf = "" | 105 | grubefi_conf = "" |
106 | grubefi_conf += "serial --unit=0 --speed=115200 --word=8 " | 106 | grubefi_conf += "serial --unit=0 --speed=115200 --word=8 " |
107 | grubefi_conf += "--parity=no --stop=1\n" | 107 | grubefi_conf += "--parity=no --stop=1\n" |
108 | grubefi_conf += "default=boot\n" | 108 | grubefi_conf += "default=boot\n" |
109 | timeout = kickstart.get_timeout(cr.ks, 10) | 109 | timeout = kickstart.get_timeout(creator.ks, 10) |
110 | grubefi_conf += "timeout=%s\n" % timeout | 110 | grubefi_conf += "timeout=%s\n" % timeout |
111 | grubefi_conf += "\n" | 111 | grubefi_conf += "\n" |
112 | grubefi_conf += "search --set=root --label %s " % part.label | 112 | grubefi_conf += "search --set=root --label %s " % part.label |
@@ -185,7 +185,7 @@ class IsoImagePlugin(SourcePlugin): | |||
185 | return initrd | 185 | return initrd |
186 | 186 | ||
187 | @classmethod | 187 | @classmethod |
188 | def do_stage_partition(cls, part, source_params, cr, cr_workdir, | 188 | def do_stage_partition(cls, part, source_params, creator, cr_workdir, |
189 | oe_builddir, bootimg_dir, kernel_dir, | 189 | oe_builddir, bootimg_dir, kernel_dir, |
190 | native_sysroot): | 190 | native_sysroot): |
191 | """ | 191 | """ |
@@ -231,7 +231,7 @@ class IsoImagePlugin(SourcePlugin): | |||
231 | exec_cmd("bitbake mtools-native") | 231 | exec_cmd("bitbake mtools-native") |
232 | 232 | ||
233 | @classmethod | 233 | @classmethod |
234 | def do_configure_partition(cls, part, source_params, cr, cr_workdir, | 234 | def do_configure_partition(cls, part, source_params, creator, cr_workdir, |
235 | oe_builddir, bootimg_dir, kernel_dir, | 235 | oe_builddir, bootimg_dir, kernel_dir, |
236 | native_sysroot): | 236 | native_sysroot): |
237 | """ | 237 | """ |
@@ -249,11 +249,11 @@ class IsoImagePlugin(SourcePlugin): | |||
249 | msger.debug("%s" % source_params) | 249 | msger.debug("%s" % source_params) |
250 | if 'image_name' in source_params and \ | 250 | if 'image_name' in source_params and \ |
251 | source_params['image_name'].strip(): | 251 | source_params['image_name'].strip(): |
252 | cr.name = source_params['image_name'].strip() | 252 | creator.name = source_params['image_name'].strip() |
253 | msger.debug("The name of the image is: %s" % cr.name) | 253 | msger.debug("The name of the image is: %s" % creator.name) |
254 | 254 | ||
255 | @classmethod | 255 | @classmethod |
256 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, | 256 | def do_prepare_partition(cls, part, source_params, creator, cr_workdir, |
257 | oe_builddir, bootimg_dir, kernel_dir, | 257 | oe_builddir, bootimg_dir, kernel_dir, |
258 | rootfs_dir, native_sysroot): | 258 | rootfs_dir, native_sysroot): |
259 | """ | 259 | """ |
@@ -353,7 +353,7 @@ class IsoImagePlugin(SourcePlugin): | |||
353 | exec_cmd(install_cmd) | 353 | exec_cmd(install_cmd) |
354 | 354 | ||
355 | if not os.path.isfile("%s/EFI/BOOT/boot.cfg" % bootimg_dir): | 355 | if not os.path.isfile("%s/EFI/BOOT/boot.cfg" % bootimg_dir): |
356 | cls.do_configure_grubefi(part, cr, bootimg_dir) | 356 | cls.do_configure_grubefi(part, creator, bootimg_dir) |
357 | 357 | ||
358 | # Builds bootx64.efi/bootia32.efi if ISODIR didn't exist or | 358 | # Builds bootx64.efi/bootia32.efi if ISODIR didn't exist or |
359 | # didn't contains it | 359 | # didn't contains it |
@@ -463,7 +463,7 @@ class IsoImagePlugin(SourcePlugin): | |||
463 | install_cmd = "install -d %s/isolinux" % isodir | 463 | install_cmd = "install -d %s/isolinux" % isodir |
464 | exec_cmd(install_cmd) | 464 | exec_cmd(install_cmd) |
465 | 465 | ||
466 | cls.do_configure_syslinux(cr, cr_workdir) | 466 | cls.do_configure_syslinux(creator, cr_workdir) |
467 | 467 | ||
468 | install_cmd = "install -m 444 %s/syslinux/ldlinux.sys " % syslinux_dir | 468 | install_cmd = "install -m 444 %s/syslinux/ldlinux.sys " % syslinux_dir |
469 | install_cmd += "%s/isolinux/ldlinux.sys" % isodir | 469 | install_cmd += "%s/isolinux/ldlinux.sys" % isodir |
@@ -508,7 +508,7 @@ class IsoImagePlugin(SourcePlugin): | |||
508 | part.set_source_file(iso_img) | 508 | part.set_source_file(iso_img) |
509 | 509 | ||
510 | @classmethod | 510 | @classmethod |
511 | def do_install_disk(cls, disk, disk_name, cr, workdir, oe_builddir, | 511 | def do_install_disk(cls, disk, disk_name, creator, workdir, oe_builddir, |
512 | bootimg_dir, kernel_dir, native_sysroot): | 512 | bootimg_dir, kernel_dir, native_sysroot): |
513 | """ | 513 | """ |
514 | Called after all partitions have been prepared and assembled into a | 514 | Called after all partitions have been prepared and assembled into a |
@@ -516,9 +516,9 @@ class IsoImagePlugin(SourcePlugin): | |||
516 | utility for booting via BIOS from disk storage devices. | 516 | utility for booting via BIOS from disk storage devices. |
517 | """ | 517 | """ |
518 | 518 | ||
519 | full_path = cr._full_path(workdir, disk_name, "direct") | 519 | full_path = creator._full_path(workdir, disk_name, "direct") |
520 | iso_img = "%s.p1" % full_path | 520 | iso_img = "%s.p1" % full_path |
521 | full_path_iso = cr._full_path(workdir, disk_name, "iso") | 521 | full_path_iso = creator._full_path(workdir, disk_name, "iso") |
522 | 522 | ||
523 | isohybrid_cmd = "isohybrid -u %s" % iso_img | 523 | isohybrid_cmd = "isohybrid -u %s" % iso_img |
524 | msger.debug("running command: %s" % \ | 524 | msger.debug("running command: %s" % \ |
diff --git a/scripts/lib/wic/utils/partitionedfs.py b/scripts/lib/wic/utils/partitionedfs.py index 2f884a3cb8..5a103bbc7e 100644 --- a/scripts/lib/wic/utils/partitionedfs.py +++ b/scripts/lib/wic/utils/partitionedfs.py | |||
@@ -129,14 +129,14 @@ class Image(object): | |||
129 | self._partitions_layed_out = True | 129 | self._partitions_layed_out = True |
130 | 130 | ||
131 | # Go through partitions in the order they are added in .ks file | 131 | # Go through partitions in the order they are added in .ks file |
132 | for n in range(len(self.partitions)): | 132 | for num in range(len(self.partitions)): |
133 | p = self.partitions[n] | 133 | part = self.partitions[num] |
134 | 134 | ||
135 | if not self.disks.has_key(p['disk_name']): | 135 | if not self.disks.has_key(part['disk_name']): |
136 | raise ImageError("No disk %s for partition %s" \ | 136 | raise ImageError("No disk %s for partition %s" \ |
137 | % (p['disk_name'], p['mountpoint'])) | 137 | % (part['disk_name'], part['mountpoint'])) |
138 | 138 | ||
139 | if ptable_format == 'msdos' and p['part_type']: | 139 | if ptable_format == 'msdos' and part['part_type']: |
140 | # The --part-type can also be implemented for MBR partitions, | 140 | # The --part-type can also be implemented for MBR partitions, |
141 | # in which case it would map to the 1-byte "partition type" | 141 | # in which case it would map to the 1-byte "partition type" |
142 | # filed at offset 3 of the partition entry. | 142 | # filed at offset 3 of the partition entry. |
@@ -144,79 +144,79 @@ class Image(object): | |||
144 | "implemented for msdos partitions") | 144 | "implemented for msdos partitions") |
145 | 145 | ||
146 | # Get the disk where the partition is located | 146 | # Get the disk where the partition is located |
147 | d = self.disks[p['disk_name']] | 147 | disk = self.disks[part['disk_name']] |
148 | d['numpart'] += 1 | 148 | disk['numpart'] += 1 |
149 | if not p['no_table']: | 149 | if not part['no_table']: |
150 | d['realpart'] += 1 | 150 | disk['realpart'] += 1 |
151 | d['ptable_format'] = ptable_format | 151 | disk['ptable_format'] = ptable_format |
152 | 152 | ||
153 | if d['numpart'] == 1: | 153 | if disk['numpart'] == 1: |
154 | if ptable_format == "msdos": | 154 | if ptable_format == "msdos": |
155 | overhead = MBR_OVERHEAD | 155 | overhead = MBR_OVERHEAD |
156 | elif ptable_format == "gpt": | 156 | elif ptable_format == "gpt": |
157 | overhead = GPT_OVERHEAD | 157 | overhead = GPT_OVERHEAD |
158 | 158 | ||
159 | # Skip one sector required for the partitioning scheme overhead | 159 | # Skip one sector required for the partitioning scheme overhead |
160 | d['offset'] += overhead | 160 | disk['offset'] += overhead |
161 | 161 | ||
162 | if d['realpart'] > 3: | 162 | if disk['realpart'] > 3: |
163 | # Reserve a sector for EBR for every logical partition | 163 | # Reserve a sector for EBR for every logical partition |
164 | # before alignment is performed. | 164 | # before alignment is performed. |
165 | if ptable_format == "msdos": | 165 | if ptable_format == "msdos": |
166 | d['offset'] += 1 | 166 | disk['offset'] += 1 |
167 | 167 | ||
168 | 168 | ||
169 | if p['align']: | 169 | if part['align']: |
170 | # If not first partition and we do have alignment set we need | 170 | # If not first partition and we do have alignment set we need |
171 | # to align the partition. | 171 | # to align the partition. |
172 | # FIXME: This leaves a empty spaces to the disk. To fill the | 172 | # FIXME: This leaves a empty spaces to the disk. To fill the |
173 | # gaps we could enlargea the previous partition? | 173 | # gaps we could enlargea the previous partition? |
174 | 174 | ||
175 | # Calc how much the alignment is off. | 175 | # Calc how much the alignment is off. |
176 | align_sectors = d['offset'] % (p['align'] * 1024 / self.sector_size) | 176 | align_sectors = disk['offset'] % (part['align'] * 1024 / self.sector_size) |
177 | 177 | ||
178 | if align_sectors: | 178 | if align_sectors: |
179 | # If partition is not aligned as required, we need | 179 | # If partition is not aligned as required, we need |
180 | # to move forward to the next alignment point | 180 | # to move forward to the next alignment point |
181 | align_sectors = (p['align'] * 1024 / self.sector_size) - align_sectors | 181 | align_sectors = (part['align'] * 1024 / self.sector_size) - align_sectors |
182 | 182 | ||
183 | msger.debug("Realignment for %s%s with %s sectors, original" | 183 | msger.debug("Realignment for %s%s with %s sectors, original" |
184 | " offset %s, target alignment is %sK." % | 184 | " offset %s, target alignment is %sK." % |
185 | (p['disk_name'], d['numpart'], align_sectors, | 185 | (part['disk_name'], disk['numpart'], align_sectors, |
186 | d['offset'], p['align'])) | 186 | disk['offset'], part['align'])) |
187 | 187 | ||
188 | # increase the offset so we actually start the partition on right alignment | 188 | # increase the offset so we actually start the partition on right alignment |
189 | d['offset'] += align_sectors | 189 | disk['offset'] += align_sectors |
190 | 190 | ||
191 | p['start'] = d['offset'] | 191 | part['start'] = disk['offset'] |
192 | d['offset'] += p['size'] | 192 | disk['offset'] += part['size'] |
193 | 193 | ||
194 | p['type'] = 'primary' | 194 | part['type'] = 'primary' |
195 | if not p['no_table']: | 195 | if not part['no_table']: |
196 | p['num'] = d['realpart'] | 196 | part['num'] = disk['realpart'] |
197 | else: | 197 | else: |
198 | p['num'] = 0 | 198 | part['num'] = 0 |
199 | 199 | ||
200 | if d['ptable_format'] == "msdos": | 200 | if disk['ptable_format'] == "msdos": |
201 | if d['realpart'] > 3: | 201 | if disk['realpart'] > 3: |
202 | p['type'] = 'logical' | 202 | part['type'] = 'logical' |
203 | p['num'] = d['realpart'] + 1 | 203 | part['num'] = disk['realpart'] + 1 |
204 | 204 | ||
205 | d['partitions'].append(n) | 205 | disk['partitions'].append(num) |
206 | msger.debug("Assigned %s to %s%d, sectors range %d-%d size %d " | 206 | msger.debug("Assigned %s to %s%d, sectors range %d-%d size %d " |
207 | "sectors (%d bytes)." \ | 207 | "sectors (%d bytes)." \ |
208 | % (p['mountpoint'], p['disk_name'], p['num'], | 208 | % (part['mountpoint'], part['disk_name'], part['num'], |
209 | p['start'], p['start'] + p['size'] - 1, | 209 | part['start'], part['start'] + part['size'] - 1, |
210 | p['size'], p['size'] * self.sector_size)) | 210 | part['size'], part['size'] * self.sector_size)) |
211 | 211 | ||
212 | # Once all the partitions have been layed out, we can calculate the | 212 | # Once all the partitions have been layed out, we can calculate the |
213 | # minumim disk sizes. | 213 | # minumim disk sizes. |
214 | for d in self.disks.values(): | 214 | for disk in self.disks.values(): |
215 | d['min_size'] = d['offset'] | 215 | disk['min_size'] = disk['offset'] |
216 | if d['ptable_format'] == "gpt": | 216 | if disk['ptable_format'] == "gpt": |
217 | d['min_size'] += GPT_OVERHEAD | 217 | disk['min_size'] += GPT_OVERHEAD |
218 | 218 | ||
219 | d['min_size'] *= self.sector_size | 219 | disk['min_size'] *= self.sector_size |
220 | 220 | ||
221 | def __create_partition(self, device, parttype, fstype, start, size): | 221 | def __create_partition(self, device, parttype, fstype, start, size): |
222 | """ Create a partition on an image described by the 'device' object. """ | 222 | """ Create a partition on an image described by the 'device' object. """ |
@@ -237,21 +237,21 @@ class Image(object): | |||
237 | self.layout_partitions() | 237 | self.layout_partitions() |
238 | 238 | ||
239 | for dev in self.disks.keys(): | 239 | for dev in self.disks.keys(): |
240 | d = self.disks[dev] | 240 | disk = self.disks[dev] |
241 | msger.debug("Initializing partition table for %s" % \ | 241 | msger.debug("Initializing partition table for %s" % \ |
242 | (d['disk'].device)) | 242 | (disk['disk'].device)) |
243 | exec_native_cmd("parted -s %s mklabel %s" % \ | 243 | exec_native_cmd("parted -s %s mklabel %s" % \ |
244 | (d['disk'].device, d['ptable_format']), | 244 | (disk['disk'].device, disk['ptable_format']), |
245 | self.native_sysroot) | 245 | self.native_sysroot) |
246 | 246 | ||
247 | msger.debug("Creating partitions") | 247 | msger.debug("Creating partitions") |
248 | 248 | ||
249 | for p in self.partitions: | 249 | for part in self.partitions: |
250 | if p['num'] == 0: | 250 | if part['num'] == 0: |
251 | continue | 251 | continue |
252 | 252 | ||
253 | d = self.disks[p['disk_name']] | 253 | disk = self.disks[part['disk_name']] |
254 | if d['ptable_format'] == "msdos" and p['num'] == 5: | 254 | if disk['ptable_format'] == "msdos" and part['num'] == 5: |
255 | # Create an extended partition (note: extended | 255 | # Create an extended partition (note: extended |
256 | # partition is described in MBR and contains all | 256 | # partition is described in MBR and contains all |
257 | # logical partitions). The logical partitions save a | 257 | # logical partitions). The logical partitions save a |
@@ -263,17 +263,17 @@ class Image(object): | |||
263 | # starts a sector before the first logical partition, | 263 | # starts a sector before the first logical partition, |
264 | # add a sector at the back, so that there is enough | 264 | # add a sector at the back, so that there is enough |
265 | # room for all logical partitions. | 265 | # room for all logical partitions. |
266 | self.__create_partition(d['disk'].device, "extended", | 266 | self.__create_partition(disk['disk'].device, "extended", |
267 | None, p['start'] - 1, | 267 | None, part['start'] - 1, |
268 | d['offset'] - p['start'] + 1) | 268 | disk['offset'] - part['start'] + 1) |
269 | 269 | ||
270 | if p['fstype'] == "swap": | 270 | if part['fstype'] == "swap": |
271 | parted_fs_type = "linux-swap" | 271 | parted_fs_type = "linux-swap" |
272 | elif p['fstype'] == "vfat": | 272 | elif part['fstype'] == "vfat": |
273 | parted_fs_type = "fat32" | 273 | parted_fs_type = "fat32" |
274 | elif p['fstype'] == "msdos": | 274 | elif part['fstype'] == "msdos": |
275 | parted_fs_type = "fat16" | 275 | parted_fs_type = "fat16" |
276 | elif p['fstype'] == "ontrackdm6aux3": | 276 | elif part['fstype'] == "ontrackdm6aux3": |
277 | parted_fs_type = "ontrackdm6aux3" | 277 | parted_fs_type = "ontrackdm6aux3" |
278 | else: | 278 | else: |
279 | # Type for ext2/ext3/ext4/btrfs | 279 | # Type for ext2/ext3/ext4/btrfs |
@@ -281,55 +281,55 @@ class Image(object): | |||
281 | 281 | ||
282 | # Boot ROM of OMAP boards require vfat boot partition to have an | 282 | # Boot ROM of OMAP boards require vfat boot partition to have an |
283 | # even number of sectors. | 283 | # even number of sectors. |
284 | if p['mountpoint'] == "/boot" and p['fstype'] in ["vfat", "msdos"] \ | 284 | if part['mountpoint'] == "/boot" and part['fstype'] in ["vfat", "msdos"] \ |
285 | and p['size'] % 2: | 285 | and part['size'] % 2: |
286 | msger.debug("Substracting one sector from '%s' partition to " \ | 286 | msger.debug("Substracting one sector from '%s' partition to " \ |
287 | "get even number of sectors for the partition" % \ | 287 | "get even number of sectors for the partition" % \ |
288 | p['mountpoint']) | 288 | part['mountpoint']) |
289 | p['size'] -= 1 | 289 | part['size'] -= 1 |
290 | 290 | ||
291 | self.__create_partition(d['disk'].device, p['type'], | 291 | self.__create_partition(disk['disk'].device, part['type'], |
292 | parted_fs_type, p['start'], p['size']) | 292 | parted_fs_type, part['start'], part['size']) |
293 | 293 | ||
294 | if p['part_type']: | 294 | if part['part_type']: |
295 | msger.debug("partition %d: set type UID to %s" % \ | 295 | msger.debug("partition %d: set type UID to %s" % \ |
296 | (p['num'], p['part_type'])) | 296 | (part['num'], part['part_type'])) |
297 | exec_native_cmd("sgdisk --typecode=%d:%s %s" % \ | 297 | exec_native_cmd("sgdisk --typecode=%d:%s %s" % \ |
298 | (p['num'], p['part_type'], | 298 | (part['num'], part['part_type'], |
299 | d['disk'].device), self.native_sysroot) | 299 | disk['disk'].device), self.native_sysroot) |
300 | 300 | ||
301 | if p['uuid']: | 301 | if part['uuid']: |
302 | msger.debug("partition %d: set UUID to %s" % \ | 302 | msger.debug("partition %d: set UUID to %s" % \ |
303 | (p['num'], p['uuid'])) | 303 | (part['num'], part['uuid'])) |
304 | exec_native_cmd("sgdisk --partition-guid=%d:%s %s" % \ | 304 | exec_native_cmd("sgdisk --partition-guid=%d:%s %s" % \ |
305 | (p['num'], p['uuid'], d['disk'].device), | 305 | (part['num'], part['uuid'], disk['disk'].device), |
306 | self.native_sysroot) | 306 | self.native_sysroot) |
307 | 307 | ||
308 | if p['boot']: | 308 | if part['boot']: |
309 | flag_name = "legacy_boot" if d['ptable_format'] == 'gpt' else "boot" | 309 | flag_name = "legacy_boot" if disk['ptable_format'] == 'gpt' else "boot" |
310 | msger.debug("Set '%s' flag for partition '%s' on disk '%s'" % \ | 310 | msger.debug("Set '%s' flag for partition '%s' on disk '%s'" % \ |
311 | (flag_name, p['num'], d['disk'].device)) | 311 | (flag_name, part['num'], disk['disk'].device)) |
312 | exec_native_cmd("parted -s %s set %d %s on" % \ | 312 | exec_native_cmd("parted -s %s set %d %s on" % \ |
313 | (d['disk'].device, p['num'], flag_name), | 313 | (disk['disk'].device, part['num'], flag_name), |
314 | self.native_sysroot) | 314 | self.native_sysroot) |
315 | 315 | ||
316 | # Parted defaults to enabling the lba flag for fat16 partitions, | 316 | # Parted defaults to enabling the lba flag for fat16 partitions, |
317 | # which causes compatibility issues with some firmware (and really | 317 | # which causes compatibility issues with some firmware (and really |
318 | # isn't necessary). | 318 | # isn't necessary). |
319 | if parted_fs_type == "fat16": | 319 | if parted_fs_type == "fat16": |
320 | if d['ptable_format'] == 'msdos': | 320 | if disk['ptable_format'] == 'msdos': |
321 | msger.debug("Disable 'lba' flag for partition '%s' on disk '%s'" % \ | 321 | msger.debug("Disable 'lba' flag for partition '%s' on disk '%s'" % \ |
322 | (p['num'], d['disk'].device)) | 322 | (part['num'], disk['disk'].device)) |
323 | exec_native_cmd("parted -s %s set %d lba off" % \ | 323 | exec_native_cmd("parted -s %s set %d lba off" % \ |
324 | (d['disk'].device, p['num']), | 324 | (disk['disk'].device, part['num']), |
325 | self.native_sysroot) | 325 | self.native_sysroot) |
326 | 326 | ||
327 | def cleanup(self): | 327 | def cleanup(self): |
328 | if self.disks: | 328 | if self.disks: |
329 | for dev in self.disks: | 329 | for dev in self.disks: |
330 | d = self.disks[dev] | 330 | disk = self.disks[dev] |
331 | try: | 331 | try: |
332 | d['disk'].cleanup() | 332 | disk['disk'].cleanup() |
333 | except: | 333 | except: |
334 | pass | 334 | pass |
335 | 335 | ||
@@ -354,8 +354,8 @@ class Image(object): | |||
354 | 354 | ||
355 | def create(self): | 355 | def create(self): |
356 | for dev in self.disks.keys(): | 356 | for dev in self.disks.keys(): |
357 | d = self.disks[dev] | 357 | disk = self.disks[dev] |
358 | d['disk'].create() | 358 | disk['disk'].create() |
359 | 359 | ||
360 | self.__format_disks() | 360 | self.__format_disks() |
361 | 361 | ||
diff --git a/scripts/lib/wic/utils/runner.py b/scripts/lib/wic/utils/runner.py index f6a1d0828c..7431917ff0 100644 --- a/scripts/lib/wic/utils/runner.py +++ b/scripts/lib/wic/utils/runner.py | |||
@@ -62,13 +62,13 @@ def runtool(cmdln_or_args, catch=1): | |||
62 | serr = subprocess.STDOUT | 62 | serr = subprocess.STDOUT |
63 | 63 | ||
64 | try: | 64 | try: |
65 | p = subprocess.Popen(cmdln_or_args, stdout=sout, | 65 | process = subprocess.Popen(cmdln_or_args, stdout=sout, |
66 | stderr=serr, shell=shell) | 66 | stderr=serr, shell=shell) |
67 | (sout, serr) = p.communicate() | 67 | (sout, serr) = process.communicate() |
68 | # combine stdout and stderr, filter None out | 68 | # combine stdout and stderr, filter None out |
69 | out = ''.join(filter(None, [sout, serr])) | 69 | out = ''.join(filter(None, [sout, serr])) |
70 | except OSError, e: | 70 | except OSError, err: |
71 | if e.errno == 2: | 71 | if err.errno == 2: |
72 | # [Errno 2] No such file or directory | 72 | # [Errno 2] No such file or directory |
73 | msger.error('Cannot run command: %s, lost dependency?' % cmd) | 73 | msger.error('Cannot run command: %s, lost dependency?' % cmd) |
74 | else: | 74 | else: |
@@ -77,12 +77,12 @@ def runtool(cmdln_or_args, catch=1): | |||
77 | if catch != 3: | 77 | if catch != 3: |
78 | os.close(dev_null) | 78 | os.close(dev_null) |
79 | 79 | ||
80 | return (p.returncode, out) | 80 | return (process.returncode, out) |
81 | 81 | ||
82 | def show(cmdln_or_args): | 82 | def show(cmdln_or_args): |
83 | # show all the message using msger.verbose | 83 | # show all the message using msger.verbose |
84 | 84 | ||
85 | rc, out = runtool(cmdln_or_args, catch=3) | 85 | rcode, out = runtool(cmdln_or_args, catch=3) |
86 | 86 | ||
87 | if isinstance(cmdln_or_args, list): | 87 | if isinstance(cmdln_or_args, list): |
88 | cmd = ' '.join(cmdln_or_args) | 88 | cmd = ' '.join(cmdln_or_args) |
@@ -100,7 +100,7 @@ def show(cmdln_or_args): | |||
100 | msg += '\n +----------------' | 100 | msg += '\n +----------------' |
101 | 101 | ||
102 | msger.verbose(msg) | 102 | msger.verbose(msg) |
103 | return rc | 103 | return rcode |
104 | 104 | ||
105 | def outs(cmdln_or_args, catch=1): | 105 | def outs(cmdln_or_args, catch=1): |
106 | # get the outputs of tools | 106 | # get the outputs of tools |