Improving the tar archive download function

pull/53/head
Javernaut 5 years ago
parent 04a008e001
commit 113ce59555
  1. 19
      scripts/common-functions.sh
  2. 5
      scripts/libdav1d/download.sh
  3. 18
      scripts/libmp3lame/download.sh
  4. 2
      scripts/parse-arguments.sh

@ -1,22 +1,25 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Function that downloads an archive with the source code by the given url, # 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} # extracts its files and exports a variable SOURCES_DIR_${LIBRARY_NAME}
function downloadArchive() { function downloadTarArchive() {
# The full name of the library
LIBRARY_NAME=$1 LIBRARY_NAME=$1
LIBRARY_VERSION=$2 # The url of the source code archive
DOWNLOAD_URL=$3 DOWNLOAD_URL=$2
echo "Ensuring sources of $LIBRARY_NAME $LIBRARY_VERSION" ARCHIVE_NAME=${DOWNLOAD_URL##*/}
LIBRARY_SOURCES=${LIBRARY_NAME}-${LIBRARY_VERSION} # Name of the directory after the archive extraction
LIBRARY_SOURCES="${ARCHIVE_NAME%.tar.*}"
echo "Ensuring sources of $LIBRARY_SOURCES"
if [[ ! -d "$LIBRARY_SOURCES" ]]; then if [[ ! -d "$LIBRARY_SOURCES" ]]; then
curl -O ${DOWNLOAD_URL} curl -O ${DOWNLOAD_URL}
ARCHIVE_NAME=${DOWNLOAD_URL##*/}
tar xf ${ARCHIVE_NAME} -C . tar xf ${ARCHIVE_NAME} -C .
rm ${ARCHIVE_NAME} rm ${ARCHIVE_NAME}
fi fi
export SOURCES_DIR_lib${LIBRARY_NAME}=$(pwd)/${LIBRARY_SOURCES} export SOURCES_DIR_${LIBRARY_NAME}=$(pwd)/${LIBRARY_SOURCES}
} }

@ -4,7 +4,6 @@ source ${SCRIPTS_DIR}/common-functions.sh
DAV1D_VERSION=0.6.0 DAV1D_VERSION=0.6.0
downloadArchive \ downloadTarArchive \
"dav1d" \ "libdav1d" \
${DAV1D_VERSION} \
"https://code.videolan.org/videolan/dav1d/-/archive/${DAV1D_VERSION}/dav1d-${DAV1D_VERSION}.tar.gz" "https://code.videolan.org/videolan/dav1d/-/archive/${DAV1D_VERSION}/dav1d-${DAV1D_VERSION}.tar.gz"

@ -1,19 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Script to download Lame's source code source ${SCRIPTS_DIR}/common-functions.sh
# Exports SOURCES_DIR_libmp3lame - path where actual sources are stored
LAME_VERSION=3.100 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"

@ -73,7 +73,7 @@ for argument in "$@"; do
--enable-libdav1d|-dav1d) --enable-libdav1d|-dav1d)
EXTERNAL_LIBRARIES+=( "libdav1d" ) EXTERNAL_LIBRARIES+=( "libdav1d" )
;; ;;
--enable-libmp3lame|-mp3lame) --enable-libmp3lame|-mp3lame|-lame)
EXTERNAL_LIBRARIES+=( "libmp3lame" ) EXTERNAL_LIBRARIES+=( "libmp3lame" )
;; ;;
*) *)

Loading…
Cancel
Save