A common function to download a source code archive

ffmpeg_4.4.2
Javernaut 5 years ago
parent bb8970c372
commit 04a008e001
  1. 22
      scripts/common-functions.sh
  2. 19
      scripts/libdav1d/download.sh

@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Function that downloads an archive with the source code by the given url,
# extracts its files and exports a variable SOURCES_DIR_lib${LIBRARY_NAME}
function downloadArchive() {
LIBRARY_NAME=$1
LIBRARY_VERSION=$2
DOWNLOAD_URL=$3
echo "Ensuring sources of $LIBRARY_NAME $LIBRARY_VERSION"
LIBRARY_SOURCES=${LIBRARY_NAME}-${LIBRARY_VERSION}
if [[ ! -d "$LIBRARY_SOURCES" ]]; then
curl -O ${DOWNLOAD_URL}
ARCHIVE_NAME=${DOWNLOAD_URL##*/}
tar xf ${ARCHIVE_NAME} -C .
rm ${ARCHIVE_NAME}
fi
export SOURCES_DIR_lib${LIBRARY_NAME}=$(pwd)/${LIBRARY_SOURCES}
}

@ -1,19 +1,10 @@
#!/usr/bin/env bash
# Script to download Dav1d's source code
# Exports SOURCES_DIR_libdav1d - path where actual sources are stored
source ${SCRIPTS_DIR}/common-functions.sh
DAV1D_VERSION=0.6.0
echo "Using libdav1d $DAV1D_VERSION"
DAV1D_SOURCES=dav1d-${DAV1D_VERSION}
if [[ ! -d "$DAV1D_SOURCES" ]]; then
TARGET_FILE_NAME=dav1d-${DAV1D_VERSION}.tar.gz
curl https://code.videolan.org/videolan/dav1d/-/archive/${DAV1D_VERSION}/dav1d-${DAV1D_VERSION}.tar.gz --output ${TARGET_FILE_NAME}
tar xf ${TARGET_FILE_NAME} -C .
rm ${TARGET_FILE_NAME}
fi
export SOURCES_DIR_libdav1d=$(pwd)/${DAV1D_SOURCES}
downloadArchive \
"dav1d" \
${DAV1D_VERSION} \
"https://code.videolan.org/videolan/dav1d/-/archive/${DAV1D_VERSION}/dav1d-${DAV1D_VERSION}.tar.gz"

Loading…
Cancel
Save