chore(imagesfiles): Refactor script introducing fetch_source function

Update options preferring their more explicit long form:
`-f` is `--fail`
`-s` is `--silent`
`-S` is `--show-error`
`-L` is `--location`

Additionally, `-O` is removed in favor of explicitly specifying the output file using `-o`
This commit is contained in:
Jean-Christophe Fillion-Robin
2025-08-27 11:08:53 -04:00
parent 0a27819132
commit 9f4e0b7413
6 changed files with 75 additions and 78 deletions
+10 -13
View File
@@ -3,6 +3,12 @@
set -ex
set -o pipefail
# Get script directory
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
# Get build utilities
source $SCRIPT_DIR/utils.sh
ARCH="x86_64"
while [ $# -gt 0 ]; do
@@ -18,11 +24,6 @@ while [ $# -gt 0 ]; do
shift
done
if ! command -v curl &> /dev/null; then
echo >&2 'error: "curl" not found!'
exit 1
fi
if ! command -v tar &> /dev/null; then
echo >&2 'error: "tar" not found!'
exit 1
@@ -36,15 +37,11 @@ fi
cd /usr/src
CMAKE_ROOT=cmake-${CMAKE_VERSION}-Centos5-${ARCH}
url=https://github.com/dockbuild/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_ROOT}.tar.gz
echo "Downloading $url"
curl --connect-timeout 30 \
--max-time 10 \
--retry 5 \
--retry-delay 10 \
--retry-max-time 30 \
-# -LO $url
CMAKE_DOWNLOAD_URL=https://github.com/dockbuild/CMake/releases/download/v${CMAKE_VERSION}
echo "Downloading ${CMAKE_DOWNLOAD_URL}/${CMAKE_ROOT}.tar.gz"
fetch_source "${CMAKE_ROOT}.tar.gz" "${CMAKE_DOWNLOAD_URL}"
tar -xzvf "${CMAKE_ROOT}.tar.gz"
rm -f "${CMAKE_ROOT}.tar.gz"