Repository navigation
Expand file tree
/
Copy pathinstall
More file actions
executable file
·101 lines (88 loc) · 3.14 KB
/
Copy pathinstall
File metadata and controls
executable file
·101 lines (88 loc) · 3.14 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
set -Eeuo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
STATE_DIR="$ROOT_DIR/build/.state"
ADAPTER_BUILD_DIR="$ROOT_DIR/build/adapters"
EXAMPLE_BUILD_DIR="$ROOT_DIR/build/examples"
PREFIX="${PREFIX:-/usr/local}"
DESTDIR="${DESTDIR:-}"
INSTALL_ROOT="${DESTDIR}${PREFIX}"
if [[ ! -f "$STATE_DIR/.configured" ]]; then
echo "The repository has not been configured." >&2
echo "Run ./configure and ./build.sh before ./install." >&2
exit 1
fi
if [[ ! -f "$STATE_DIR/.built" ]]; then
echo "The repository has not been built successfully." >&2
echo "Run ./build.sh before ./install." >&2
exit 1
fi
required_outputs=(
"$ROOT_DIR/build/rust/release/vds-server"
"$ROOT_DIR/build/rust/release/vds-cli"
"$ROOT_DIR/build/web/index.html"
"$ADAPTER_BUILD_DIR/spi-cuse/vds4e-spi-cuse"
"$ADAPTER_BUILD_DIR/i2c-cuse/vds4e-i2c-cuse"
"$ADAPTER_BUILD_DIR/gpio-sim/vds4e-gpio-sim"
"$ADAPTER_BUILD_DIR/uart-pty/vds4e-uart-pty"
"$EXAMPLE_BUILD_DIR/mt25ql256_tool"
"$EXAMPLE_BUILD_DIR/at24c256_tool"
"$EXAMPLE_BUILD_DIR/uart_ping"
"$EXAMPLE_BUILD_DIR/gpio_tool"
)
for output in "${required_outputs[@]}"; do
if [[ ! -e "$output" ]]; then
echo "Required build output is missing: $output" >&2
echo "Run ./build.sh again." >&2
exit 1
fi
done
install_file() {
local mode="$1"
local source="$2"
local destination="$3"
command install -D -m "$mode" "$source" "$destination"
}
install_tree() {
local source="$1"
local destination="$2"
command install -d "$destination"
cp -a "$source/." "$destination/"
}
echo "Installing into $INSTALL_ROOT..."
install_file 0755 "$ROOT_DIR/build/rust/release/vds-server" \
"$INSTALL_ROOT/bin/vds-server"
install_file 0755 "$ROOT_DIR/build/rust/release/vds-cli" \
"$INSTALL_ROOT/bin/vds-cli"
install_file 0755 "$ROOT_DIR/packaging/vds4e" \
"$INSTALL_ROOT/bin/vds4e"
install_file 0755 "$ADAPTER_BUILD_DIR/spi-cuse/vds4e-spi-cuse" \
"$INSTALL_ROOT/bin/vds4e-spi-cuse"
install_file 0755 "$ADAPTER_BUILD_DIR/i2c-cuse/vds4e-i2c-cuse" \
"$INSTALL_ROOT/bin/vds4e-i2c-cuse"
install_file 0755 "$ADAPTER_BUILD_DIR/gpio-sim/vds4e-gpio-sim" \
"$INSTALL_ROOT/bin/vds4e-gpio-sim"
install_file 0755 "$ADAPTER_BUILD_DIR/uart-pty/vds4e-uart-pty" \
"$INSTALL_ROOT/bin/vds4e-uart-pty"
install_file 0755 "$EXAMPLE_BUILD_DIR/mt25ql256_tool" \
"$INSTALL_ROOT/bin/mt25ql256_tool"
install_file 0755 "$EXAMPLE_BUILD_DIR/at24c256_tool" \
"$INSTALL_ROOT/bin/at24c256_tool"
install_file 0755 "$EXAMPLE_BUILD_DIR/uart_ping" \
"$INSTALL_ROOT/bin/uart_ping"
install_file 0755 "$EXAMPLE_BUILD_DIR/gpio_tool" \
"$INSTALL_ROOT/bin/gpio_tool"
install_tree "$ROOT_DIR/build/web" \
"$INSTALL_ROOT/share/vds4e/web"
install_tree "$ROOT_DIR/device-models/examples" \
"$INSTALL_ROOT/share/vds4e/device-models"
install_tree "$ROOT_DIR/schemas" \
"$INSTALL_ROOT/share/vds4e/schemas"
command install -d "$INSTALL_ROOT/share/vds4e"
sed \
"s#device-models/examples/#$PREFIX/share/vds4e/device-models/#g" \
"$ROOT_DIR/config/vds-server.yaml" \
>"$INSTALL_ROOT/share/vds4e/vds-server.example.yaml"
chmod 0644 "$INSTALL_ROOT/share/vds4e/vds-server.example.yaml"
echo
echo "Installation complete: $INSTALL_ROOT"