2
1
Fork 0
mirror of https://git.savannah.gnu.org/git/gnuboot.git synced 2025-01-27 17:50:20 +01:00
gnuboot/download
Denis 'GNUtoo' Carikli a77228d7af
download: rename program(s) to package(s).
Most GNU Boot users are interested in running GNU/Linux or BSD
operating systems. And the way to install software on these
operating systems is through a package manager. So most users and
contributors already know the package manager abstraction.

So referring to packages instead of options makes it easier to
understand what the script is doing.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Acked-by: Adrien 'neox' Bourmault <neox@gnu.org>
2023-12-06 17:13:08 +01:00

119 lines
3 KiB
Bash
Executable file

#!/usr/bin/env 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>
# Copyright (C) 2022, Caleb La Grange <thonkpeasant@protonmail.com>
#
# 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/>.
#
./.gitcheck
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
./resources/scripts/misc/versioncheck
# set this when you want to modify each coreboot tree
# for example, you want to test custom patches
# NODELETE= ./download coreboot
deleteblobs="true"
[ "x${NODELETE+set}" = 'xset' ] && deleteblobs="false"
rm -f "build_error"
download=resources/scripts/download
list_packages() {
for package in "${download}"/*; do
printf '%s\n' "${package##*/}"
done
}
help() {
cat <<- EOF
USAGE: ./download <PACKAGE> <OPTIONS>
possible values for 'package':
$(list_packages)
Example: ./download flashrom
Example: ./download coreboot
Some package options allow for additional parameters:
Example: ./download coreboot default
Example: ./download coreboot x60
Each package 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 package 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
package="${1}"
shift 1
[ "${package}" = help ] && help && exit 0
if [ "${package}" = "all" ]; then
for downloadPackage in ${download}/*; do
if [ -f "${downloadPackage}" ]; then
if [ "${deleteblobs}" = "false" ]; then
NODELETE= "${downloadPackage}"
else
"${downloadPackage}"
fi
fi
done
exit 0
elif [ ! -f "${download}/${package}" ]; then
help
die "Invalid argument '${package}'. See: './download help'."
fi
if [ $# -lt 1 ]; then
if [ "${deleteblobs}" = "false" ]; then
NODELETE= "${download}/${package}"
else
"${download}/${package}"
fi
else
if [ "${deleteblobs}" = "false" ]; then
NODELETE= "${download}/${package}" $@
else
"${download}/${package}" $@
fi
fi
exit 0
./.gitcheck clean