-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathsetup-webp.sh
executable file
·42 lines (34 loc) · 1.05 KB
/
setup-webp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
set -e
if [[ -z "$1" ]];
then
echo "Target directory argument is missing."
exit 1
fi
TARGET_DIRECTORY=${1}
LIBWEBP_VERSION="1.3.0"
LIBWEBP_TAR_URI="https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${LIBWEBP_VERSION}-linux-x86-64.tar.gz"
EXPECTED_FILES=(cwebp dwebp webpinfo gif2webp webpmux)
function ensure_target_directory() {
mkdir -p ${TARGET_DIRECTORY}
if [ "$?" != "0" ]; then
exit -1
fi
}
function download_and_extract() {
curl --retry 8 -L "${LIBWEBP_TAR_URI}" | \
tar -xzv --strip-components=2 -C "${TARGET_DIRECTORY}" --\
"libwebp-${LIBWEBP_VERSION}-linux-x86-64/bin"
}
function check_expected_files_in_target_exists() {
for file in ${EXPECTED_FILES[@]}; do
PATH2CHECK="${TARGET_DIRECTORY}/${file}"
[ ! -f "${PATH2CHECK}" ] &&
( echo "file ${PATH2CHECK} is missing" ; exit -1 );
done
echo "setup-webp successfully installed binaries: ${EXPECTED_FILES[@]}"
}
# Entry
ensure_target_directory
download_and_extract
check_expected_files_in_target_exists