}
+check_for_free_space() {
+ local space=${1}
+ local path=${2}
+
+ # Space needs to passed in MB
+ # df returns bytes so we multiple by 1024²
+ space=$(( ${space} * 1024 * 1024 ))
+
+ if [[ $(df --output=avail ${path} | tail -n 1) -lt ${space} ]]; then
+ log error "Not enough free space available under ${path}"
+ log error "Free space is $(df -h -B MB --output=avail ${path} | tail -n 1) but we need at least $(( ${space} / 1024 / 1024 ))MB"
+ return ${EXIT_ERROR}
+ fi
+}
+
#
# General settings
#
# Check that pakfire is working
check_for_pakfire
+if ! check_for_free_space 10000 "${WORKING_DIR}"; then
+ exit ${EXIT_ERROR}
+fi
# Check that the image does not exist yet
if [ -f ${IMAGE_BASE_FILE} ]; then