From 96a488d7a805cfb8e63fb2530c5e2eb00d4bf92a Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Tue, 27 Oct 2015 18:23:13 -0400 Subject: do_update(): Partially implement dist and mirror selection --- (limited to 'src/action/update.sh') diff --git a/src/action/update.sh b/src/action/update.sh index d18c029..5db6230 100644 --- a/src/action/update.sh +++ b/src/action/update.sh @@ -17,9 +17,46 @@ do_update() { + local dists='' + local i=0 + local dist='' + local mirror_url='' + local mirror_label='' + local mirror_urls='' + info 'Updating firmware' + # Probe for board and chip. if ! flashrom_probe; then return 1 fi + + # Select distributor. + # TODO: Show names in menu labels. + dists="$(board_get_dists)" + if [ $(printf '%s' "${dists}" | wc -w | cut -d ' ' -f 1) -gt 1 ]; then + i=$(show_menu 'Select a firmware distributor' ${dists}) + i=$(($i + 1)) + dist="$(printf '%s ' ${dists} | cut -d ' ' -f ${i})" + else + dist="$(printf '%s' ${dists})" + fi + select_dist "${dist}" + info 'Distributor: %s' "${dist}" + + # Select mirror. + # TODO: Handle show_menu() output. + set -- + while :; do + if ! read -r mirror_url || ! read -r mirror_label; then + break + fi + mirror_urls="${mirror_urls} ${mirror_url}" + set -- "${@}" "${mirror_label}" + done <<-EOF + $(dist_get_mirrors) + EOF + show_menu 'Select a mirror' "${@}" + + return 0 } -- cgit v0.9.1