Commit 3c506aa5 authored by Natanael Copa's avatar Natanael Copa

setup-bootable: use stat to calculate needed disk space

parent a3dd3912
...@@ -136,11 +136,16 @@ fi ...@@ -136,11 +136,16 @@ fi
rm -rf "$destdir"/.new "$destdir"/.old rm -rf "$destdir"/.new "$destdir"/.old
# check that we have the space we need # check that we have the space we need
needed_space=$(cd "$srcdir" && du -s -c boot apks syslinux.cfg .alpine-release | awk '$2 == "total" {print $1}') # we calculate on MB since shell arthimetic gets problems with big disks
[ -n "$verbose" ] && echo "Needed space: $needed_space kB" # and bytes.
needed_space=$(cd "$srcdir" && du -m -s -c boot apks syslinux.cfg .alpine-release | awk '$2 == "total" {print $1}')
available_space=$(df -k "$destdir" | tail -n 1 | awk '{print $4}') [ -n "$verbose" ] && echo "Needed space: $needed_space MiB"
[ -n "$verbose" ] && echo "Available space: $available_space kB"
free_blocks=$(stat -f -c "%f" "$destdir")
block_size=$(stat -f -c "%s" "$destdir")
blocks_per_mb=$(( 1024 * 1024 / $block_size))
available_space=$(( $free_blocks / $blocks_per_mb ))
[ -n "$verbose" ] && echo "Available space: $available_space MiB"
[ $available_space -lt $needed_space ] && die "Not enough space on $destdir. Aborting." [ $available_space -lt $needed_space ] && die "Not enough space on $destdir. Aborting."
# copy the files to .new # copy the files to .new
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment