aboutsummaryrefslogtreecommitdiff
path: root/download
diff options
context:
space:
mode:
Diffstat (limited to 'download')
-rwxr-xr-xdownload57
1 files changed, 23 insertions, 34 deletions
diff --git a/download b/download
index 82f78945..3e003a38 100755
--- a/download
+++ b/download
@@ -4,6 +4,7 @@
# aren't distributed in the git repository.
#
# Copyright (C) 2014, 2015 Francis Rowe <info@gluglug.org.uk>
+# Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,40 +23,28 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
-download="./resources/scripts/helpers/download"
-programmes="unknown"
+download=./resources/scripts/helpers/download
+availableprogrammes=$(ls ${download}/)
-usage="./download programme(s) # programmes are space separated, if specifing multiple programmes"
-availableprogrammes="$(ls ${download}/)"
-
-# User specified no or too few/many parameters
-if [ $# -lt 1 ]; then
- printf "%s\n\n" "${usage}"
- printf "possible values for 'programmes':\nall:\n%s\n\n" "${availableprogrammes}"
- printf "Example (download everything): ./download all\n"
- printf "Example (download flashrom): ./download flashrom\n"
- printf "Example (download coreboot): ./download coreboot\n"
- printf "Example (download coreboot and flashrom): ./download coreboot flashrom\n"
- printf "Example (lists all available downloadable components): ./download list\n"
- exit 1
-fi
-programmes="$@"
-
-if [ "${programmes}" = "list" ]; then
- printf "Available programmes are:\nall\n%s\n" "${availableprogrammes}"
-elif [ "${programmes}" = "all" ]; then
- for programme in ${availableprogrammes}; do
- ${download}/${programme}
- done
-else
- for programme in ${programmes}; do
- printf "\"%s\"\n" "${programme}"
- if [ -f "${download}/${programme}" ]; then
+case ${@} in
+ all)
+ for programme in ${availableprogrammes}; do
${download}/${programme}
- else
- printf "download: WARNING: Invalid programme '%s'. Available programmes are:\nall\n%s\n" "${programmes}" "${availableprogrammes}"
- fi
- done
-fi
-
+ done;;
+ list)
+ printf "possible values for 'programmes':\nall:\n%s\n\n" "${availableprogrammes}";;
+ help)
+ printf "%s\n\n" "./download programme(s) # programmes are space separated, if specifing multiple programmes"
+ printf "possible values for 'programmes':\nall:\n%s\n\n" "${availableprogrammes}"
+ printf "Example (download everything): ./download all\n"
+ printf "Example (download flashrom): ./download flashrom\n"
+ printf "Example (download coreboot): ./download coreboot\n"
+ printf "Example (download coreboot and flashrom): ./download coreboot flashrom\n"
+ printf "Example (lists all available downloadable components): ./download list\n";;
+ *)
+ for programme in ${@}; do
+ echo ${availableprogrammes} | grep -wq ${programme} || (printf "ERROR: Invalid programme '${programme}'. See ./download help.\n"; exit 1)
+ done
+ ${download}/${@};;
+esac
# ------------------- DONE ----------------------