123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #!/bin/bash
- # Generic script for downloading programs used by the build system
- #
- # Copyright (C) 2014, 2015, 2020, 2021 Leah Rowe <info@minifree.org>
- # Copyright (C) 2015 Patrick "P. J." McDermott <pj@pehjota.net>
- # Copyright (C) 2015, 2016 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
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- [ "x${DEBUG+set}" = 'xset' ] && set -v
- set -u -e
- rm -f "osbmk_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
- Refer to the documentation for more information.
- EOF
- }
- die() {
- printf 'Error: %s\n' "${@}" 1>&2
- exit 1
- }
- if [ $# -lt 1 ]; then
- die "Wrong number of arguments specified. See './download help'."
- fi
- program="${1}"
- shift 1
- [ "${program}" = help ] && help && exit 0
- if [ ! -f "${download}/${program}" ]; then
- help
- die "Invalid argument '${program}'. See: './download help'."
- fi
- if [ $# -lt 1 ]; then
- "${download}/${program}"
- else
- "${download}/${program}" $@
- fi
- exit 0
|