123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #!/usr/bin/env bash
- ./.gitcheck
- [ "x${DEBUG+set}" = 'xset' ] && set -v
- set -u -e
- ./resources/scripts/misc/versioncheck
- deletegit="true"
- deleteblobs="true"
- if [ "x${NODELETE+set}" = 'xset' ]; then
- [ "x${NODELETE:-all}" = "xgit" ] && deletegit="false"
- [ "x${NODELETE:-all}" = "xall" ] && deleteblobs="false" && deletegit="false"
- fi
- rm -f "build_error"
- download=resources/scripts/download
- listprograms() {
- for program in "${download}"/*; do
- printf '%s\n' "${program##*/}"
- done
- }
- help() {
- cat <<- EOF
- USAGE: ./download <PROGRAM> <OPTIONS>
- 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
- }
- die() {
- printf 'Error: %s\n' "${@}" 1>&2
- exit 1
- }
- 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 [ "${deleteblobs}" = "false" ]; then
- NODELETE= "${downloadProgram}"
- elif [ "${deletegit}" = "false" ]; then
- NODELETE=git "${downloadProgram}"
- else
- "${downloadProgram}"
- fi
- fi
- done
- exit 0
- elif [ ! -f "${download}/${program}" ]; then
- help
- die "Invalid argument '${program}'. See: './download help'."
- fi
- if [ $# -lt 1 ]; then
- if [ "${deleteblobs}" = "false" ]; then
- NODELETE= "${download}/${program}"
- elif [ "${deletegit}" = "false" ]; then
- NODELETE=git "${download}/${program}"
- else
- "${download}/${program}"
- fi
- else
- if [ "${deleteblobs}" = "false" ]; then
- NODELETE= "${download}/${program}" $@
- elif [ "${deletegit}" = "false" ]; then
- NODELETE=git "${download}/${program}" $@
- else
- "${download}/${program}" $@
- fi
- fi
- exit 0
- ./.gitcheck clean
|