Add optional output_filename argument in rootfs.sh

Downloads to a particular filename, allows for different names than
whatever is upstream.
This commit is contained in:
fosslinux 2021-02-15 19:31:17 +11:00
parent 372e08e4f9
commit 44bad278e0
1 changed files with 45 additions and 49 deletions

View File

@ -27,22 +27,17 @@ sudo mount -t tmpfs -o size=8G tmpfs tmp
LOGFILE="$PWD/tmp/bootstrap.log" LOGFILE="$PWD/tmp/bootstrap.log"
wget() _wget() {
{
local url="$1" local url="$1"
local dir="${CACHEDIR:-$GITDIR/sources}" local dir="${CACHEDIR:-$GITDIR/sources}"
local file local file="${2:-$(basename "${url}")}"
file=$(basename "$url")
mkdir -p "$dir" mkdir -p "$dir"
test -s "$dir/$file" || command wget -O "$dir/$file" "$url" test -s "$dir/$file" || command wget -O "$dir/$file" "$url"
cp -v "$dir/$file" . cp -v "$dir/$file" .
checksum_do "$dir" "$file" checksum_do "$dir" "$file"
} }
checksum_do() checksum_do() {
{
local dir="$1" local dir="$1"
local file="$2" local file="$2"
local line local line
@ -127,11 +122,12 @@ tar -C tmp/after/tar-1.12/src -xf "tmp/after/tar-1.12/src/$(basename $url)" --st
get_file() { get_file() {
url=$1 url=$1
make_build=${2:-0} make_build=${2:-0}
output_filename=$3
ext="${url##*.}" ext="${url##*.}"
if [ "$ext" = "tar" ]; then if [ "$ext" = "tar" ]; then
bname=$(basename "$url" ".tar") bname=$(basename "${output_filename:-${url}}" ".tar")
else else
bname=$(basename "$url" ".tar.${ext}") bname=$(basename "${output_filename:-${url}}" ".tar.${ext}")
fi fi
cp -r "${bname}" tmp/after/ cp -r "${bname}" tmp/after/
target="tmp/after/${bname}" target="tmp/after/${bname}"
@ -141,7 +137,7 @@ get_file() {
fi fi
pushd "tmp/after/${bname}/src" pushd "tmp/after/${bname}/src"
if [ ! -f "$(basename "$url")" ]; then if [ ! -f "$(basename "$url")" ]; then
wget "$url" _wget "$url" "${output_filename:-${url##*/}}"
fi fi
popd popd
} }