Skip to content

Commit

Permalink
move right before the first mkdir
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Nov 8, 2024
1 parent ce3b6c7 commit 138616e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions constructor/header.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ if ! echo "$0" | grep '\.sh$' > /dev/null; then
return 1
fi

total_installation_size_kb="__TOTAL_INSTALLATION_SIZE_KB__"
free_disk_space_bytes="$(df -Pk "$PREFIX" | tail -n 1 | awk '{print $4}')"
free_disk_space_kb="$((free_disk_space_bytes / 1024))"
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 / 1024))" "$((total_installation_size_kb / 1024))" >&2
exit 1
fi

#if osx and min_osx_version
min_osx_version="__MIN_OSX_VERSION__"
system_osx_version=$(SYSTEM_VERSION_COMPAT=0 sw_vers -productVersion)
Expand Down Expand Up @@ -399,6 +389,16 @@ elif [ "$FORCE" = "1" ] && [ -e "$PREFIX" ]; then
REINSTALL=1
fi

total_installation_size_kb="__TOTAL_INSTALLATION_SIZE_KB__"
free_disk_space_bytes="$(df -Pk "$PREFIX" | tail -n 1 | awk '{print $4}')"
free_disk_space_kb="$((free_disk_space_bytes / 1024))"
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 / 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
exit 1
Expand Down

0 comments on commit 138616e

Please sign in to comment.