-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathubuntu.sh
78 lines (65 loc) · 1.74 KB
/
ubuntu.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/sh
########################################
# Read the command line argument
########################################
if [ "$#" -ne "1" ]; then
echo "ERROR: No target directory was given!"
echo "usage: $0 /path/to/empty/dir"
exit 1
fi
README="$(dirname "$(realpath "$0")")/README.md"
BUILDDIR="$(realpath "$1")"
if [ ! -d "$BUILDDIR" ] || [ ! -z "$(ls -A "$BUILDDIR")" ]; then
echo "ERROR: Installation needs an empty directory as a target!"
echo "usage: $0 /path/to/empty/dir"
exit 1
fi
cd "$BUILDDIR" || exit
########################################
# STEP 0: Check for all dependencies
########################################
required="
bc
bison
build-essential
cmake
curl
flex
git
libboost-all-dev
libcap-dev
libncurses5-dev
python-minimal
python-pip
subversion
unzip
zlib1g-dev
"
if lsb_release -a 2>> /dev/null | grep -q "Ubuntu"; then
# if we are on Ubuntu
error=0
for pkg in $required
# for all required packages
do
# Check, if this package is installed
if ! dpkg -l "$pkg" >> /dev/null 2>&1; then
echo "Error: $pkg is not installed"
error=1
fi
done
if [ $error -eq 1 ]; then
echo "STOP: Not all dependencies installed"
exit 1
fi
fi
# This extracts all commands from the README.md and executes them
eval "$( \
# Extract all relevant build steps -> Step 1 until 6, excluding 7
sed -n '/## Step 1: LLVM/,/## Step 7: Link some executables/p' "$README" | \
# Extract all marked code snippets
sed -n '/```/,/```/p' | grep -v '```' | \
# Remove comments and the automatic assignment of BUILDDIR and empty lines
grep -v '^#' | grep -v '^BUILDDIR=' | awk 'NF > 0' \
)"
echo ""
echo "Congratulations. $BUILDDIR is initialized completely"