Skip to content

Commit

Permalink
move again
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Nov 8, 2024
1 parent 0b834f0 commit 4aff6e2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions constructor/header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,18 @@ elif [ "$FORCE" = "1" ] && [ -e "$PREFIX" ]; then
fi

total_installation_size_kb="__TOTAL_INSTALLATION_SIZE_KB__"
total_installation_size_mb="$(( total_installation_size_kb / 1024 ))"
if ! mkdir -p "$PREFIX"; then
printf "ERROR: Could not create directory: '%s'.\\n" "$PREFIX" >&2
printf "Check permissions and available disk space (%s MB needed).\\n" "$total_installation_size_mb" >&2
exit 1
fi

free_disk_space_kb="$(df -Pk "$PREFIX" | tail -n 1 | awk '{print $4}')"
free_disk_space_kb_with_buffer="$((free_disk_space_kb - 50 * 1024))" # add 50MB of buffer
if [ "$free_disk_space_kb_with_buffer" -lt "$total_installation_size_kb" ]; then
printf "ERROR: Not enough free disk space. Only %s MB are available, but %s MB are required (leaving a 50 MB buffer).\\n" \
"$((free_disk_space_kb_with_buffer / 1024))" "$((total_installation_size_kb / 1024))" >&2
exit 1
fi

if ! mkdir -p "$PREFIX"; then
printf "ERROR: Could not create directory: '%s'\\n" "$PREFIX" >&2
"$((free_disk_space_kb_with_buffer / 1024))" "$total_installation_size_mb" >&2
exit 1
fi

Expand Down

0 comments on commit 4aff6e2

Please sign in to comment.