From 04a008e001fcca45470fbf9dfdd79b642fd2f9ea Mon Sep 17 00:00:00 2001 From: Javernaut Date: Tue, 21 Apr 2020 11:18:14 +0300 Subject: [PATCH 1/4] A common function to download a source code archive --- scripts/common-functions.sh | 22 ++++++++++++++++++++++ scripts/libdav1d/download.sh | 19 +++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) create mode 100755 scripts/common-functions.sh diff --git a/scripts/common-functions.sh b/scripts/common-functions.sh new file mode 100755 index 0000000..82062c2 --- /dev/null +++ b/scripts/common-functions.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} +} diff --git a/scripts/libdav1d/download.sh b/scripts/libdav1d/download.sh index ec0a7c5..acd83a8 100755 --- a/scripts/libdav1d/download.sh +++ b/scripts/libdav1d/download.sh @@ -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" From 113ce59555887cae516f0c98d58f388b4781324c Mon Sep 17 00:00:00 2001 From: Javernaut Date: Tue, 21 Apr 2020 12:27:43 +0300 Subject: [PATCH 2/4] Improving the tar archive download function --- scripts/common-functions.sh | 19 +++++++++++-------- scripts/libdav1d/download.sh | 5 ++--- scripts/libmp3lame/download.sh | 18 ++++-------------- scripts/parse-arguments.sh | 2 +- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/scripts/common-functions.sh b/scripts/common-functions.sh index 82062c2..44aac2e 100755 --- a/scripts/common-functions.sh +++ b/scripts/common-functions.sh @@ -1,22 +1,25 @@ #!/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() { +# extracts its files and exports a variable SOURCES_DIR_${LIBRARY_NAME} +function downloadTarArchive() { + # The full name of the library LIBRARY_NAME=$1 - LIBRARY_VERSION=$2 - DOWNLOAD_URL=$3 + # The url of the source code archive + DOWNLOAD_URL=$2 - echo "Ensuring sources of $LIBRARY_NAME $LIBRARY_VERSION" - LIBRARY_SOURCES=${LIBRARY_NAME}-${LIBRARY_VERSION} + ARCHIVE_NAME=${DOWNLOAD_URL##*/} + # Name of the directory after the archive extraction + LIBRARY_SOURCES="${ARCHIVE_NAME%.tar.*}" + + echo "Ensuring sources of $LIBRARY_SOURCES" 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} + export SOURCES_DIR_${LIBRARY_NAME}=$(pwd)/${LIBRARY_SOURCES} } diff --git a/scripts/libdav1d/download.sh b/scripts/libdav1d/download.sh index acd83a8..9697551 100755 --- a/scripts/libdav1d/download.sh +++ b/scripts/libdav1d/download.sh @@ -4,7 +4,6 @@ source ${SCRIPTS_DIR}/common-functions.sh DAV1D_VERSION=0.6.0 -downloadArchive \ - "dav1d" \ - ${DAV1D_VERSION} \ +downloadTarArchive \ + "libdav1d" \ "https://code.videolan.org/videolan/dav1d/-/archive/${DAV1D_VERSION}/dav1d-${DAV1D_VERSION}.tar.gz" diff --git a/scripts/libmp3lame/download.sh b/scripts/libmp3lame/download.sh index 46cf5d6..fe58d48 100755 --- a/scripts/libmp3lame/download.sh +++ b/scripts/libmp3lame/download.sh @@ -1,19 +1,9 @@ #!/usr/bin/env bash -# Script to download Lame's source code - -# Exports SOURCES_DIR_libmp3lame - path where actual sources are stored +source ${SCRIPTS_DIR}/common-functions.sh LAME_VERSION=3.100 -echo "Using libmp3lame $LAME_VERSION" -LAME_SOURCES=lame-${LAME_VERSION} - -if [[ ! -d "$LAME_SOURCES" ]]; then - TARGET_FILE_NAME=lame-${LAME_VERSION}.tar.gz - - curl http://downloads.videolan.org/pub/contrib/lame/${TARGET_FILE_NAME} --output ${TARGET_FILE_NAME} - tar xf ${TARGET_FILE_NAME} -C . - rm ${TARGET_FILE_NAME} -fi -export SOURCES_DIR_libmp3lame=$(pwd)/${LAME_SOURCES} +downloadTarArchive \ + "libmp3lame" \ + "http://downloads.videolan.org/pub/contrib/lame/lame-${LAME_VERSION}.tar.gz" diff --git a/scripts/parse-arguments.sh b/scripts/parse-arguments.sh index ea9f989..8ba04fd 100755 --- a/scripts/parse-arguments.sh +++ b/scripts/parse-arguments.sh @@ -73,7 +73,7 @@ for argument in "$@"; do --enable-libdav1d|-dav1d) EXTERNAL_LIBRARIES+=( "libdav1d" ) ;; - --enable-libmp3lame|-mp3lame) + --enable-libmp3lame|-mp3lame|-lame) EXTERNAL_LIBRARIES+=( "libmp3lame" ) ;; *) From 15d32bb6e307e6132b13b922568f0beee0a09159 Mon Sep 17 00:00:00 2001 From: Javernaut Date: Tue, 21 Apr 2020 13:04:09 +0300 Subject: [PATCH 3/4] simplifying the libaom download.sh --- scripts/common-functions.sh | 14 +++++++++++--- scripts/libaom/download.sh | 24 +++++------------------- 2 files changed, 16 insertions(+), 22 deletions(-) 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 From f0718ba7847c2f3fc5a4afe317598f8d6c7fa623 Mon Sep 17 00:00:00 2001 From: Javernaut Date: Tue, 21 Apr 2020 13:11:47 +0300 Subject: [PATCH 4/4] simplifying the ffmpeg download.sh --- scripts/ffmpeg/download.sh | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/scripts/ffmpeg/download.sh b/scripts/ffmpeg/download.sh index bdb5819..590b3fa 100755 --- a/scripts/ffmpeg/download.sh +++ b/scripts/ffmpeg/download.sh @@ -9,17 +9,11 @@ # Getting sources of a particular FFmpeg release. # Same argument (FFmpeg version) produces the same source set. function ensureSourcesTar() { - FFMPEG_SOURCES=ffmpeg-${FFMPEG_SOURCE_VALUE} + source ${SCRIPTS_DIR}/common-functions.sh - if [[ ! -d "$FFMPEG_SOURCES" ]]; then - TARGET_FILE_NAME=ffmpeg-${FFMPEG_SOURCE_VALUE}.tar.bz2 - - curl https://www.ffmpeg.org/releases/${TARGET_FILE_NAME} --output ${TARGET_FILE_NAME} - tar xf ${TARGET_FILE_NAME} -C . - rm ${TARGET_FILE_NAME} - fi - - export SOURCES_DIR_ffmpeg=$(pwd)/${FFMPEG_SOURCES} + downloadTarArchive \ + "ffmpeg" \ + "https://www.ffmpeg.org/releases/ffmpeg-${FFMPEG_SOURCE_VALUE}.tar.bz2" } # Getting sources of a particular branch or a tag of FFmpeg's git repository.