get_platform_dir () {
  local release_dir=$1
  local platform_dir_candidates=("platform_open_sources" "platform-release_open_sources" "platform_release_open_sources")
  
  for candidate in "${platform_dir_candidates[@]}"; do
    platform_dir=$(ls "$release_dir" | grep "$candidate")
    if [ -n "$platform_dir" ]; then
      break
    fi
  done

  if [ -z "$platform_dir" ]; then
      echo "No platform dir found. Exiting..."
      exit 1
  fi
  
  platform_dir="$release_dir/$platform_dir"
}

get_uboot_dir () {
  local platform_dir=$1

  uboot_dir="$platform_dir/u-boot"
 
  if [ ! -d "$uboot_dir" ]; then
    uboot_dir="$platform_dir/bootable/bootloader/u-boot-1.3.4"

    if [ ! -d "$uboot_dir" ]; then
      echo "No uboot dir found. Exiting..."
      exit 1
    fi
  fi
}