-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetchvendor.sh
48 lines (45 loc) · 1.36 KB
/
fetchvendor.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
43
44
45
46
47
48
#!/bin/sh
#
# Auxiliary script that downloads the 3rd-party libraries into directory
# `vendor/`, if the source code repository has not been cloned recursively with
# Git. The following libraries are fetched and unpacked:
#
# * fortran-curl
# * fortran-lua54
# * fortran-modbus
# * fortran-pcre2
# * fortran-sqlite3
# * fortran-unix
# * fortran-xmpp
# * fortran-zlib
# * fortran-zstd
#
# The curl(1) and unzip(1) command-line programs are required.
#
set -e
VENDOR=${1-"./vendor"}
CURL=curl
UNZIP=unzip
LIBS="curl lua54 modbus pcre2 sqlite3 unix xmpp zlib zstd"
echo "Creating ${VENDOR} ..."
mkdir -p ${VENDOR}
for LIB in ${LIBS}; do
LIBNAME="fortran-${LIB}"
LIBPATH="${VENDOR}/${LIBNAME}"
echo "Searching for ${LIBNAME} ..."
[ -e "${LIBPATH}/Makefile" ] && echo "Error: ${LIBNAME} exists" && exit 1
[ -d ${LIBPATH} ] && rm -r ${LIBPATH} && echo "Deleted ${LIBPATH}"
LIBURL="https://codeload.github.com/interkosmos/${LIBNAME}/zip/refs/heads/master"
LIBMASTER="${LIBNAME}-master"
LIBZIP="${LIBMASTER}.zip"
LIBFILE="${VENDOR}/${LIBZIP}"
LIBDIR="${VENDOR}/${LIBNAME}"
echo "Fetching ${LIBZIP} ..."
${CURL} -L -s -o ${LIBFILE} ${LIBURL}
echo "Unpacking ${LIBZIP} ..."
${UNZIP} -q -d ${VENDOR} ${LIBFILE}
echo "Deleting ${LIBZIP} ..."
rm ${LIBFILE}
echo "Renaming directory ..."
mv "${VENDOR}/${LIBMASTER}" ${LIBDIR}
done