forked from ArduPilot/ardupilot_wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·136 lines (109 loc) · 4.08 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
# check for changes in docs and run sphinx
export PYTHONUNBUFFERED=1
cd $HOME/build_wiki || exit 1
START=$(date +%s)
############################
# grab a lock file. Not atomic, but close :)
# tries to cope with NFS
lock_file() {
lck="$1"
pid=`cat "$lck" 2> /dev/null`
if test -f "$lck" && kill -0 $pid 2> /dev/null; then
LOCKAGE=$(($(date +%s) - $(stat -c '%Y' "build.lck")))
test $LOCKAGE -gt 30000 && {
echo "old lock file $lck is valid for $pid with age $LOCKAGE seconds"
}
return 1
fi
/bin/rm -f "$lck"
echo "$$" > "$lck"
return 0
}
lock_file build.lck || {
echo "$(date +%s) already locked" >>build.lck.log
exit 1
}
test -n "$FORCEBUILD" || {
(cd ardupilot_wiki && git fetch > /dev/null 2>&1)
(cd sphinx_rtd_theme && git fetch > /dev/null 2>&1)
changed=0
oldhash=$(cd ardupilot_wiki && git rev-parse origin/master)
newhash=$(cd ardupilot_wiki && git rev-parse HEAD)
[ "$oldhash" = "$newhash" ] || {
echo "ardupilot_wiki has changed $newhash $oldhash"
changed=1
}
oldhash=$(cd sphinx_rtd_theme && git rev-parse origin/master)
newhash=$(cd sphinx_rtd_theme && git rev-parse HEAD)
[ "$oldhash" = "$newhash" ] || {
echo "sphinx_rtd_theme has changed $newhash $oldhash"
changed=1
}
PARAMSITES="ArduPlane ArduCopter AntennaTracker Rover AP_Periph Blimp"
mkdir -p old_params new_params
for site in $PARAMSITES; do
wget "https://autotest.ardupilot.org/Parameters/$site/Parameters.rst" -O new_params/$site.rst 2> /dev/null
done
for site in $PARAMSITES; do
if ! cmp new_params/$site.rst old_params/$site.rst; then
echo "$site.rst has changed"
cp new_params/$site.rst old_params/$site.rst
changed=1
fi
done
LOGMESSAGESITES="Plane Copter Tracker Rover Blimp"
mkdir -p old_logmessages new_logmessages
for site in $LOGMESSAGESITES; do
wget "https://autotest.ardupilot.org/LogMessages/$site/LogMessages.rst" -O new_logmessages/$site.rst 2> /dev/null
done
for site in $LOGMESSAGESITES; do
if ! cmp new_logmessages/$site.rst old_logmessages/$site.rst; then
echo "$site.rst has changed"
cp new_logmessages/$site.rst old_logmessages/$site.rst
changed=1
fi
done
[ $changed = 1 ] || exit 0
}
(
date
report() {
cat <<EOF | mail -s 'wiki build failed' [email protected]
A wiki build failed
EOF
}
echo "[Buildlog] Updating ardupilot_wiki at $(date '+%Y-%m-%d-%H-%M-%S')"
pushd ardupilot_wiki
git checkout -f master
git fetch origin
git submodule update
git reset --hard origin/master
git clean -f -f -x -d -d
popd
echo "[Buildlog] Updating sphinx_rtd_theme at $(date '+%Y-%m-%d-%H-%M-%S')"
pushd sphinx_rtd_theme
git checkout -f master
git fetch origin
git submodule update
git reset --hard origin/master
git clean -f -f -x -d -d
python3 -m pip install --user -U .
popd
cd ardupilot_wiki
find -name "parameters*rst" -delete # Clean possible built and cached parameters files
END_UPDATES=$(date +%s)
echo "[Buildlog] Starting to build multiple parameters pages at $(date '+%Y-%m-%d-%H-%M-%S')"
python3 build_parameters.py
END_BUILD_MPARAMS=$(date +%s)
MPARAMS_TIME=$(echo "($END_BUILD_MPARAMS - $END_UPDATES)" | bc)
echo "[Buildlog] Time to run build_parameters.py: $MPARAMS_TIME seconds"
echo "[Buildlog] Starting to build the wiki at $(date '+%Y-%m-%d-%H-%M-%S')"
# python3 update.py --clean --parallel 4 # Build without versioning for parameters. It is better for editing wiki.
python3 update.py --destdir /var/sites/wiki/web --clean --paramversioning --parallel 4 --enablebackups --verbose # Enables parameters versioning and backups, should be used only on the wiki server
END_BUILD_WIKI=$(date +%s)
WIKI_TIME=$(echo "($END_BUILD_WIKI - $END_BUILD_MPARAMS)/60" | bc)
echo "[Buildlog] Time to build the wiki itself: $WIKI_TIME minutes"
SCRIPT_TIME=$(echo "($END_BUILD_WIKI - $START)/60" | bc)
echo "[Buildlog] Time to run the full script: $SCRIPT_TIME minutes"
) >> update.log 2>&1