summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2015-10-27 18:23:13 (EDT)
committer P. J. McDermott <pj@pehjota.net>2015-10-27 18:23:13 (EDT)
commit96a488d7a805cfb8e63fb2530c5e2eb00d4bf92a (patch)
tree6d3872af12f8cc5efc054eff4d2ca6cec722b046
parent59bf6d52283c1f655c15e30dbb744350a33a1041 (diff)
downloadfirman.sh-96a488d7a805cfb8e63fb2530c5e2eb00d4bf92a.zip
firman.sh-96a488d7a805cfb8e63fb2530c5e2eb00d4bf92a.tar.gz
firman.sh-96a488d7a805cfb8e63fb2530c5e2eb00d4bf92a.tar.bz2
do_update(): Partially implement dist and mirror selection
-rw-r--r--src/action/update.sh37
1 files changed, 37 insertions, 0 deletions
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
}