summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2013-09-14 00:08:57 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-09-17 14:35:17 +0100
commitc78c1f9c92a2c2b38699a732ad893b669ccefcda (patch)
treecbaeb13c340c0dca48c5af07ec71bb45b40c71b6 /meta
parent238e9b54e228b850434f7d503870e86cfb12b775 (diff)
downloadpoky-c78c1f9c92a2c2b38699a732ad893b669ccefcda.tar.gz
bootimage.bbclass: Move fat image creation into a function
In order to call the fat image creation multiple times it needs to be in its own function. A future commit will make use of the new function to additionally create EFI image files for use with an ISO. [YOCTO #4100] [YOCTO #1913] (From OE-Core rev: 6d5181dc68766f42416a41f4988e8400d37fd7fa) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/bootimg.bbclass110
1 files changed, 58 insertions, 52 deletions
diff --git a/meta/classes/bootimg.bbclass b/meta/classes/bootimg.bbclass
index 90a241d9b3..bd211fbdc3 100644
--- a/meta/classes/bootimg.bbclass
+++ b/meta/classes/bootimg.bbclass
@@ -111,6 +111,63 @@ build_iso() {
111 ln -s ${IMAGE_NAME}.iso ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.iso 111 ln -s ${IMAGE_NAME}.iso ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.iso
112} 112}
113 113
114build_fat_img() {
115 FATSOURCEDIR=$1
116 FATIMG=$2
117
118 # Calculate the size required for the final image including the
119 # data and filesystem overhead.
120 # Sectors: 512 bytes
121 # Blocks: 1024 bytes
122
123 # Determine the sector count just for the data
124 SECTORS=$(expr $(du --apparent-size -ks ${FATSOURCEDIR} | cut -f 1) \* 2)
125
126 # Account for the filesystem overhead. This includes directory
127 # entries in the clusters as well as the FAT itself.
128 # Assumptions:
129 # FAT32 (12 or 16 may be selected by mkdosfs, but the extra
130 # padding will be minimal on those smaller images and not
131 # worth the logic here to caclulate the smaller FAT sizes)
132 # < 16 entries per directory
133 # 8.3 filenames only
134
135 # 32 bytes per dir entry
136 DIR_BYTES=$(expr $(find ${FATSOURCEDIR} | tail -n +2 | wc -l) \* 32)
137 # 32 bytes for every end-of-directory dir entry
138 DIR_BYTES=$(expr $DIR_BYTES + $(expr $(find ${FATSOURCEDIR} -type d | tail -n +2 | wc -l) \* 32))
139 # 4 bytes per FAT entry per sector of data
140 FAT_BYTES=$(expr $SECTORS \* 4)
141 # 4 bytes per FAT entry per end-of-cluster list
142 FAT_BYTES=$(expr $FAT_BYTES + $(expr $(find ${FATSOURCEDIR} -type d | tail -n +2 | wc -l) \* 4))
143
144 # Use a ceiling function to determine FS overhead in sectors
145 DIR_SECTORS=$(expr $(expr $DIR_BYTES + 511) / 512)
146 # There are two FATs on the image
147 FAT_SECTORS=$(expr $(expr $(expr $FAT_BYTES + 511) / 512) \* 2)
148 SECTORS=$(expr $SECTORS + $(expr $DIR_SECTORS + $FAT_SECTORS))
149
150 # Determine the final size in blocks accounting for some padding
151 BLOCKS=$(expr $(expr $SECTORS / 2) + ${BOOTIMG_EXTRA_SPACE})
152
153 # Ensure total sectors is an integral number of sectors per
154 # track or mcopy will complain. Sectors are 512 bytes, and we
155 # generate images with 32 sectors per track. This calculation is
156 # done in blocks, thus the mod by 16 instead of 32.
157 BLOCKS=$(expr $BLOCKS + $(expr 16 - $(expr $BLOCKS % 16)))
158
159 # mkdosfs will sometimes use FAT16 when it is not appropriate,
160 # resulting in a boot failure from SYSLINUX. Use FAT32 for
161 # images larger than 512MB, otherwise let mkdosfs decide.
162 if [ $(expr $BLOCKS / 1024) -gt 512 ]; then
163 FATSIZE="-F 32"
164 fi
165
166 mkdosfs ${FATSIZE} -n ${BOOTIMG_VOLUME_ID} -S 512 -C ${FATIMG} ${BLOCKS}
167 # Copy FATSOURCEDIR recursively into the image file directly
168 mcopy -i ${FATIMG} -s ${FATSOURCEDIR}/* ::/
169}
170
114build_hddimg() { 171build_hddimg() {
115 # Create an HDD image 172 # Create an HDD image
116 if [ "${NOHDD}" != "1" ] ; then 173 if [ "${NOHDD}" != "1" ] ; then
@@ -123,58 +180,7 @@ build_hddimg() {
123 grubefi_hddimg_populate 180 grubefi_hddimg_populate
124 fi 181 fi
125 182
126 # Calculate the size required for the final image including the 183 build_fat_img ${HDDDIR} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
127 # data and filesystem overhead.
128 # Sectors: 512 bytes
129 # Blocks: 1024 bytes
130
131 # Determine the sector count just for the data
132 SECTORS=$(expr $(du --apparent-size -ks ${HDDDIR} | cut -f 1) \* 2)
133
134 # Account for the filesystem overhead. This includes directory
135 # entries in the clusters as well as the FAT itself.
136 # Assumptions:
137 # FAT32 (12 or 16 may be selected by mkdosfs, but the extra
138 # padding will be minimal on those smaller images and not
139 # worth the logic here to caclulate the smaller FAT sizes)
140 # < 16 entries per directory
141 # 8.3 filenames only
142
143 # 32 bytes per dir entry
144 DIR_BYTES=$(expr $(find ${HDDDIR} | tail -n +2 | wc -l) \* 32)
145 # 32 bytes for every end-of-directory dir entry
146 DIR_BYTES=$(expr $DIR_BYTES + $(expr $(find ${HDDDIR} -type d | tail -n +2 | wc -l) \* 32))
147 # 4 bytes per FAT entry per sector of data
148 FAT_BYTES=$(expr $SECTORS \* 4)
149 # 4 bytes per FAT entry per end-of-cluster list
150 FAT_BYTES=$(expr $FAT_BYTES + $(expr $(find ${HDDDIR} -type d | tail -n +2 | wc -l) \* 4))
151
152 # Use a ceiling function to determine FS overhead in sectors
153 DIR_SECTORS=$(expr $(expr $DIR_BYTES + 511) / 512)
154 # There are two FATs on the image
155 FAT_SECTORS=$(expr $(expr $(expr $FAT_BYTES + 511) / 512) \* 2)
156 SECTORS=$(expr $SECTORS + $(expr $DIR_SECTORS + $FAT_SECTORS))
157
158 # Determine the final size in blocks accounting for some padding
159 BLOCKS=$(expr $(expr $SECTORS / 2) + ${BOOTIMG_EXTRA_SPACE})
160
161 # Ensure total sectors is an integral number of sectors per
162 # track or mcopy will complain. Sectors are 512 bytes, and we
163 # generate images with 32 sectors per track. This calculation is
164 # done in blocks, thus the mod by 16 instead of 32.
165 BLOCKS=$(expr $BLOCKS + $(expr 16 - $(expr $BLOCKS % 16)))
166
167 # mkdosfs will sometimes use FAT16 when it is not appropriate,
168 # resulting in a boot failure from SYSLINUX. Use FAT32 for
169 # images larger than 512MB, otherwise let mkdosfs decide.
170 if [ $(expr $BLOCKS / 1024) -gt 512 ]; then
171 FATSIZE="-F 32"
172 fi
173
174 IMG=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
175 mkdosfs ${FATSIZE} -n ${BOOTIMG_VOLUME_ID} -S 512 -C ${IMG} ${BLOCKS}
176 # Copy HDDDIR recursively into the image file directly
177 mcopy -i ${IMG} -s ${HDDDIR}/* ::/
178 184
179 if [ "${PCBIOS}" = "1" ]; then 185 if [ "${PCBIOS}" = "1" ]; then
180 syslinux_hddimg_install 186 syslinux_hddimg_install