validateswap() {
# Validate system swap if SM_SWAPCHECK is defined and set to 1
  if [ -n "$SM_SWAPCHECK" ] && [ "$SM_SWAPCHECK" = "1" ]; then
    if inarray "${APP}" "${SM_PACKAGESREQUIRINGSWAP[@]}" ; then    
 
      # Here we determine available system swap size needed to compile exceptional packages that pull in a lot of RAM.
      # Those packages are listed under the SM_PACKAGESREQUIRINGSWAP array in /etc/bldpkg.conf. Check whether swap
      #is available on the system and if it is, determine its size. If its size is >= SM_SWAPSIZE, we are all good.
      #If it's less than SM_SWAPSIZE, we exit with a status 1.

      SM_SWAPCHECK="$(grep "SwapFree" /proc/meminfo | awk '{print $2}')"
      if [ "$SM_SWAPCHECK" -lt "$SM_SWAPSIZE" ]; then
        echo "[ERROR] Insufficient swap to build '"$APP"' which is listed"
        echo "[ERROR] in $SM_PACKAGESREQUIRINGSWAP. Kindly add/increase"
        echo "[ERROR] swap size on this system and try again. Aborting!"
        exit 1
      fi
    fi
  fi
}
