2018-05-08 17:14:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
|
|
|
|
# set version of 3rd party libraries
|
|
|
|
CURRENT_LIBZIP="1.2.0"
|
|
|
|
CURRENT_LIBGIT2="v0.26.0"
|
|
|
|
CURRENT_HIDAPI="hidapi-0.7.0"
|
|
|
|
CURRENT_LIBCURL="curl-7_54_1"
|
|
|
|
CURRENT_LIBUSB="v1.0.21"
|
2018-05-19 20:39:49 +00:00
|
|
|
CURRENT_OPENSSL="OpenSSL_1_1_0h"
|
2018-05-08 17:14:09 +00:00
|
|
|
CURRENT_LIBSSH2="libssh2-1.8.0"
|
|
|
|
CURRENT_XSLT="v1.1.29"
|
|
|
|
CURRENT_SQLITE="3190200"
|
|
|
|
CURRENT_LIBXML2="v2.9.4"
|
|
|
|
CURRENT_LIBFTDI="1.3"
|
2018-06-16 10:47:58 +00:00
|
|
|
CURRENT_KIRIGAMI="8b803828ad9ea67559a64a93c927862d6b19c96e"
|
2018-05-23 13:41:55 +00:00
|
|
|
CURRENT_BREEZE_ICONS=""
|
2018-05-08 17:14:09 +00:00
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
# Checkout library from git
|
|
|
|
# Ensure specified version is checked out,
|
|
|
|
# while avoiding cloning/fetching if unnecessary.
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# name - used as directory name
|
|
|
|
# version - any tag/sha usable by git
|
|
|
|
# url - repository url
|
|
|
|
#
|
|
|
|
git_checkout_library() {
|
|
|
|
[ $# -ne 3 ] && return -1
|
|
|
|
|
|
|
|
# for clarity
|
|
|
|
local name=$1
|
|
|
|
local version=$2
|
|
|
|
local url=$3
|
|
|
|
|
|
|
|
if [ ! -d "$name" ]; then
|
|
|
|
git clone "$url" "$name"
|
|
|
|
fi
|
|
|
|
pushd "$name"
|
|
|
|
|
2018-06-16 16:27:35 +00:00
|
|
|
local current_sha=$(git rev-parse HEAD)
|
|
|
|
local target_sha=$(git rev-parse "$version")
|
|
|
|
|
|
|
|
if [ ! "$current_sha" = "$target_sha" ] ; then
|
|
|
|
git fetch origin
|
|
|
|
if ! git checkout "$version" ; then
|
|
|
|
echo "Can't find the right tag in $name - giving up"
|
|
|
|
return -1
|
|
|
|
fi
|
2018-06-16 14:24:46 +00:00
|
|
|
fi
|
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
2018-06-17 07:44:20 +00:00
|
|
|
# Download and extract tarball dependencies
|
|
|
|
#
|
|
|
|
# Arguments:
|
|
|
|
# name - used as output directory
|
|
|
|
# base_url -
|
|
|
|
# filename - tarball file name
|
|
|
|
#
|
|
|
|
curl_download_library() {
|
|
|
|
[ $# -ne 3 ] && return -1
|
|
|
|
|
|
|
|
local name=$1
|
|
|
|
local base_url=$2
|
|
|
|
local filename=$3
|
|
|
|
|
|
|
|
if [ ! -f "$filename" ]; then
|
|
|
|
${CURL} "${base_url}${filename}"
|
|
|
|
rm -rf "$name"
|
|
|
|
mkdir "$name"
|
|
|
|
tar -C "$name" --strip-components=1 -xf "$filename"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
|
2018-05-08 17:14:09 +00:00
|
|
|
# deal with all the command line arguments
|
2018-05-16 08:59:27 +00:00
|
|
|
if [[ $# -ne 2 && $# -ne 3 ]] ; then
|
2018-05-08 17:14:09 +00:00
|
|
|
echo "wrong number of parameters, format:"
|
2018-05-16 08:59:27 +00:00
|
|
|
echo "get-dep-lib.sh <platform> <install dir>"
|
|
|
|
echo "get-dep-lib.sh single <install dir> <lib>"
|
2018-05-17 18:55:58 +00:00
|
|
|
echo "get-dep-lib.sh singleAndroid <install dir> <lib>"
|
2018-05-16 08:59:27 +00:00
|
|
|
echo "where"
|
|
|
|
echo "<platform> is one of scripts, ios or android"
|
2018-05-08 17:14:09 +00:00
|
|
|
echo "(the name of the directory where build.sh resides)"
|
2018-05-16 08:59:27 +00:00
|
|
|
echo "<install dir> is the directory to clone in"
|
|
|
|
echo "<lib> is the name to be cloned"
|
2018-05-08 17:14:09 +00:00
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
|
|
|
|
PLATFORM=$1
|
|
|
|
INSTDIR=$2
|
|
|
|
if [ ! -d ${INSTDIR} ] ; then
|
|
|
|
echo "creating dir"
|
|
|
|
mkdir -p ${INSTDIR}
|
|
|
|
fi
|
|
|
|
|
2018-05-17 18:55:58 +00:00
|
|
|
# FIX FOR ANDROID,
|
|
|
|
if [ "$PLATFORM" == "singleAndroid" ] ; then
|
|
|
|
CURRENT_LIBZIP="1.1.3"
|
2018-05-19 20:39:49 +00:00
|
|
|
CURRENT_OPENSSL="OpenSSL_1_0_2o"
|
2018-05-17 18:55:58 +00:00
|
|
|
fi
|
|
|
|
# no curl and old libs (never version breaks)
|
|
|
|
# check whether to use curl or wget
|
|
|
|
if [ "`which curl`" == "" ] ; then
|
|
|
|
CURL="wget "
|
|
|
|
else
|
|
|
|
CURL="curl -O "
|
|
|
|
fi
|
2018-05-25 06:08:05 +00:00
|
|
|
BUILD_COMMON="libzip libgit2 googlemaps"
|
2018-05-08 17:14:09 +00:00
|
|
|
case ${PLATFORM} in
|
|
|
|
scripts)
|
2018-05-23 13:41:55 +00:00
|
|
|
BUILD="${BUILD_COMMON} hidapi libcurl libusb openssl libssh2"
|
2018-05-08 17:14:09 +00:00
|
|
|
;;
|
|
|
|
ios)
|
2018-05-23 13:41:55 +00:00
|
|
|
BUILD="${BUILD_COMMON} libxslt"
|
2018-05-08 17:14:09 +00:00
|
|
|
;;
|
|
|
|
android)
|
2018-05-23 13:41:55 +00:00
|
|
|
BUILD="${BUILD_COMMON} libxslt sqlite libxml2 openssl libftdi libusb"
|
2018-05-08 17:14:09 +00:00
|
|
|
;;
|
2018-05-16 08:59:27 +00:00
|
|
|
single)
|
|
|
|
BUILD="$3"
|
|
|
|
;;
|
2018-05-17 18:55:58 +00:00
|
|
|
singleAndroid)
|
|
|
|
BUILD="$3"
|
|
|
|
;;
|
2018-05-08 17:14:09 +00:00
|
|
|
*)
|
|
|
|
echo "Unknown platform ${PLATFORM}, choose between native, ios or android"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# show what you are doing and stop when things break
|
|
|
|
set -x
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# get ready to download needed sources
|
|
|
|
cd ${INSTDIR}
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
if [[ "$BUILD" = *"libcurl"* ]]; then
|
|
|
|
git_checkout_library libcurl $CURRENT_LIBCURL https://github.com/curl/curl.git
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
if [[ "$BUILD" = *"libgit2"* ]]; then
|
|
|
|
git_checkout_library libgit2 $CURRENT_LIBGIT2 https://github.com/libgit2/libgit2.git
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
if [[ "$BUILD" = *"libssh2"* ]]; then
|
|
|
|
git_checkout_library libssh2 $CURRENT_LIBSSH2 https://github.com/libssh2/libssh2.git
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
if [[ "$BUILD" = *"libusb"* ]]; then
|
|
|
|
git_checkout_library libusb $CURRENT_LIBUSB https://github.com/libusb/libusb.git
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
if [[ "$BUILD" = *"libxml2"* ]];then
|
|
|
|
git_checkout_library libxml2 $CURRENT_LIBXML2 https://github.com/GNOME/libxml2.git
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
if [[ "$BUILD" = *"libxslt"* ]]; then
|
|
|
|
git_checkout_library libxslt $CURRENT_XSLT https://github.com/GNOME/libxslt.git
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
if [[ "$BUILD" = *"breeze-icons"* ]]; then
|
|
|
|
git_checkout_library breeze-icons master https://github.com/kde/breeze-icons.git
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
if [[ "$BUILD" = *"googlemaps"* ]]; then
|
|
|
|
git_checkout_library googlemaps master https://github.com/Subsurface-divelog/googlemaps.git
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
if [[ "$BUILD" = *"hidapi"* ]]; then
|
|
|
|
git_checkout_library hidapi master https://github.com/signal11/hidapi.git
|
2018-05-23 13:41:55 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
if [[ "$BUILD" = *"kirigami"* ]]; then
|
|
|
|
git_checkout_library kirigami $CURRENT_KIRIGAMI https://github.com/KDE/kirigami.git
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-16 14:24:46 +00:00
|
|
|
if [[ "$BUILD" = *"openssl"* ]]; then
|
|
|
|
git_checkout_library openssl $CURRENT_OPENSSL https://github.com/openssl/openssl.git
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-17 07:44:20 +00:00
|
|
|
if [[ "$BUILD" = *"libzip"* ]]; then
|
|
|
|
curl_download_library libzip https://subsurface-divelog.org/downloads/ libzip-${CURRENT_LIBZIP}.tar.xz
|
2018-05-23 13:41:55 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-17 07:44:20 +00:00
|
|
|
if [[ "$BUILD" = *"libftdi"* ]]; then
|
|
|
|
curl_download_library libftdi1 https://www.intra2net.com/en/developer/libftdi/download/ libftdi1-${CURRENT_LIBFTDI}.tar.bz2
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-17 07:44:20 +00:00
|
|
|
if [[ "$BUILD" = *"sqlite"* ]]; then
|
|
|
|
curl_download_library sqlite http://www.sqlite.org/2017/ sqlite-autoconf-${CURRENT_SQLITE}.tar.gz
|
2018-05-08 17:14:09 +00:00
|
|
|
fi
|