-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·78 lines (68 loc) · 2.16 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
BUILD_DIR=build
EXEC=rp-scrabble
INSTALL_DIR=$HOME/.local/bin
LOG_DIR=$HOME/.local/share/rp-scrabble/logs
LOG_PARENT_DIR=$HOME/.local/share/rp-scrabble
case $1 in
"debian")
if ! cmake --version > /dev/null 2>&1; then
echo "cmake not installed, it is required for building from source"
echo "Installing cmake..."
if ! sudo apt update; then
echo "Aborting install"
exit 1
fi
if ! sudo apt install cmake; then
exit 1
fi
else
echo "cmake is installed"
fi
;;
"arch")
if ! cmake --version > /dev/null 2>&1; then
echo "cmake not installed, it is required for building from source"
echo "Installing cmake..."
if ! sudo pacman -S cmake; then
echo "Aborting install"
exit 1
fi
else
echo "cmake is installed"
fi
;;
"help")
echo "Usage: ./install.sh [ arch | debian | help | uninstall | custom ]"
exit 0
;;
"uninstall")
echo "Uninstalling rp-scrabble..."
rm -f --verbose $INSTALL_DIR/$EXEC
rm -rdf --verbose $LOG_PARENT_DIR
exit 0
;;
"custom")
if ! cmake --version > /dev/null 2>&1; then
echo "cmake not installed, it is required for building from source"
echo "Please install it using your distribution's package manager and rerun this script"
exit 1
else
echo "cmake is installed"
fi
;;
*)
echo "Invalid arguments"
echo "Usage: ./install.sh [ arch | debian | help | uninstall | custom ]"
exit 1
;;
esac
echo "Making build directories..."
if [ ! -d "$BUILD_DIR" ]; then mkdir -vp $BUILD_DIR; fi
if [ ! -d "$INSTALL_DIR" ]; then mkdir -vp $INSTALL_DIR; fi
if [ ! -d "$LOG_DIR" ]; then mkdir -vp $LOG_DIR; fi
echo "Building from source.."
cmake -B $BUILD_DIR -DCMAKE_BUILD_TYPE=Release && make -C $BUILD_DIR -j $(nproc)
echo "Installing..."
cp --verbose $BUILD_DIR/$EXEC $INSTALL_DIR
chmod 755 $INSTALL_DIR/$EXEC