#!/bin/sh
#
# Copyright (C) 2014 Dream Property GmbH
#

source librecovery

usage()
{
	echo "Usage: ${0} [-hqtv] <A|B|C>"
	exit ${1}
}

xgetopts $@
shift $((${OPTIND} - 1))
[ "$#" -eq 1 ] || usage 1
OPTION=${1}

is_writable_blockdev "${MMC_DEVICE}" || abort "Target block device '${MMC_DEVICE}' is not a writable block device"
! is_empty "${OPTION}" || abort "No option given"

case "${OPTION}" in
	A|B|C)
		;;
	*)
		abort "Invalid boot option: ${OPTION}"
		;;
esac

select_boot_source "${MMC_DEVICE}" "${OPTION}" || abort "Failed to enable boot source"
