summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic')
-rw-r--r--scripts/lib/wic/help.py10
-rw-r--r--scripts/lib/wic/ksparser.py1
-rw-r--r--scripts/lib/wic/partition.py32
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py17
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-efi.py3
-rw-r--r--scripts/lib/wic/plugins/source/bootimg-pcbios.py3
6 files changed, 47 insertions, 19 deletions
diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index 2ac45e052e..bf658b94e3 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -863,7 +863,10 @@ DESCRIPTION
863 This is achieved by wic adding entries to the fstab during image 863 This is achieved by wic adding entries to the fstab during image
864 generation. In order for a valid fstab to be generated one of the 864 generation. In order for a valid fstab to be generated one of the
865 --ondrive, --ondisk or --use-uuid partition options must be used for 865 --ondrive, --ondisk or --use-uuid partition options must be used for
866 each partition that specifies a mountpoint. 866 each partition that specifies a mountpoint. Note that with --use-uuid
867 and non-root <mountpoint>, including swap, the mount program must
868 understand the PARTUUID syntax. This currently excludes the busybox
869 versions of these applications.
867 870
868 871
869 The following are supported 'part' options: 872 The following are supported 'part' options:
@@ -986,6 +989,11 @@ DESCRIPTION
986 in bootloader configuration before running wic. In this case .wks file can 989 in bootloader configuration before running wic. In this case .wks file can
987 be generated or modified to set preconfigured parition UUID using this option. 990 be generated or modified to set preconfigured parition UUID using this option.
988 991
992 --fsuuid: This option is specific to wic. It specifies filesystem UUID.
993 It's useful if preconfigured filesystem UUID is added to kernel command line
994 in bootloader configuration before running wic. In this case .wks file can
995 be generated or modified to set preconfigured filesystem UUID using this option.
996
989 --system-id: This option is specific to wic. It specifies partition system id. It's useful 997 --system-id: This option is specific to wic. It specifies partition system id. It's useful
990 for the harware that requires non-default partition system ids. The parameter 998 for the harware that requires non-default partition system ids. The parameter
991 in one byte long hex number either with 0x prefix or without it. 999 in one byte long hex number either with 0x prefix or without it.
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index 4fb6868531..e590b2fe3c 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -161,6 +161,7 @@ class KickStart():
161 part.add_argument('--system-id', type=systemidtype) 161 part.add_argument('--system-id', type=systemidtype)
162 part.add_argument('--use-uuid', action='store_true') 162 part.add_argument('--use-uuid', action='store_true')
163 part.add_argument('--uuid') 163 part.add_argument('--uuid')
164 part.add_argument('--fsuuid')
164 165
165 bootloader = subparsers.add_parser('bootloader') 166 bootloader = subparsers.add_parser('bootloader')
166 bootloader.add_argument('--append') 167 bootloader.add_argument('--append')
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 8731238337..c0b67d829f 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -26,6 +26,7 @@
26 26
27import logging 27import logging
28import os 28import os
29import uuid
29 30
30from wic import WicError 31from wic import WicError
31from wic.misc import exec_cmd, exec_native_cmd, get_bitbake_var 32from wic.misc import exec_cmd, exec_native_cmd, get_bitbake_var
@@ -61,6 +62,7 @@ class Partition():
61 self.system_id = args.system_id 62 self.system_id = args.system_id
62 self.use_uuid = args.use_uuid 63 self.use_uuid = args.use_uuid
63 self.uuid = args.uuid 64 self.uuid = args.uuid
65 self.fsuuid = args.fsuuid
64 66
65 self.lineno = lineno 67 self.lineno = lineno
66 self.source_file = "" 68 self.source_file = ""
@@ -264,8 +266,8 @@ class Partition():
264 if self.label: 266 if self.label:
265 label_str = "-L %s" % self.label 267 label_str = "-L %s" % self.label
266 268
267 mkfs_cmd = "mkfs.%s %s %s %s -d %s" % \ 269 mkfs_cmd = "mkfs.%s %s %s %s -U %s -d %s" % \
268 (self.fstype, extraopts, rootfs, label_str, rootfs_dir) 270 (self.fstype, extraopts, rootfs, label_str, self.fsuuid, rootfs_dir)
269 exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) 271 exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
270 272
271 mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs) 273 mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs)
@@ -289,9 +291,9 @@ class Partition():
289 if self.label: 291 if self.label:
290 label_str = "-L %s" % self.label 292 label_str = "-L %s" % self.label
291 293
292 mkfs_cmd = "mkfs.%s -b %d -r %s %s %s %s" % \ 294 mkfs_cmd = "mkfs.%s -b %d -r %s %s %s -U %s %s" % \
293 (self.fstype, rootfs_size * 1024, rootfs_dir, label_str, 295 (self.fstype, rootfs_size * 1024, rootfs_dir, label_str,
294 self.mkfs_extraopts, rootfs) 296 self.mkfs_extraopts, self.fsuuid, rootfs)
295 exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) 297 exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
296 298
297 def prepare_rootfs_msdos(self, rootfs, oe_builddir, rootfs_dir, 299 def prepare_rootfs_msdos(self, rootfs, oe_builddir, rootfs_dir,
@@ -315,8 +317,9 @@ class Partition():
315 317
316 extraopts = self.mkfs_extraopts or '-S 512' 318 extraopts = self.mkfs_extraopts or '-S 512'
317 319
318 dosfs_cmd = "mkdosfs %s %s %s -C %s %d" % \ 320 dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \
319 (label_str, size_str, extraopts, rootfs, rootfs_size) 321 (label_str, self.fsuuid, size_str, extraopts, rootfs,
322 rootfs_size)
320 exec_native_cmd(dosfs_cmd, native_sysroot) 323 exec_native_cmd(dosfs_cmd, native_sysroot)
321 324
322 mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, rootfs_dir) 325 mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (rootfs, rootfs_dir)
@@ -352,8 +355,8 @@ class Partition():
352 if self.label: 355 if self.label:
353 label_str = "-L %s" % self.label 356 label_str = "-L %s" % self.label
354 357
355 mkfs_cmd = "mkfs.%s -F %s %s %s" % \ 358 mkfs_cmd = "mkfs.%s -F %s %s -U %s %s" % \
356 (self.fstype, extraopts, label_str, rootfs) 359 (self.fstype, extraopts, label_str, self.fsuuid, rootfs)
357 exec_native_cmd(mkfs_cmd, native_sysroot) 360 exec_native_cmd(mkfs_cmd, native_sysroot)
358 361
359 def prepare_empty_partition_btrfs(self, rootfs, oe_builddir, 362 def prepare_empty_partition_btrfs(self, rootfs, oe_builddir,
@@ -369,8 +372,8 @@ class Partition():
369 if self.label: 372 if self.label:
370 label_str = "-L %s" % self.label 373 label_str = "-L %s" % self.label
371 374
372 mkfs_cmd = "mkfs.%s -b %d %s %s %s" % \ 375 mkfs_cmd = "mkfs.%s -b %d %s -U %s %s %s" % \
373 (self.fstype, self.size * 1024, label_str, 376 (self.fstype, self.size * 1024, label_str, self.fsuuid,
374 self.mkfs_extraopts, rootfs) 377 self.mkfs_extraopts, rootfs)
375 exec_native_cmd(mkfs_cmd, native_sysroot) 378 exec_native_cmd(mkfs_cmd, native_sysroot)
376 379
@@ -391,8 +394,9 @@ class Partition():
391 394
392 extraopts = self.mkfs_extraopts or '-S 512' 395 extraopts = self.mkfs_extraopts or '-S 512'
393 396
394 dosfs_cmd = "mkdosfs %s %s %s -C %s %d" % \ 397 dosfs_cmd = "mkdosfs %s -i %s %s %s -C %s %d" % \
395 (label_str, extraopts, size_str, rootfs, blocks) 398 (label_str, self.fsuuid, extraopts, size_str, rootfs,
399 blocks)
396 400
397 exec_native_cmd(dosfs_cmd, native_sysroot) 401 exec_native_cmd(dosfs_cmd, native_sysroot)
398 402
@@ -410,9 +414,9 @@ class Partition():
410 with open(path, 'w') as sparse: 414 with open(path, 'w') as sparse:
411 os.ftruncate(sparse.fileno(), self.size * 1024) 415 os.ftruncate(sparse.fileno(), self.size * 1024)
412 416
413 import uuid
414 label_str = "" 417 label_str = ""
415 if self.label: 418 if self.label:
416 label_str = "-L %s" % self.label 419 label_str = "-L %s" % self.label
417 mkswap_cmd = "mkswap %s -U %s %s" % (label_str, str(uuid.uuid1()), path) 420
421 mkswap_cmd = "mkswap %s -U %s %s" % (label_str, self.fsuuid, path)
418 exec_native_cmd(mkswap_cmd, native_sysroot) 422 exec_native_cmd(mkswap_cmd, native_sysroot)
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index da1c061063..71c0b1c82b 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -141,7 +141,15 @@ class DirectPlugin(ImagerPlugin):
141 continue 141 continue
142 142
143 if part.use_uuid: 143 if part.use_uuid:
144 device_name = "PARTUUID=%s" % part.uuid 144 if part.fsuuid:
145 # FAT UUID is different from others
146 if len(part.fsuuid) == 10:
147 device_name = "UUID=%s-%s" % \
148 (part.fsuuid[2:6], part.fsuuid[6:])
149 else:
150 device_name = "UUID=%s" % part.fsuuid
151 else:
152 device_name = "PARTUUID=%s" % part.uuid
145 else: 153 else:
146 # mmc device partitions are named mmcblk0p1, mmcblk0p2.. 154 # mmc device partitions are named mmcblk0p1, mmcblk0p2..
147 prefix = 'p' if part.disk.startswith('mmcblk') else '' 155 prefix = 'p' if part.disk.startswith('mmcblk') else ''
@@ -334,13 +342,18 @@ class PartitionedImage():
334 continue 342 continue
335 part.realnum = realnum 343 part.realnum = realnum
336 344
337 # generate parition UUIDs 345 # generate parition and filesystem UUIDs
338 for part in self.partitions: 346 for part in self.partitions:
339 if not part.uuid and part.use_uuid: 347 if not part.uuid and part.use_uuid:
340 if self.ptable_format == 'gpt': 348 if self.ptable_format == 'gpt':
341 part.uuid = str(uuid.uuid4()) 349 part.uuid = str(uuid.uuid4())
342 else: # msdos partition table 350 else: # msdos partition table
343 part.uuid = '%08x-%02d' % (self.identifier, part.realnum) 351 part.uuid = '%08x-%02d' % (self.identifier, part.realnum)
352 if not part.fsuuid:
353 if part.fstype == 'vfat' or part.fstype == 'msdos':
354 part.fsuuid = '0x' + str(uuid.uuid4())[:8].upper()
355 else:
356 part.fsuuid = str(uuid.uuid4())
344 357
345 def prepare(self, imager): 358 def prepare(self, imager):
346 """Prepare an image. Call prepare method of all image partitions.""" 359 """Prepare an image. Call prepare method of all image partitions."""
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
index 4c4f36a32f..beb74d7a71 100644
--- a/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ b/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -240,7 +240,8 @@ class BootimgEFIPlugin(SourcePlugin):
240 # dosfs image, created by mkdosfs 240 # dosfs image, created by mkdosfs
241 bootimg = "%s/boot.img" % cr_workdir 241 bootimg = "%s/boot.img" % cr_workdir
242 242
243 dosfs_cmd = "mkdosfs -n efi -C %s %d" % (bootimg, blocks) 243 dosfs_cmd = "mkdosfs -n efi -i %s -C %s %d" % \
244 (part.fsuuid, bootimg, blocks)
244 exec_native_cmd(dosfs_cmd, native_sysroot) 245 exec_native_cmd(dosfs_cmd, native_sysroot)
245 246
246 mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir) 247 mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)
diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
index 56da468fb5..d599112dd7 100644
--- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py
+++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py
@@ -186,7 +186,8 @@ class BootimgPcbiosPlugin(SourcePlugin):
186 # dosfs image, created by mkdosfs 186 # dosfs image, created by mkdosfs
187 bootimg = "%s/boot%s.img" % (cr_workdir, part.lineno) 187 bootimg = "%s/boot%s.img" % (cr_workdir, part.lineno)
188 188
189 dosfs_cmd = "mkdosfs -n boot -S 512 -C %s %d" % (bootimg, blocks) 189 dosfs_cmd = "mkdosfs -n boot -i %s -S 512 -C %s %d" % \
190 (part.fsuuid, bootimg, blocks)
190 exec_native_cmd(dosfs_cmd, native_sysroot) 191 exec_native_cmd(dosfs_cmd, native_sysroot)
191 192
192 mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir) 193 mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)