mirror of
https://github.com/bensuperpc/dockcross.git
synced 2026-07-26 04:48:08 +02:00
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:
@@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
MY_DIR=$(dirname "${BASH_SOURCE[0]}")
|
# Get script directory
|
||||||
source $MY_DIR/utils.sh
|
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||||
|
|
||||||
|
# Get build utilities
|
||||||
|
source $SCRIPT_DIR/utils.sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Function 'do_curl_build' and 'build_curl'
|
# Function 'do_curl_build' and 'build_curl'
|
||||||
@@ -20,6 +23,7 @@ if [[ -z "${CURL_HASH}" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
CURL_ROOT="${CURL_VERSION}"
|
||||||
CURL_DOWNLOAD_URL=https://curl.haxx.se/download
|
CURL_DOWNLOAD_URL=https://curl.haxx.se/download
|
||||||
|
|
||||||
function do_curl_build {
|
function do_curl_build {
|
||||||
@@ -30,28 +34,16 @@ function do_curl_build {
|
|||||||
make install > /dev/null
|
make install > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function build_curl {
|
|
||||||
local curl_fname=$1
|
|
||||||
check_var ${curl_fname}
|
|
||||||
local curl_sha256=$2
|
|
||||||
check_var ${curl_sha256}
|
|
||||||
check_var ${CURL_DOWNLOAD_URL}
|
|
||||||
curl --connect-timeout 30 \
|
|
||||||
--max-time 10 \
|
|
||||||
--retry 5 \
|
|
||||||
--retry-delay 10 \
|
|
||||||
--retry-max-time 30 \
|
|
||||||
-fsSLO ${CURL_DOWNLOAD_URL}/${curl_fname}.tar.gz
|
|
||||||
|
|
||||||
check_sha256sum ${curl_fname}.tar.gz ${curl_sha256}
|
|
||||||
tar -zxf ${curl_fname}.tar.gz
|
|
||||||
(cd curl-*/ && do_curl_build)
|
|
||||||
rm -rf curl-*
|
|
||||||
}
|
|
||||||
|
|
||||||
cd /usr/src
|
cd /usr/src
|
||||||
build_curl "${CURL_VERSION}" "${CURL_HASH}"
|
|
||||||
|
fetch_source "${CURL_ROOT}.tar.gz" "${CURL_DOWNLOAD_URL}"
|
||||||
|
check_sha256sum "${CURL_ROOT}.tar.gz" "${CURL_HASH}"
|
||||||
|
|
||||||
|
tar -zxf "${CURL_ROOT}.tar.gz"
|
||||||
|
pushd "${CURL_ROOT}"
|
||||||
|
do_curl_build
|
||||||
|
popd
|
||||||
|
rm -rf "${CURL_ROOT}" "${CURL_ROOT}.tar.gz"
|
||||||
|
|
||||||
(cat /etc/ld.so.conf.d/usr-local.conf 2> /dev/null | grep -q "^/usr/local/lib$") ||
|
(cat /etc/ld.so.conf.d/usr-local.conf 2> /dev/null | grep -q "^/usr/local/lib$") ||
|
||||||
echo '/usr/local/lib' >> /etc/ld.so.conf.d/usr-local.conf
|
echo '/usr/local/lib' >> /etc/ld.so.conf.d/usr-local.conf
|
||||||
|
|||||||
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
if ! command -v curl &> /dev/null; then
|
# Get script directory
|
||||||
echo >&2 'error: "curl" not found!'
|
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||||
exit 1
|
|
||||||
fi
|
# Get build utilities
|
||||||
|
source $SCRIPT_DIR/utils.sh
|
||||||
|
|
||||||
|
|
||||||
if ! command -v tar &> /dev/null; then
|
if ! command -v tar &> /dev/null; then
|
||||||
echo >&2 'error: "tar" not found!'
|
echo >&2 'error: "tar" not found!'
|
||||||
@@ -23,27 +25,20 @@ ldconfig
|
|||||||
|
|
||||||
cd /usr/src
|
cd /usr/src
|
||||||
|
|
||||||
url="https://mirrors.edge.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.gz"
|
GIT_ROOT="git-${GIT_VERSION}"
|
||||||
echo "Downloading $url"
|
GIT_DOWNLOAD_URL="https://mirrors.edge.kernel.org/pub/software/scm/git"
|
||||||
curl --connect-timeout 20 \
|
|
||||||
--max-time 10 \
|
|
||||||
--retry 5 \
|
|
||||||
--retry-delay 10 \
|
|
||||||
--retry-max-time 40 \
|
|
||||||
-# -LO $url
|
|
||||||
|
|
||||||
tar xvzf "git-${GIT_VERSION}.tar.gz" --no-same-owner
|
fetch_source "${GIT_ROOT}.tar.gz" "${GIT_DOWNLOAD_URL}"
|
||||||
rm -f "git-${GIT_VERSION}.tar.gz"
|
tar xvzf "${GIT_ROOT}.tar.gz" --no-same-owner
|
||||||
|
|
||||||
pushd "git-${GIT_VERSION}"
|
pushd "${GIT_ROOT}"
|
||||||
./configure --prefix=/usr/local --with-curl
|
./configure --prefix=/usr/local --with-curl
|
||||||
make -j"$(nproc)"
|
make -j"$(nproc)"
|
||||||
make install
|
make install
|
||||||
popd
|
popd
|
||||||
|
rm -rf "${GIT_ROOT}" "${GIT_ROOT}.tar.gz"
|
||||||
|
|
||||||
ldconfig
|
ldconfig
|
||||||
|
|
||||||
rm -rf "git-${GIT_VERSION}"
|
|
||||||
|
|
||||||
# turn the detached message off
|
# turn the detached message off
|
||||||
git config --global advice.detachedHead false
|
git config --global advice.detachedHead false
|
||||||
|
|||||||
@@ -10,6 +10,12 @@
|
|||||||
set -e
|
set -e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
# Get script directory
|
||||||
|
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||||
|
|
||||||
|
# Get build utilities
|
||||||
|
source $SCRIPT_DIR/utils.sh
|
||||||
|
|
||||||
PYTHON=python
|
PYTHON=python
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -31,25 +37,22 @@ if [[ -z "${NINJA_VERSION}" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Download
|
# Download
|
||||||
url="https://github.com/ninja-build/ninja/archive/v${NINJA_VERSION}.tar.gz"
|
NINJA_DOWNLOAD_URL="https://github.com/ninja-build/ninja/archive/"
|
||||||
|
NINJA_ROOT="v${NINJA_VERSION}"
|
||||||
|
|
||||||
curl --connect-timeout 30 \
|
fetch_source "${NINJA_ROOT}.tar.gz" "${NINJA_DOWNLOAD_URL}"
|
||||||
--max-time 10 \
|
|
||||||
--retry 5 \
|
|
||||||
--retry-delay 10 \
|
|
||||||
--retry-max-time 30 \
|
|
||||||
-# -o ninja.tar.gz -LO "$url"
|
|
||||||
|
|
||||||
mkdir ninja
|
# Since the archive name doesn't match the top-level directory, explicitly specify it.
|
||||||
tar -xzvf ./ninja.tar.gz --strip-components=1 -C ./ninja
|
mkdir -p "${NINJA_ROOT}"
|
||||||
|
tar xvzf "${NINJA_ROOT}.tar.gz" --strip-components=1 -C "${NINJA_ROOT}"
|
||||||
|
|
||||||
# Configure, build and install
|
# Configure, build and install
|
||||||
pushd ./ninja
|
pushd "${NINJA_ROOT}"
|
||||||
echo "Configuring ninja using [$PYTHON]"
|
echo "Configuring ninja using [$PYTHON]"
|
||||||
$PYTHON ./configure.py --bootstrap && ./ninja
|
$PYTHON ./configure.py --bootstrap && ./ninja
|
||||||
cp ./ninja /usr/bin/
|
cp ./ninja /usr/bin/
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Clean
|
# Clean
|
||||||
rm -rf ./ninja*
|
rm -rf "${NINJA_ROOT}" "${NINJA_ROOT}.tar.gz"
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,11 @@ while [ $# -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
MY_DIR=$(dirname "${BASH_SOURCE[0]}")
|
# Get script directory
|
||||||
source $MY_DIR/utils.sh
|
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||||
|
|
||||||
|
# Get build utilities
|
||||||
|
source $SCRIPT_DIR/utils.sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Function 'do_openssl_build' and 'build_openssl'
|
# Function 'do_openssl_build' and 'build_openssl'
|
||||||
@@ -84,13 +87,8 @@ function build_perl {
|
|||||||
local perl_sha256=$2
|
local perl_sha256=$2
|
||||||
check_var ${perl_sha256}
|
check_var ${perl_sha256}
|
||||||
check_var ${PERL_DOWNLOAD_URL}
|
check_var ${PERL_DOWNLOAD_URL}
|
||||||
curl --connect-timeout 30 \
|
|
||||||
--max-time 10 \
|
|
||||||
--retry 5 \
|
|
||||||
--retry-delay 10 \
|
|
||||||
--retry-max-time 30 \
|
|
||||||
-fsSLO ${PERL_DOWNLOAD_URL}/${perl_fname}.tar.gz
|
|
||||||
|
|
||||||
|
fetch_source "${perl_fname}.tar.gz" "${PERL_DOWNLOAD_URL}"
|
||||||
check_sha256sum ${perl_fname}.tar.gz ${perl_sha256}
|
check_sha256sum ${perl_fname}.tar.gz ${perl_sha256}
|
||||||
tar -xzf ${perl_fname}.tar.gz --no-same-owner
|
tar -xzf ${perl_fname}.tar.gz --no-same-owner
|
||||||
(cd ${perl_fname} && do_perl_build)
|
(cd ${perl_fname} && do_perl_build)
|
||||||
@@ -109,13 +107,8 @@ function build_openssl {
|
|||||||
local openssl_sha256=$2
|
local openssl_sha256=$2
|
||||||
check_var ${openssl_sha256}
|
check_var ${openssl_sha256}
|
||||||
check_var ${OPENSSL_DOWNLOAD_URL}
|
check_var ${OPENSSL_DOWNLOAD_URL}
|
||||||
curl --connect-timeout 30 \
|
|
||||||
--max-time 10 \
|
|
||||||
--retry 5 \
|
|
||||||
--retry-delay 10 \
|
|
||||||
--retry-max-time 30 \
|
|
||||||
-fsSLO ${OPENSSL_DOWNLOAD_URL}/${openssl_fname}.tar.gz
|
|
||||||
|
|
||||||
|
fetch_source "${openssl_fname}.tar.gz" "${OPENSSL_DOWNLOAD_URL}"
|
||||||
check_sha256sum ${openssl_fname}.tar.gz ${openssl_sha256}
|
check_sha256sum ${openssl_fname}.tar.gz ${openssl_sha256}
|
||||||
tar -xzf ${openssl_fname}.tar.gz
|
tar -xzf ${openssl_fname}.tar.gz
|
||||||
(cd ${openssl_fname} && PATH=/opt/perl/bin:${PATH} do_openssl_build)
|
(cd ${openssl_fname} && PATH=/opt/perl/bin:${PATH} do_openssl_build)
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
set -ex
|
set -ex
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
|
# Get script directory
|
||||||
|
SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||||
|
|
||||||
|
# Get build utilities
|
||||||
|
source $SCRIPT_DIR/utils.sh
|
||||||
|
|
||||||
ARCH="x86_64"
|
ARCH="x86_64"
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
@@ -18,11 +24,6 @@ while [ $# -gt 0 ]; do
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if ! command -v curl &> /dev/null; then
|
|
||||||
echo >&2 'error: "curl" not found!'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! command -v tar &> /dev/null; then
|
if ! command -v tar &> /dev/null; then
|
||||||
echo >&2 'error: "tar" not found!'
|
echo >&2 'error: "tar" not found!'
|
||||||
exit 1
|
exit 1
|
||||||
@@ -36,15 +37,11 @@ fi
|
|||||||
cd /usr/src
|
cd /usr/src
|
||||||
|
|
||||||
CMAKE_ROOT=cmake-${CMAKE_VERSION}-Centos5-${ARCH}
|
CMAKE_ROOT=cmake-${CMAKE_VERSION}-Centos5-${ARCH}
|
||||||
url=https://github.com/dockbuild/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_ROOT}.tar.gz
|
CMAKE_DOWNLOAD_URL=https://github.com/dockbuild/CMake/releases/download/v${CMAKE_VERSION}
|
||||||
echo "Downloading $url"
|
|
||||||
curl --connect-timeout 30 \
|
|
||||||
--max-time 10 \
|
|
||||||
--retry 5 \
|
|
||||||
--retry-delay 10 \
|
|
||||||
--retry-max-time 30 \
|
|
||||||
-# -LO $url
|
|
||||||
|
|
||||||
|
echo "Downloading ${CMAKE_DOWNLOAD_URL}/${CMAKE_ROOT}.tar.gz"
|
||||||
|
|
||||||
|
fetch_source "${CMAKE_ROOT}.tar.gz" "${CMAKE_DOWNLOAD_URL}"
|
||||||
tar -xzvf "${CMAKE_ROOT}.tar.gz"
|
tar -xzvf "${CMAKE_ROOT}.tar.gz"
|
||||||
rm -f "${CMAKE_ROOT}.tar.gz"
|
rm -f "${CMAKE_ROOT}.tar.gz"
|
||||||
|
|
||||||
|
|||||||
@@ -22,3 +22,20 @@ function check_sha256sum {
|
|||||||
rm -f ${fname}.sha256
|
rm -f ${fname}.sha256
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fetch_source {
|
||||||
|
if ! command -v curl &> /dev/null; then
|
||||||
|
echo >&2 'error: "curl" not found!'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
local file=$1
|
||||||
|
check_var "${file}"
|
||||||
|
local url=$2
|
||||||
|
check_var "${url}"
|
||||||
|
curl --fail \
|
||||||
|
--location \
|
||||||
|
--silent \
|
||||||
|
--show-error \
|
||||||
|
--connect-timeout 30 --max-time 10 \
|
||||||
|
--retry 5 --retry-delay 10 --retry-max-time 30 \
|
||||||
|
-o "${file}" ${url}/${file}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user