1 contributor
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
#!/bin/bash
hangar[path]=$HOME/.fgfs/flightgear-fgaddon/Aircraft
hangar[name]=FGADDON
hangar[source]=sourceforge
hangar[type]=svn
hangar[url]=https://svn.code.sf.net/p/flightgear/fgaddon/trunk/Aircraft
hangar[active]=1
function getfromrepo () {
svn cat ${hangar[url]}/$1
}
function on_exit () {
rm -f $aircrafts $aircraft
}
function parse_repo_history () {
function getaircraftinfo () {
svn list --xml --depth files ${hangar[url]}/$1 > $aircraft
unset xmlgetnext_empty_tag
while xmlgetnext; do
if test "$TAG" = 'name' && test "${VALUE/%-set.xml}" != "$VALUE"; then
add_setxml_for_aircraft $1 ${VALUE/%-set.xml}
fi
done < $aircraft
}
aircrafts=$temppath/Aircraft-$tempid
aircraft=$temppath/aircraft-$tempid
if test $latest_revision -eq 1; then
echo getting repository list
if ! svn list --xml --depth immediates ${hangar[url]} > $aircrafts; then
echo "error while retrieving list"
exit
fi
total=$(grep -c '<entry' $aircrafts)
is_ac=0
else
if test ${latest_revision:-0} -gt $(svn info --show-item revision ${hangar[url]}); then
echo "already latest revisison"
return
fi
echo "downloading history from revision ${latest_revision:-0}"
if ! svn log --revision ${latest_revision:-0}:HEAD --xml --verbose ${hangar[url]} > $aircrafts; then
echo "error while retrieving history"
exit
fi
total=$(grep -c '<logentry' $aircrafts)
fi
progress=0
echo parsing repository
unset xmlgetnext_empty_tag
while xmlgetnext; do
if test $latest_revision -eq 1; then
if test "$TAG" = 'entry kind="dir"'; then
is_ac=1
continue
elif test $is_ac -eq 0 -a "$TAG" != '/list'; then
continue
fi
else
if test "${TAG%% *}" = 'logentry'; then
is_ac=1
elif test ${is_ac:-0} -eq 0 -a "$TAG" != '/log'; then
continue
fi
fi
case "$TAG" in
'name')
add_record name $VALUE
;;
'logentry revision='*|'commit revision='*)
add_record revision ${TAG#*=}
;;
'author')
add_record author ${VALUE//\'/\'\'}
;;
'date')
add_record date $(date +%s -d "$VALUE")
;;
'path '*)
TAG=${TAG#* }
TAG=${TAG// /;}
TAG=${TAG//-/_}
eval $(echo ${TAG// /;})
path=(${VALUE//\// })
if test $kind = 'dir' -a ${#path[@]} -eq 3 -a $action = 'D'; then
sqlite_request "delete from setxml
where variantof in (
select id from aircrafts
where name = '${path[2]}'
and hangar = ${hangar[id]}
)"
sqlite_request "delete from aircrafts
where name = '${path[2]}'
and hangar = ${hangar[id]}"
is_ac=0
continue
fi
is_ac=1
add_record name ${path[2]}
;;
'/logentry'|'/entry')
getaircraftinfo $(get_record name)
add_aircraft
newprogress=$((++entry * 100 / $total))
if test $(( $newprogress - $progress )) -ge ${progress_granularity:-1}; then
progress=$newprogress
printf "\r%d%% (%d)" $progress $(sqlite_request 'select count(name) from recover_aircrafts')
fi
is_ac=0
;;
'/list'|'/log')
printf "\r\033[K"
apply_revision
break
;;
esac
done < $aircrafts
}