diff options
Diffstat (limited to 'import-layers/yocto-poky/scripts/lib/wic')
7 files changed, 31 insertions, 17 deletions
diff --git a/import-layers/yocto-poky/scripts/lib/wic/canned-wks/systemd-bootdisk.wks b/import-layers/yocto-poky/scripts/lib/wic/canned-wks/systemd-bootdisk.wks index b90002356..4bd9d6a65 100644 --- a/import-layers/yocto-poky/scripts/lib/wic/canned-wks/systemd-bootdisk.wks +++ b/import-layers/yocto-poky/scripts/lib/wic/canned-wks/systemd-bootdisk.wks @@ -4,7 +4,7 @@ part /boot --source bootimg-efi --sourceparams="loader=systemd-boot" --ondisk sda --label msdos --active --align 1024 -part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 +part / --source rootfs --ondisk sda --fstype=ext4 --label platform --align 1024 --use-uuid part swap --ondisk sda --size 44 --label swap1 --fstype=swap diff --git a/import-layers/yocto-poky/scripts/lib/wic/filemap.py b/import-layers/yocto-poky/scripts/lib/wic/filemap.py index f3240ba8d..162603ed0 100644 --- a/import-layers/yocto-poky/scripts/lib/wic/filemap.py +++ b/import-layers/yocto-poky/scripts/lib/wic/filemap.py @@ -543,9 +543,9 @@ def sparse_copy(src_fname, dst_fname, offset=0, skip=0): end = (last + 1) * fmap.block_size if start < skip < end: - start = skip - - fmap._f_image.seek(start, os.SEEK_SET) + fmap._f_image.seek(skip, os.SEEK_SET) + else: + fmap._f_image.seek(start, os.SEEK_SET) dst_file.seek(offset + start, os.SEEK_SET) chunk_size = 1024 * 1024 diff --git a/import-layers/yocto-poky/scripts/lib/wic/imager/direct.py b/import-layers/yocto-poky/scripts/lib/wic/imager/direct.py index edf5e5d22..4c547e04a 100644 --- a/import-layers/yocto-poky/scripts/lib/wic/imager/direct.py +++ b/import-layers/yocto-poky/scripts/lib/wic/imager/direct.py @@ -108,7 +108,7 @@ class DirectImageCreator(BaseImageCreator): if pnum == num: if part.no_table: return 0 - if self.ptable_format == 'msdos' and realnum > 3: + if self.ptable_format == 'msdos' and realnum > 3 and len(parts) > 4: # account for logical partition numbering, ex. sda5.. return realnum + 1 return realnum diff --git a/import-layers/yocto-poky/scripts/lib/wic/partition.py b/import-layers/yocto-poky/scripts/lib/wic/partition.py index 90f65a1e3..ec3aa6622 100644 --- a/import-layers/yocto-poky/scripts/lib/wic/partition.py +++ b/import-layers/yocto-poky/scripts/lib/wic/partition.py @@ -146,6 +146,12 @@ class Partition(): oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, native_sysroot) + # further processing required Partition.size to be an integer, make + # sure that it is one + if type(self.size) is not int: + msger.error("Partition %s internal size is not an integer. " \ + "This a bug in source plugin %s and needs to be fixed." \ + % (self.mountpoint, self.source)) def prepare_rootfs_from_fs_image(self, cr_workdir, oe_builddir, rootfs_dir): @@ -157,7 +163,7 @@ class Partition(): out = exec_cmd(du_cmd) rootfs_size = out.split()[0] - self.size = rootfs_size + self.size = int(rootfs_size) self.source_file = rootfs def prepare_rootfs(self, cr_workdir, oe_builddir, rootfs_dir, @@ -184,6 +190,10 @@ class Partition(): if os.path.isfile(rootfs): os.remove(rootfs) + if not self.fstype: + msger.error("File system for partition %s not specified in kickstart, " \ + "use --fstype option" % (self.mountpoint)) + for prefix in ("ext", "btrfs", "vfat", "squashfs"): if self.fstype.startswith(prefix): method = getattr(self, "prepare_rootfs_" + prefix) @@ -194,7 +204,7 @@ class Partition(): # get the rootfs size in the right units for kickstart (kB) du_cmd = "du -Lbks %s" % rootfs out = exec_cmd(du_cmd) - self.size = out.split()[0] + self.size = int(out.split()[0]) break @@ -229,6 +239,9 @@ class Partition(): (self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir) exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) + mkfs_cmd = "fsck.%s -pvfD %s || [ $? -le 3 ]" % (self.fstype, rootfs) + exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo) + def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir, native_sysroot, pseudo): """ @@ -375,7 +388,7 @@ class Partition(): out = exec_cmd(du_cmd) fs_size = out.split()[0] - self.size = fs_size + self.size = int(fs_size) def prepare_swap_partition(self, cr_workdir, oe_builddir, native_sysroot): """ diff --git a/import-layers/yocto-poky/scripts/lib/wic/plugins/source/bootimg-efi.py b/import-layers/yocto-poky/scripts/lib/wic/plugins/source/bootimg-efi.py index 8bc362254..4adb80bec 100644 --- a/import-layers/yocto-poky/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/import-layers/yocto-poky/scripts/lib/wic/plugins/source/bootimg-efi.py @@ -234,5 +234,5 @@ class BootimgEFIPlugin(SourcePlugin): out = exec_cmd(du_cmd) bootimg_size = out.split()[0] - part.size = bootimg_size + part.size = int(bootimg_size) part.source_file = bootimg diff --git a/import-layers/yocto-poky/scripts/lib/wic/plugins/source/rawcopy.py b/import-layers/yocto-poky/scripts/lib/wic/plugins/source/rawcopy.py index e0b11f95a..618dd4475 100644 --- a/import-layers/yocto-poky/scripts/lib/wic/plugins/source/rawcopy.py +++ b/import-layers/yocto-poky/scripts/lib/wic/plugins/source/rawcopy.py @@ -71,16 +71,16 @@ class RawCopyPlugin(SourcePlugin): dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], part.lineno)) if 'skip' in source_params: - sparse_copy(src, dst, skip=source_params['skip']) + sparse_copy(src, dst, skip=int(source_params['skip'])) else: sparse_copy(src, dst) # get the size in the right units for kickstart (kB) du_cmd = "du -Lbks %s" % dst out = exec_cmd(du_cmd) - filesize = out.split()[0] + filesize = int(out.split()[0]) - if int(filesize) > int(part.size): + if filesize > part.size: part.size = filesize part.source_file = dst diff --git a/import-layers/yocto-poky/scripts/lib/wic/utils/partitionedfs.py b/import-layers/yocto-poky/scripts/lib/wic/utils/partitionedfs.py index cb03009fc..9ea4a30cb 100644 --- a/import-layers/yocto-poky/scripts/lib/wic/utils/partitionedfs.py +++ b/import-layers/yocto-poky/scripts/lib/wic/utils/partitionedfs.py @@ -92,7 +92,7 @@ class Image(): def add_partition(self, size, disk_name, mountpoint, source_file=None, fstype=None, label=None, fsopts=None, boot=False, align=None, no_table=False, part_type=None, uuid=None, system_id=None): - """ Add the next partition. Prtitions have to be added in the + """ Add the next partition. Partitions have to be added in the first-to-last order. """ ks_pnum = len(self.partitions) @@ -201,9 +201,10 @@ class Image(): part['num'] = 0 if disk['ptable_format'] == "msdos": - if disk['realpart'] > 3: - part['type'] = 'logical' - part['num'] = disk['realpart'] + 1 + if len(self.partitions) > 4: + if disk['realpart'] > 3: + part['type'] = 'logical' + part['num'] = disk['realpart'] + 1 disk['partitions'].append(num) msger.debug("Assigned %s to %s%d, sectors range %d-%d size %d " @@ -292,7 +293,7 @@ class Image(): # even number of sectors. if part['mountpoint'] == "/boot" and part['fstype'] in ["vfat", "msdos"] \ and part['size'] % 2: - msger.debug("Substracting one sector from '%s' partition to " \ + msger.debug("Subtracting one sector from '%s' partition to " \ "get even number of sectors for the partition" % \ part['mountpoint']) part['size'] -= 1 |