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>
This commit is contained in:
parent
238e9b54e2
commit
c78c1f9c92
|
@ -111,17 +111,9 @@ build_iso() {
|
|||
ln -s ${IMAGE_NAME}.iso ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.iso
|
||||
}
|
||||
|
||||
build_hddimg() {
|
||||
# Create an HDD image
|
||||
if [ "${NOHDD}" != "1" ] ; then
|
||||
populate ${HDDDIR}
|
||||
|
||||
if [ "${PCBIOS}" = "1" ]; then
|
||||
syslinux_hddimg_populate
|
||||
fi
|
||||
if [ "${EFI}" = "1" ]; then
|
||||
grubefi_hddimg_populate
|
||||
fi
|
||||
build_fat_img() {
|
||||
FATSOURCEDIR=$1
|
||||
FATIMG=$2
|
||||
|
||||
# Calculate the size required for the final image including the
|
||||
# data and filesystem overhead.
|
||||
|
@ -129,7 +121,7 @@ build_hddimg() {
|
|||
# Blocks: 1024 bytes
|
||||
|
||||
# Determine the sector count just for the data
|
||||
SECTORS=$(expr $(du --apparent-size -ks ${HDDDIR} | cut -f 1) \* 2)
|
||||
SECTORS=$(expr $(du --apparent-size -ks ${FATSOURCEDIR} | cut -f 1) \* 2)
|
||||
|
||||
# Account for the filesystem overhead. This includes directory
|
||||
# entries in the clusters as well as the FAT itself.
|
||||
|
@ -141,13 +133,13 @@ build_hddimg() {
|
|||
# 8.3 filenames only
|
||||
|
||||
# 32 bytes per dir entry
|
||||
DIR_BYTES=$(expr $(find ${HDDDIR} | tail -n +2 | wc -l) \* 32)
|
||||
DIR_BYTES=$(expr $(find ${FATSOURCEDIR} | tail -n +2 | wc -l) \* 32)
|
||||
# 32 bytes for every end-of-directory dir entry
|
||||
DIR_BYTES=$(expr $DIR_BYTES + $(expr $(find ${HDDDIR} -type d | tail -n +2 | wc -l) \* 32))
|
||||
DIR_BYTES=$(expr $DIR_BYTES + $(expr $(find ${FATSOURCEDIR} -type d | tail -n +2 | wc -l) \* 32))
|
||||
# 4 bytes per FAT entry per sector of data
|
||||
FAT_BYTES=$(expr $SECTORS \* 4)
|
||||
# 4 bytes per FAT entry per end-of-cluster list
|
||||
FAT_BYTES=$(expr $FAT_BYTES + $(expr $(find ${HDDDIR} -type d | tail -n +2 | wc -l) \* 4))
|
||||
FAT_BYTES=$(expr $FAT_BYTES + $(expr $(find ${FATSOURCEDIR} -type d | tail -n +2 | wc -l) \* 4))
|
||||
|
||||
# Use a ceiling function to determine FS overhead in sectors
|
||||
DIR_SECTORS=$(expr $(expr $DIR_BYTES + 511) / 512)
|
||||
|
@ -171,10 +163,24 @@ build_hddimg() {
|
|||
FATSIZE="-F 32"
|
||||
fi
|
||||
|
||||
IMG=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
|
||||
mkdosfs ${FATSIZE} -n ${BOOTIMG_VOLUME_ID} -S 512 -C ${IMG} ${BLOCKS}
|
||||
# Copy HDDDIR recursively into the image file directly
|
||||
mcopy -i ${IMG} -s ${HDDDIR}/* ::/
|
||||
mkdosfs ${FATSIZE} -n ${BOOTIMG_VOLUME_ID} -S 512 -C ${FATIMG} ${BLOCKS}
|
||||
# Copy FATSOURCEDIR recursively into the image file directly
|
||||
mcopy -i ${FATIMG} -s ${FATSOURCEDIR}/* ::/
|
||||
}
|
||||
|
||||
build_hddimg() {
|
||||
# Create an HDD image
|
||||
if [ "${NOHDD}" != "1" ] ; then
|
||||
populate ${HDDDIR}
|
||||
|
||||
if [ "${PCBIOS}" = "1" ]; then
|
||||
syslinux_hddimg_populate
|
||||
fi
|
||||
if [ "${EFI}" = "1" ]; then
|
||||
grubefi_hddimg_populate
|
||||
fi
|
||||
|
||||
build_fat_img ${HDDDIR} ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
|
||||
|
||||
if [ "${PCBIOS}" = "1" ]; then
|
||||
syslinux_hddimg_install
|
||||
|
|
Loading…
Reference in New Issue