123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- #!/usr/bin/env bash
- ./$(dirname $0)/.gitcheck
- [ "x${DEBUG+set}" = 'xset' ] && set -v
- set -u -e
- $(dirname $0)/resources/scripts/misc/versioncheck
- deleteblobs="true"
- [ "x${NODELETE+set}" = 'xset' ] && deleteblobs="false"
- rm -f "build_error"
- download="$(dirname $0)/resources/scripts/download"
- extra_dir=""
- listprograms() {
- for program in "${download}"/*; do
- printf '%s\n' "${program##*/}"
- done
- if [ "${extra_dir}" != "" ] ; then
- for program in ${extra_dir}/resources/scripts/download/*; do
- if [ -f "${download}/${program}" ] ; then
- continue
- fi
- printf '%s\n' "${program##*/}"
- done
- fi
- }
- help() {
-
-
-
-
-
-
- if [ "${extra_dir}" == "" ] ; then
- echo "USAGE: ./download [--include-extra-dir <PATH>] <PROGRAM> <OPTIONS>"
- else
- echo "USAGE: ./download <PROGRAM> <OPTIONS>"
- fi
- cat <<- EOF
- possible values for 'program':
- $(listprograms)
- Example: ./download flashrom
- Example: ./download coreboot
- Some program options allow for additional parameters:
- Example: ./download coreboot default
- Example: ./download coreboot x60
- Each program download script should work without extra paramaters, but
- they can use them. For instance, './download coreboot' will download all
- coreboot trees by default, but './download coreboot x60' will only download
- the coreboot tree required for the target: x60
- Each program download script should also accept the --help paramater to
- display the usage of the script.
- Refer to the documentation for more information.
- EOF
- if [ "${extra_dir}" == "" ] ; then
- cat <<- EOF
- --include-extra-dir PATH makes download also look for scripts
- in PATH/resources/scripts/download/. If a script of the same
- name exist in both PATH/resources/scripts/download/ and
- resources/scripts/download/, the first one will be preffered.
- Example: ./download --include-extra-dir ../mydir coreboot
- EOF
- fi
- }
- die() {
- printf 'Error: %s\n' "${@}" 1>&2
- exit 1
- }
- run_download_program() {
- path="$1"
- shift 1
- if [ "${deleteblobs}" = "false" ]; then
- NODELETE= "${path}" $@
- else
- "${path}" $@
- fi
- }
- if [ $# -gt 1 ] && [ "$1" = "--include-extra-dir" ] ; then
- if [ $# -lt 2 ]; then
- die "Missing PATH for --include-extra-dir"
- else
- extra_dir="$2"
- shift 2
- fi
- fi
- if [ $# -lt 1 ]; then
- help
- die "Please specify arguments."
- fi
- program="${1}"
- shift 1
- [ "${program}" = help ] && help && exit 0
- if [ "${program}" = "all" ]; then
- for downloadProgram in ${download}/*; do
- if [ -f "${downloadProgram}" ]; then
-
-
-
-
- if [ "${extra_dir}" != "" ] && \
- [ -f "${extra_dir}/${downloadProgram}" ] ; then
- continue
- fi
- run_download_program "${downloadProgram}"
- fi
- done
- for downloadProgram in ${extra_dir}/resources/scripts/download/*; do
- if [ -f "${downloadProgram}" ]; then
- run_download_program "${downloadProgram}"
- fi
- done
- exit 0
- elif [ ! -f "${download}/${program}" ] && \
- [ ! -f "${extra_dir}//resources/scripts/download/${program}" ]; then
- help
- die "Invalid argument '${program}'. See: './download help'."
- fi
- if [ "${extra_dir}" != "" ] && \
- [ -f "${extra_dir}//resources/scripts/download/${program}" ] ; then
- run_download_program "${extra_dir}/resources/scripts/download/${program}" $@
- else
- run_download_program "${download}/${program}" $@
- fi
- exit 0
- ./$(dirname $0)/.gitcheck clean
|