-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·58 lines (50 loc) · 1.75 KB
/
install.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
#!/bin/bash
set -u
err() {
printf "%s\n" "$@" >&2
exit 1
}
if [[ "$(uname -p)" =~ "arm" ]]; then
err "Unsupported CPU architecture: $(uname -p)."
fi
if [[ -n "${1-}" ]]
then
LIBQUIL_URL_PREFIX="https://github.com/rigetti/libquil/releases/download/v${1}"
else
LIBQUIL_URL_PREFIX="https://github.com/rigetti/libquil/releases/latest/download"
fi
OS="$(uname)"
if [[ "${OS}" == "Linux" ]]
then
IS_LINUX=1
LIBQUIL_RELEASE_FILE="linux-amd64.zip"
elif [[ "${OS}" == "Darwin" ]]
then
LIBQUIL_RELEASE_FILE="macos.zip"
else
err "Unsupported operating system. Supported operating systems are Linux and macOS."
fi
LIBQUIL_RELEASE_URL="${LIBQUIL_URL_PREFIX}/${LIBQUIL_RELEASE_FILE}"
LIBQUIL_TEMP_DIR="$(mktemp -d)"
LIBQUIL_LIB_PREFIX="/usr/local/lib"
LIBQUIL_INCLUDE_PREFIX="/usr/local/include/libquil"
pushd "${LIBQUIL_TEMP_DIR}" || exit
curl -L "${LIBQUIL_RELEASE_URL}" -o "${LIBQUIL_RELEASE_FILE}"
unzip "${LIBQUIL_RELEASE_FILE}"
if [[ -n "${IS_LINUX-}" ]]
then
sudo cp libquil/libquil.so libquil/libquil.core libquil/libsbcl.so "${LIBQUIL_LIB_PREFIX}"
sudo mkdir -p "${LIBQUIL_INCLUDE_PREFIX}"
sudo cp libquil/libquil.h "${LIBQUIL_INCLUDE_PREFIX}"
sudo ldconfig
else
sudo cp libquil/libquil.dylib libquil/libquil.core libquil/libsbcl.so "${LIBQUIL_LIB_PREFIX}"
sudo mkdir -p "${LIBQUIL_INCLUDE_PREFIX}"
sudo cp libquil/libquil.h "${LIBQUIL_INCLUDE_PREFIX}"
# This disables the "cannot open libquil.dylib from untrusted developer" dialog.
# A better solution for this would be to properly codesign the files, but that
# is a non-trivial amount of work.
sudo xattr -r -d com.apple.quarantine /usr/local/lib/libquil.dylib
sudo xattr -r -d com.apple.quarantine /usr/local/lib/libquil.core
sudo xattr -r -d com.apple.quarantine /usr/local/lib/libsbcl.so
fi