55# it with the efi stub obtained from systemd-boot.
66# The layout of the image is described in a separate, customizable json file.
77
8- # A layout files is built accordingly to the following example:
9- # {
10- # "gpt_initial_offset_mb": 3, <- Space allocated for the 1st GPT
11- # "gpt_tail_padding_mb": 3, <- Space allocated for the 2nd GPT
12- # "primary_uefi_boot_partition": { <-- Name of the entry in the dictionary
13- # "name": "primary_uefi", <-- Name of the partition in the GPT (MAX 16 ch)
14- # "uuid": 0, <-- UUID of the partition, 0 means random
15- # "size_mb": 30, <-- Size of the partition in MB
16- # "source": "${S}/hdd/boot", <-- Directory containing the root for the partition
17- # "filesystem": "vfat", <-- Filesystem for the partition
18- # "type": "ef00" <-- Type of the partition, to be used in the GPT
19- # },
20- # [...] Iterate partitions as needed
21- # }
22- #
23- # The main rootfs partition is a special case and must be named "rootfs".
24- # This is required to identify it and pass its Partition UUID to the kernel, for booting.
25-
26-
278# By default, the full image is meant to fit into 4*10^9 bytes, i.e.
289# "4GB" regardless whether 1000 or 1024 is used as base. 64M are reserved
2910# for potential partitioning overhead.
@@ -49,16 +30,6 @@ do_uefiapp[depends] += " \
4930 ${INITRD_IMAGE} :do_image_complete \
5031 "
5132
52- IMAGE_DEPENDS_dsk += " \
53- gptfdisk-native:do_populate_sysroot \
54- parted-native:do_populate_sysroot \
55- mtools-native:do_populate_sysroot \
56- dosfstools-native:do_populate_sysroot \
57- dosfstools-native:do_populate_sysroot \
58- python-native:do_populate_sysroot \
59- bmap-tools-native:do_populate_sysroot \
60- "
61-
6233# Always ensure that the INITRD_IMAGE gets added to the initramfs .cpio.
6334# This needs to be done even when the actual .dsk image format is inactive,
6435# because the .cpio file gets copied into the rootfs, and that rootfs
@@ -77,35 +48,7 @@ REMOVABLE_MEDIA_ROOTFS_PARTUUID_VALUE ?= "deadbeef-dead-beef-dead-beefdeadbeef"
7748PARTITION_TYPE_EFI = "EF00"
7849PARTITION_TYPE_EFI_BACKUP = "2700"
7950
80- DSK_IMAGE_LAYOUT ??= ' \
81- { \
82- "gpt_initial_offset_mb": 3, \
83- "gpt_tail_padding_mb": 3, \
84- "partition_01_primary_uefi_boot": { \
85- "name": "primary_uefi", \
86- "uuid": 0, \
87- "size_mb": ${REFKIT_VFAT_MB} , \
88- "source": "${IMAGE_ROOTFS} /boot/", \
89- "filesystem": "vfat", \
90- "type": "${PARTITION_TYPE_EFI} " \
91- }, \
92- "partition_02_secondary_uefi_boot": { \
93- "name": "secondary_uefi", \
94- "uuid": 0, \
95- "size_mb": ${REFKIT_VFAT_MB} , \
96- "source": "${IMAGE_ROOTFS} /boot/", \
97- "filesystem": "vfat", \
98- "type": "${PARTITION_TYPE_EFI_BACKUP} " \
99- }, \
100- "partition_03_rootfs": { \
101- "name": "rootfs", \
102- "uuid": "${REMOVABLE_MEDIA_ROOTFS_PARTUUID_VALUE} ", \
103- "size_mb": 3700, \
104- "source": "${IMAGE_ROOTFS} ", \
105- "filesystem": "ext4", \
106- "type": "8300" \
107- } \
108- }'
51+ DSK_IMAGE_LAYOUT ??= '{}'
10952
11053inherit deploy
11154
@@ -140,9 +83,10 @@ export PART_%(pnum)d_FS=%(filesystem)s
14083 partition_table = json . loads (layout )
14184
14285 full_image_size_mb = partition_table ["gpt_initial_offset_mb" ] + \
143- partition_table ["gpt_tail_padding_mb" ]
86+ partition_table ["gpt_tail_padding_mb" ] \
87+ if partition_table else 0
14488
145- rootfs_type = None
89+ rootfs_type = ''
14690 pnum = 0
14791 for key in sorted (partition_table . keys ()):
14892 if not isinstance (partition_table [key ], dict ):
@@ -154,7 +98,7 @@ export PART_%(pnum)d_FS=%(filesystem)s
15498 partition_table [key ]['uuid' ] = str (uuid . uuid4 ())
15599 # Store these for the creation of the UEFI binary
156100 if partition_table [key ]['name' ] == 'rootfs' :
157- rootfs_type = partition_table [key ]['filesystem' ]
101+ rootfs_type = 'rootfstype=%s ' % partition_table [key ]['filesystem' ]
158102 int_part_uuid = d . getVar ('INT_STORAGE_ROOTFS_PARTUUID_VALUE' , True )
159103 else :
160104 int_part_uuid = partition_table [key ]["uuid" ]
@@ -168,8 +112,8 @@ export PART_%(pnum)d_FS=%(filesystem)s
168112 }
169113 pnum = pnum + 1
170114
171- assert rootfs_type is not None
172- partition_data += "export PART_COUNT=%d\n" % pnum
115+ if pnum > 0 :
116+ partition_data += "export PART_COUNT=%d\n" % pnum
173117
174118 if os . path . exists (d . expand ('${B} /initrd' )):
175119 os . remove (d . expand ('${B} /initrd' ))
@@ -188,7 +132,7 @@ export PART_%(pnum)d_FS=%(filesystem)s
188132
189133 def generate_app (partuuid , cmdline , suffix ):
190134 with open (d . expand ('${B} /cmdline' + suffix + '.txt' ), 'w' ) as f :
191- f . write (d . expand ('${APPEND} root=PARTUUID=%s rootfstype=%s %s' % \
135+ f . write (d . expand ('${APPEND} root=PARTUUID=%s %s %s' % \
192136 (partuuid , rootfs_type , cmdline )))
193137 check_call (d . expand ('objcopy ' +
194138 '--add-section .osrel=${B} /machine.txt ' +
@@ -209,9 +153,10 @@ export PART_%(pnum)d_FS=%(filesystem)s
209153 generate_app (d . getVar ('REMOVABLE_MEDIA_ROOTFS_PARTUUID_VALUE' , True ), "installer" , "" )
210154 generate_app (d . getVar ('INT_STORAGE_ROOTFS_PARTUUID_VALUE' , True ), "" , "_internal_storage" )
211155
212- with open (d . expand ('${B} /emmc-partitions-data' ), 'w' ) as emmc_part_data :
213- emmc_part_data . write (partition_data )
214- shutil . copyfile (d . expand ('${B} /emmc-partitions-data' ), d . expand ('${DEPLOYDIR} /emmc-partitions-data' ))
156+ if partition_data :
157+ with open (d . expand ('${B} /emmc-partitions-data' ), 'w' ) as emmc_part_data :
158+ emmc_part_data . write (partition_data )
159+ shutil . copyfile (d . expand ('${B} /emmc-partitions-data' ), d . expand ('${DEPLOYDIR} /emmc-partitions-data' ))
215160
216161 # The RMC database is deployed unconditionally but not read if the BIOS is in SecureBoot mode.
217162 # XXX: However, the check for SecureBoot is not present. The bug is tracked in
@@ -280,21 +225,3 @@ do_rootfs[depends] += '${@bb.utils.contains('IMAGE_FEATURES','secureboot','sbsig
280225
281226ROOTFS_POSTPROCESS_COMMAND += " ${@ bb . utils . contains ('IMAGE_FEATURES' , 'secureboot' , 'uefiapp_sign;' , '' , d )} "
282227ROOTFS_POSTPROCESS_COMMAND += " uefiapp_deploy; "
283-
284- # All variables explicitly passed to image-dsk.py.
285- IMAGE_DSK_VARIABLES = " \
286- APPEND \
287- IMGDEPLOYDIR \
288- DSK_IMAGE_LAYOUT \
289- IMAGE_LINK_NAME \
290- IMAGE_NAME \
291- IMAGE_ROOTFS \
292- ROOTFS_TYPE \
293- REMOVABLE_MEDIA_ROOTFS_PARTUUID_VALUE \
294- PARTITION_TYPE_EFI \
295- PARTITION_TYPE_EFI_BACKUP \
296- S \
297- "
298-
299- IMAGE_CMD_dsk = "${PYTHON} ${IMAGE_DSK_BASE} /lib/image-dsk.py ${@ ' ' . join (["'%s=%s'" % (x , d . getVar (x , True ) or '' ) for x in d . getVar ('IMAGE_DSK_VARIABLES' , True ). split ()])}"
300- IMAGE_CMD_dsk [vardeps ] = "${IMAGE_DSK_VARIABLES} "
0 commit comments