Skip to content

Commit 6f12ab3

Browse files
petelliottawesomekling
authored andcommitted
Meta: Calculate image size based on size of Build/Root and Base
This reduces the size of the default build, while allowing people to install as many ports as they want, without having to manually specify disk size.
1 parent 99ddbb8 commit 6f12ab3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Meta/build-image-grub.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ if [ -z "$grub" ]; then
2323
fi
2424
echo "using grub-install at ${grub}"
2525

26+
disk_usage() {
27+
du -sm $1 | cut -f1
28+
}
29+
30+
DISK_SIZE=$(($(disk_usage "$SERENITY_ROOT/Base") + $(disk_usage Root) + 300))
31+
2632
echo "setting up disk image..."
2733
dd if=/dev/zero of=grub_disk_image bs=1M count="${DISK_SIZE:-800}" status=none || die "couldn't create disk image"
2834
chown "$SUDO_UID":"$SUDO_GID" grub_disk_image || die "couldn't adjust permissions on disk image"

Meta/build-image-qemu.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ if [ "$(uname -s)" = "Darwin" ]; then
1717
export PATH="/usr/local/opt/e2fsprogs/bin:$PATH"
1818
export PATH="/usr/local/opt/e2fsprogs/sbin:$PATH"
1919
fi
20+
21+
disk_usage() {
22+
du -sm $1 | cut -f1
23+
}
24+
25+
DISK_SIZE=$(($(disk_usage "$SERENITY_ROOT/Base") + $(disk_usage Root) + 100))
26+
2027
echo "setting up disk image..."
2128
qemu-img create _disk_image "${DISK_SIZE:-600}"m || die "could not create disk image"
2229
chown "$SUDO_UID":"$SUDO_GID" _disk_image || die "could not adjust permissions on disk image"

0 commit comments

Comments
 (0)