From 3d5645f07d74fa247323b54a84e12c13f89a7a27 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 7 May 2022 17:56:11 +0200 Subject: [PATCH] Meta: Allow overriding the default calculated _disk_image size By providing SERENITY_DISK_SIZE_BYTES as an environment variable, the calculation of default value considered suitable for the size of files and number of inodes that will be included can be sidestepped. --- Meta/build-image-qemu.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Meta/build-image-qemu.sh b/Meta/build-image-qemu.sh index 594049906f..6b58ac900a 100755 --- a/Meta/build-image-qemu.sh +++ b/Meta/build-image-qemu.sh @@ -73,14 +73,21 @@ INODE_SIZE=128 INODE_COUNT=$(($(inode_usage "$SERENITY_SOURCE_DIR/Base") + $(inode_usage Root))) DISK_SIZE_BYTES=$((($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) + INODE_COUNT) * 1024)) -# Try to use heuristics to guess a good disk size and inode count. -# The disk must notably fit: -# * Data blocks (for both files and directories), -# * Indirect/doubly indirect/triply indirect blocks, -# * Inodes and block bitmaps for each block group, -# * Plenty of extra free space and free inodes. -DISK_SIZE_BYTES=$(((DISK_SIZE_BYTES + (INODE_COUNT * INODE_SIZE * 2)) * 3)) -INODE_COUNT=$((INODE_COUNT * 7)) +if [ -z "$SERENITY_DISK_SIZE_BYTES" ]; then + # Try to use heuristics to guess a good disk size and inode count. + # The disk must notably fit: + # * Data blocks (for both files and directories), + # * Indirect/doubly indirect/triply indirect blocks, + # * Inodes and block bitmaps for each block group, + # * Plenty of extra free space and free inodes. + DISK_SIZE_BYTES=$(((DISK_SIZE_BYTES + (INODE_COUNT * INODE_SIZE * 2)) * 3)) + INODE_COUNT=$((INODE_COUNT * 7)) +else + if [ "$DISK_SIZE_BYTES" -gt "$SERENITY_DISK_SIZE_BYTES" ]; then + die "SERENITY_DISK_SIZE_BYTES is set to $SERENITY_DISK_SIZE_BYTES but required disk size is $DISK_SIZE_BYTES bytes" + fi + DISK_SIZE_BYTES="$SERENITY_DISK_SIZE_BYTES" +fi USE_EXISTING=0