diff --git a/scripts/common-functions.sh b/scripts/common-functions.sh index 44aac2e..045a830 100755 --- a/scripts/common-functions.sh +++ b/scripts/common-functions.sh @@ -7,17 +7,25 @@ function downloadTarArchive() { LIBRARY_NAME=$1 # The url of the source code archive DOWNLOAD_URL=$2 + # Optional. If 'true' then the function creates an extra directory for archive extraction. + NEED_EXTRA_DIRECTORY=$3 ARCHIVE_NAME=${DOWNLOAD_URL##*/} - # Name of the directory after the archive extraction + # File name without extension LIBRARY_SOURCES="${ARCHIVE_NAME%.tar.*}" - echo "Ensuring sources of $LIBRARY_SOURCES" + echo "Ensuring sources of ${LIBRARY_NAME} in ${LIBRARY_SOURCES}" if [[ ! -d "$LIBRARY_SOURCES" ]]; then curl -O ${DOWNLOAD_URL} - tar xf ${ARCHIVE_NAME} -C . + EXTRACTION_DIR="." + if [ "$NEED_EXTRA_DIRECTORY" = true ] ; then + EXTRACTION_DIR=${LIBRARY_SOURCES} + mkdir ${EXTRACTION_DIR} + fi + + tar xf ${ARCHIVE_NAME} -C ${EXTRACTION_DIR} rm ${ARCHIVE_NAME} fi diff --git a/scripts/libaom/download.sh b/scripts/libaom/download.sh index 6cbeabf..c233fba 100755 --- a/scripts/libaom/download.sh +++ b/scripts/libaom/download.sh @@ -1,24 +1,10 @@ #!/usr/bin/env bash -# Script to download AV1 Codec Library's source code +source ${SCRIPTS_DIR}/common-functions.sh -# Exports SOURCES_DIR_libaom - path where actual sources are stored - -# This 2 variables have to be changed at once. -# The first one is produced by 'git describe' command while being in the commit represented by the second one. AOM_VERSION=v1.0.0-errata1-avif -AOM_HASH=4eb1e7795b9700d532af38a2d9489458a8038233 - -echo "Using libaom $AOM_VERSION" -AOM_SOURCES=libaom-${AOM_VERSION} - -if [[ ! -d "$AOM_SOURCES" ]]; then - TARGET_FILE_NAME=${AOM_VERSION}.tar.gz - - curl https://aomedia.googlesource.com/aom/+archive/${AOM_HASH}.tar.gz --output ${TARGET_FILE_NAME} - mkdir $AOM_SOURCES - tar xf ${TARGET_FILE_NAME} -C $AOM_SOURCES - rm ${TARGET_FILE_NAME} -fi -export SOURCES_DIR_libaom=$(pwd)/${AOM_SOURCES} +downloadTarArchive \ + "libaom" \ + "https://aomedia.googlesource.com/aom/+archive/${AOM_VERSION}.tar.gz" \ + true