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"
wget()
{
_wget() {
local url="$1"
local dir="${CACHEDIR:-$GITDIR/sources}"
local file
file=$(basename "$url")
local file="${2:-$(basename "${url}")}"
mkdir -p "$dir"
test -s "$dir/$file" || command wget -O "$dir/$file" "$url"
cp -v "$dir/$file" .
checksum_do "$dir" "$file"
}
checksum_do()
{
checksum_do() {
local dir="$1"
local file="$2"
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() {
url=$1
make_build=${2:-0}
output_filename=$3
ext="${url##*.}"
if [ "$ext" = "tar" ]; then
bname=$(basename "$url" ".tar")
bname=$(basename "${output_filename:-${url}}" ".tar")
else
bname=$(basename "$url" ".tar.${ext}")
bname=$(basename "${output_filename:-${url}}" ".tar.${ext}")
fi
cp -r "${bname}" tmp/after/
target="tmp/after/${bname}"
@ -141,7 +137,7 @@ get_file() {
fi
pushd "tmp/after/${bname}/src"
if [ ! -f "$(basename "$url")" ]; then
wget "$url"
_wget "$url" "${output_filename:-${url##*/}}"
fi
popd
}