Skip to content

Commit

Permalink
Meta: Calculate image size based on size of Build/Root and Base
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
petelliott authored and awesomekling committed Jul 28, 2020
1 parent 99ddbb8 commit 6f12ab3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Meta/build-image-grub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ if [ -z "$grub" ]; then
fi
echo "using grub-install at ${grub}"

disk_usage() {
du -sm $1 | cut -f1
}

DISK_SIZE=$(($(disk_usage "$SERENITY_ROOT/Base") + $(disk_usage Root) + 300))

echo "setting up disk image..."
dd if=/dev/zero of=grub_disk_image bs=1M count="${DISK_SIZE:-800}" status=none || die "couldn't create disk image"
chown "$SUDO_UID":"$SUDO_GID" grub_disk_image || die "couldn't adjust permissions on disk image"
Expand Down
7 changes: 7 additions & 0 deletions Meta/build-image-qemu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ if [ "$(uname -s)" = "Darwin" ]; then
export PATH="/usr/local/opt/e2fsprogs/bin:$PATH"
export PATH="/usr/local/opt/e2fsprogs/sbin:$PATH"
fi

disk_usage() {
du -sm $1 | cut -f1
}

DISK_SIZE=$(($(disk_usage "$SERENITY_ROOT/Base") + $(disk_usage Root) + 100))

echo "setting up disk image..."
qemu-img create _disk_image "${DISK_SIZE:-600}"m || die "could not create disk image"
chown "$SUDO_UID":"$SUDO_GID" _disk_image || die "could not adjust permissions on disk image"
Expand Down

0 comments on commit 6f12ab3

Please sign in to comment.