-
Notifications
You must be signed in to change notification settings - Fork 4
/
update.sh
executable file
·84 lines (71 loc) · 3.13 KB
/
update.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
79
80
81
82
83
84
#!/usr/bin/env bash
# if your local copy is modified and you want to ensure it is the same as the master, you can erase all the changes by running
# git reset --hard origin/master
# find location of the script, which should be root of useTracker
# from http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
cd $DIR
echo Updating > update_status.txt
(
echo "# Pulling update from github repository" ; git pull &> update_status.txt
error=$(cat update_status.txt | grep Aborting | wc -l)
wxversion=3.0
# make sure you all necessary packages installed
if [ $error -eq 0 ]; then
zenity --info --text "About to update required package dependencies"
(echo "# Updating packages..."; pkexec apt-get --yes install build-essential cmake premake4 libwxbase$wxversion-dev libopencv-dev libboost-program-options-dev libboost-filesystem-dev libwxgtk$wxversion-dev libwxgtk-media$wxversion-dev freeglut3-dev libva-dev libbz2-dev libx264-dev libbluetooth-dev
) |
zenity --progress \
--title="Updating package dependencies for USE Tracker" \
--progress\
--auto-close\
--pulsate
fi
if [ $error -eq 0 ]; then
echo "# Cleaning sources"; make clean &> update_status.txt
echo "# Building arucoColor"; cd arucoColor; premake4 gmake &> update_status.txt; make config=release clean &> update_status.txt; make config=release &> update_status.txt; cd ..
echo "# Building from updated sources"; make release &> update_status.txt
fi
) |
zenity --progress \
--title="Updating USE Tracker" \
--progress\
--auto-close\
--pulsate
error=$(cat update_status.txt | grep Aborting | wc -l)
if [ $error != 0 ] ; then
zenity --error \
--text="Could not pull files from GitHub.com\nUpdate canceled."
exit -1
fi
error=$(ls ./bin/Release/useTracker | wc -l)
if [ $error -eq 0 ]; then
zenity --error \
--text="Could not compile USE Tracker.\nUpdate canceled."
exit -1
fi
#zenity --info --text "About to install USE Tracker to system directory"
#(echo "# Installing"; gksudo -S -m "Installing USE Tracker to system directories" "cp ./bin/Release/useTracker /usr/bin/"
#) |
zenity --info --text "About to install USE Tracker to system directory"
(echo "# Installing"; pkexec install $(pwd)/bin/Release/useTracker /usr/bin/; pkexec install $(pwd)/images/* /usr/share/useTracker/images/
) |
zenity --progress \
--title="Updating USE Tracker" \
--progress\
--auto-close\
--pulsate
m1=$(md5sum ./bin/Release/useTracker | cut -f 1 -d ' ')
m2=$(md5sum /usr/bin/useTracker | cut -f 1 -d ' ')
if [ $m1 != $m2 ]; then
zenity --error \
--text="Could not install USE Tracker.\nPlease close all instances of USE Tracker or try to restart.\nUpdate canceled."
exit -1
fi
zenity --info --text="Update successful."