1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-21 14:45:07 +00:00

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.
This commit is contained in:
Linus Groh 2022-05-07 17:56:11 +02:00
parent 360e149c5c
commit 3d5645f07d

View file

@ -73,6 +73,7 @@ INODE_SIZE=128
INODE_COUNT=$(($(inode_usage "$SERENITY_SOURCE_DIR/Base") + $(inode_usage Root))) 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)) DISK_SIZE_BYTES=$((($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Root) + INODE_COUNT) * 1024))
if [ -z "$SERENITY_DISK_SIZE_BYTES" ]; then
# Try to use heuristics to guess a good disk size and inode count. # Try to use heuristics to guess a good disk size and inode count.
# The disk must notably fit: # The disk must notably fit:
# * Data blocks (for both files and directories), # * Data blocks (for both files and directories),
@ -81,6 +82,12 @@ DISK_SIZE_BYTES=$((($(disk_usage "$SERENITY_SOURCE_DIR/Base") + $(disk_usage Roo
# * Plenty of extra free space and free inodes. # * Plenty of extra free space and free inodes.
DISK_SIZE_BYTES=$(((DISK_SIZE_BYTES + (INODE_COUNT * INODE_SIZE * 2)) * 3)) DISK_SIZE_BYTES=$(((DISK_SIZE_BYTES + (INODE_COUNT * INODE_SIZE * 2)) * 3))
INODE_COUNT=$((INODE_COUNT * 7)) 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 USE_EXISTING=0