-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer_linux_x64.template
79 lines (58 loc) · 2.17 KB
/
installer_linux_x64.template
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
#!/bin/bash
SCRIPT_DIR=$(dirname "$0")
TERMINAL_DIR=$(dirname .)
if [[ $(/usr/bin/id -u) -eq 0 ]]; then
echo "WARNING: SCRIPT IS RUNNING AS SUDO, THIS IS NOT NECESSARY"
HOME_DIR=$(eval echo ~$SUDO_USER)
else
HOME_DIR=$(eval echo ~)
fi
INSTALL_DIR="$HOME_DIR/dsp-board-sdk"
function atexit()
{
cd $TERMINAL_DIR
}
trap atexit EXIT
echo "Installing DSPBoard SDK at $INSTALL_DIR"
echo ''
mkdir -p $INSTALL_DIR
PAYLOAD_LINE=$(awk '/^exit 0/ { print NR + 1; exit 0; }' $0)
# Decompress SDK files
tail -n +${PAYLOAD_LINE} $0 | tar -xvj -C $INSTALL_DIR
if [[ $(/usr/bin/id -u) -eq 0 ]]; then
chown $SUDO_USER:$SUDO_USER $INSTALL_DIR
chown root:root $INSTALL_DIR/vscode/chrome-sandbox
chmod 4755 $INSTALL_DIR/vscode/chrome-sandbox
DESKTOPARGS=""
else
DESKTOPARGS="--no-sandbox"
fi
# Create VSCode desktop shortcut
DESKTOPEXEC="Exec=$INSTALL_DIR/vscode/code %F $DESKTOPARGS"
DESKTOPICON="Icon=$INSTALL_DIR/vscode/resources/app/resources/linux/code.png"
#Modify VSCode settings
sed -i "s+SDK_PATH_TO_REMPLACE+$INSTALL_DIR+g" "$INSTALL_DIR/vscode/data/user-data/User/settings.json"
cp -f "$INSTALL_DIR/vscode/dsp-board-ide.desktop" "$HOME_DIR/.local/share/applications/dsp-board-ide.desktop"
echo $DESKTOPEXEC >> "$HOME_DIR/.local/share/applications/dsp-board-ide.desktop"
echo $DESKTOPICON >> "$HOME_DIR/.local/share/applications/dsp-board-ide.desktop"
chmod +x "$HOME_DIR/.local/share/applications/dsp-board-ide.desktop"
# Install openocd
echo "Do you want install OpenOCD 12.0? (This REQUIRES sudo) [y/N]"
read -e INSTALL_OPENOCD
echo ''
if [ $INSTALL_OPENOCD == "y" ] || [ $INSTALL_OPENOCD == "Y" ]; then
cd "$INSTALL_DIR/utils/openocd"
sudo make install
elif [ $INSTALL_OPENOCD == "n" ] || [ $INSTALL_OPENOCD == "N" ]; then
echo "OpenOCD will not install"
else
echo "WARNING: By default OPENOCD will not install."
fi
#Generate uninstaller
readarray -t UNINSTALLER_TEMPLATE < "$INSTALL_DIR/uninstaller_linux_x64.template"
UNINSTALLER_TEMPLATE[6]="INSTALL_DIR=$INSTALL_DIR"
printf '%s\n' "${UNINSTALLER_TEMPLATE[@]}" > "$INSTALL_DIR/uninstall.run"
rm -f "$INSTALL_DIR/uninstaller_linux_x64.template"
chmod +x "$INSTALL_DIR/uninstall.run"
echo "Done"
exit 0