-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall-qsv.sh
executable file
·75 lines (62 loc) · 2.19 KB
/
install-qsv.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# This installs qsv:
# "a command line program for querying, indexing, slicing, analyzing, filtering, enriching,
# transforming, sorting, validating & joining CSV files"
#
# Additional information available here:
# https://github.com/jqnatividad/qsv
#
# Additional information on available releases (including the latest versions) available here:
# https://github.com/jqnatividad/qsv/releases
QSV_BINARY=qsvpy310 # "qsv" is the binary with all features enabled (except python); "qsvlite" has extra features disabled and is much smaller in size
QSV_VERSION=0.125.0
case "$(uname -m)" in
x86_64)
CPU_ARCH="x86_64"
;;
arm64 | aarch64)
CPU_ARCH="aarch64" #"aarch64" for Apple Silicon and other ARM-based CPUs
;;
*)
CPU_ARCH="unknown"
echo "Unknown CPU architecture returned by uname -m: '${CPU_ARCH}'" >&2
exit 1
;;
esac
case "$(uname -s)" in
Linux)
OS_BUILD_TYPE="unknown-linux-gnu" # "unknown-linux-musl" for Linux platforms where libc compatability is an issue, otherwise "unknown-linux-gnu"
;;
Darwin)
OS_BUILD_TYPE="apple-darwin"
;;
*)
OS_BUILD_TYPE="unknown"
echo "Unknown OS type returned by uname -s: '${OS_BUILD_TYPE}'" >&2
exit 1
;;
esac
if ! command -v curl &> /dev/null; then
echo "curl is required but it does not appear to be installed" >&2
exit 1
fi
PACKAGE_ZIP=qsv-${QSV_VERSION}-${CPU_ARCH}-${OS_BUILD_TYPE}.zip
echo "Downloading binary for ${OS_BUILD_TYPE} built for ${CPU_ARCH}: ${PACKAGE_ZIP}"
curl --silent --location --output $PACKAGE_ZIP https://github.com/jqnatividad/qsv/releases/download/${QSV_VERSION}/${PACKAGE_ZIP}
# unzip only the qsv binary to its final location (the zip archive also contains alternate builds)
unzip -o -d /usr/local/bin $PACKAGE_ZIP ${QSV_BINARY}
rm $PACKAGE_ZIP
chmod 755 /usr/local/bin/${QSV_BINARY}
# if copying in an alternate build of qsv, symlink it to "qsv"
if [[ "$QSV_BINARY" != "qsv" ]]; then
if [ ! -f /usr/local/bin/qsv ]; then
ln -s /usr/local/bin/${QSV_BINARY} /usr/local/bin/qsv
fi
fi
hash -r
if ! command -v qsv &> /dev/null; then
echo "The qsv installation seems to have failed" >&2
exit 1
else
echo "qsv installation successful."
fi