2023-05-18 12:17:28 +00:00
|
|
|
#!/usr/bin/env sh
|
2021-05-18 12:56:12 +00:00
|
|
|
|
|
|
|
# Generic script for downloading programs used by the build system
|
|
|
|
#
|
2023-05-18 08:09:26 +00:00
|
|
|
# Copyright (C) 2014,2015,2020,2021,2023 Leah Rowe <info@minifree.org>
|
2021-05-18 12:56:12 +00:00
|
|
|
# Copyright (C) 2015 Patrick "P. J." McDermott <pj@pehjota.net>
|
|
|
|
# Copyright (C) 2015, 2016 Klemens Nanni <contact@autoboot.org>
|
2022-11-14 00:51:12 +00:00
|
|
|
# Copyright (C) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
|
2022-08-27 12:27:48 +00:00
|
|
|
# Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
|
2021-05-18 12:56:12 +00:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
|
|
|
download=resources/scripts/download
|
2023-05-18 08:09:26 +00:00
|
|
|
program=""
|
|
|
|
|
|
|
|
main()
|
|
|
|
{
|
2023-05-18 08:18:42 +00:00
|
|
|
./.gitcheck
|
|
|
|
./resources/scripts/misc/versioncheck
|
|
|
|
|
2023-05-18 08:09:26 +00:00
|
|
|
rm -f "build_error"
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
|
|
|
help
|
|
|
|
die "Please specify arguments."
|
|
|
|
fi
|
|
|
|
|
|
|
|
program="${1}"
|
|
|
|
shift 1
|
|
|
|
|
|
|
|
if [ "${program}" = help ]; then
|
|
|
|
help
|
|
|
|
exit 0
|
|
|
|
elif [ "${program}" = "all" ]; then
|
|
|
|
for downloadProgram in ${download}/*; do
|
2023-05-18 08:16:50 +00:00
|
|
|
if [ ! -f "${downloadProgram}" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2023-05-18 08:09:26 +00:00
|
|
|
"${downloadProgram}"
|
|
|
|
done
|
|
|
|
exit 0
|
|
|
|
elif [ ! -f "${download}/${program}" ]; then
|
|
|
|
help
|
|
|
|
die "Invalid argument '${program}'. See: './download help'."
|
|
|
|
elif [ $# -lt 1 ]; then
|
|
|
|
"${download}/${program}"
|
|
|
|
else
|
|
|
|
"${download}/${program}" $@
|
|
|
|
fi
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-05-18 08:09:26 +00:00
|
|
|
./.gitcheck clean
|
2021-05-18 12:56:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2023-05-18 08:09:26 +00:00
|
|
|
they can be used. For example, './download coreboot' will download all
|
|
|
|
coreboot trees by default, but './download coreboot x60' will only
|
|
|
|
download the coreboot tree required for the target: x60
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2022-11-14 00:51:12 +00:00
|
|
|
Each program download script should also accept the --help parameter to
|
2022-02-16 13:04:16 +00:00
|
|
|
display the usage of the script.
|
2022-11-14 00:51:12 +00:00
|
|
|
|
2021-05-18 12:56:12 +00:00
|
|
|
Refer to the documentation for more information.
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2023-05-18 08:09:26 +00:00
|
|
|
listprograms() {
|
|
|
|
for program in "${download}"/*; do
|
|
|
|
printf '%s\n' "${program##*/}"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2021-05-18 12:56:12 +00:00
|
|
|
die() {
|
|
|
|
printf 'Error: %s\n' "${@}" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2023-05-18 08:09:26 +00:00
|
|
|
main $@
|