ajout de gestion de bdd pour...
|
1 |
#!/bin/bash |
2 | ||
ré-écriture complète
|
3 |
set -e |
4 | ||
5 |
declare -A data=( |
|
6 |
[/sim/description]=text |
|
7 |
[/sim/long-description]=text |
|
8 |
[/sim/author]=text |
|
9 |
[/sim/flight-model]=text |
|
10 |
[/sim/type]=text |
|
11 |
[/sim/model/path]=text |
|
12 |
) |
|
complete rewrite
|
13 | |
14 |
missing_data_check=( /sim/model/path ) |
|
15 | ||
ré-écriture complète
|
16 |
database=${DB:-$0.db} |
complete rewrite
|
17 |
test -r "$0.conf" && source "$0.conf" |
18 | ||
ré-écriture complète
|
19 |
#locale=fr |
20 | ||
complete rewrite
|
21 |
tempid=$(mktemp --dry-run XXXXXXX) |
22 |
temppath=/dev/shm |
|
ré-écriture complète
|
23 | |
complete rewrite
|
24 |
setxml=$temppath/setxml-$tempid |
25 |
json_file=$temppath/github_json-$tempid |
|
26 |
in_ram_database=$temppath/${database##*/}-$tempid |
|
ajout de gestion de bdd pour...
|
27 | |
ré-écriture complète
|
28 |
function xmlgetnext () { |
29 |
local IFS='>' |
|
30 |
read -d '<' TAG VALUE |
|
31 |
# by design, the first TAG/VALUE pair is empty |
|
32 |
# to avoid infinite loops at end of file parsing we return an error |
|
33 |
# the next time we find an empty TAG |
|
34 |
if test -z "$TAG"; then |
|
better infinite loop check
|
35 |
test ${xmlgetnext_empty_tag:-0} -gt 0 && return 1 |
36 |
xmlgetnext_empty_tag=$(( xmlgetnext_empty_tag + 1 )) |
|
ré-écriture complète
|
37 |
fi |
38 |
# process $TAG only if necessary |
|
39 |
local _TAG=$(printf '%q' $TAG) |
|
40 |
if test ${_TAG:0:1} = '$'; then |
|
41 |
TAG=$(tr '\n' ' ' <<< $TAG | sed 's/ */ /g; s/ *$//') |
|
42 |
fi |
|
ajout de gestion de bdd pour...
|
43 |
} |
44 | ||
complete rewrite
|
45 |
function json () { |
46 |
jq --raw-output "$1" < ${2:-${json_file:?}} |
|
47 |
} |
|
48 | ||
49 |
rm -f $temppath/sqlite_request |
|
ajout de gestion de bdd pour...
|
50 |
function sqlite_request () { |
complete rewrite
|
51 |
echo -e "## REQ $(( ++sqlite_request_count ))\n${1}\n" >> $temppath/sqlite_request |
52 |
sqlite3 "$in_ram_database" <<< "$1" |
|
ré-écriture complète
|
53 |
} |
54 | ||
55 |
function xmlremovecomments () { |
|
56 |
sed -ri 's/<(!--|script>)/\n&/;s/(<\/script|--)>/&\n/' $setxml |
|
57 |
sed -ri '/<(script>|!--).*(<\/script|--)>/d;/<(script>|!--)/,/(<\/script|--)>/d' $setxml |
|
complete rewrite
|
58 |
sed -i 's/\xef\xbb\xbf//;s/\r//' $setxml # removes BOM and ^M |
ré-écriture complète
|
59 |
} |
60 | ||
61 |
function trap_break () { |
|
62 |
trap '' INT |
|
63 |
echo "stop requested" |
|
ajout de gestion de bdd pour...
|
64 |
} |
65 | ||
66 |
function trap_exit () { |
|
ré-écriture complète
|
67 |
trapped_rc=$? |
68 |
trap '' INT |
|
complete rewrite
|
69 | |
70 |
if declare -f on_exit > /dev/null; then |
|
71 |
on_exit |
|
72 |
fi |
|
73 | ||
ré-écriture complète
|
74 |
if test ! -e $in_ram_database; then |
75 |
exit |
|
76 |
fi |
|
many improvements
|
77 |
echo "updating installation status" |
ré-écriture complète
|
78 |
for ac in $(sqlite_request 'select printf("%i:%s/%s", aircrafts.id, aircrafts.name, setxml.file) |
79 |
from aircrafts inner join setxml |
|
80 |
where aircrafts.id = setxml.variantof and setxml.installed != 0;'); do |
|
many improvements
|
81 |
ac_path=${ac#*:} |
complete rewrite
|
82 |
if test ! -e ${hangar[path]}/$ac_path-set.xml; then |
many improvement
|
83 |
sqlite_request "update setxml set installed = 0 where file = '${ac_path#*/}' and variantof = ${ac%:*}" |
84 |
fi |
|
85 |
done |
|
complete rewrite
|
86 |
for ac in ${hangar[path]}/*/*-set.xml; do |
87 |
ac=${ac/${hangar[path]}} |
|
many improvement
|
88 |
sx=${ac##*/} |
89 |
ac=${ac%/*} |
|
complete rewrite
|
90 |
if test -d ${hangar[path]}/$ac/.svn; then |
many improvement
|
91 |
install_type=1 |
complete rewrite
|
92 |
elif test -d ${hangar[path]}/$ac/.git; then |
many improvement
|
93 |
install_type=2 |
94 |
else |
|
95 |
install_type=3 |
|
96 |
fi |
|
97 |
sqlite_request "update setxml set installed = $install_type |
|
98 |
where exists ( |
|
ré-écriture complète
|
99 |
select 1 |
100 |
from aircrafts |
|
101 |
where name = '${ac/\/}' and setxml.variantof = id |
|
many improvement
|
102 |
)" |
many improvements
|
103 |
done |
complete rewrite
|
104 |
local missing_setxml=$(sqlite_request "select printf(' - %s (%s)', aircrafts.name, hangars.name) |
105 |
from aircrafts inner join hangars |
|
106 |
where hangars.id = aircrafts.hangar and aircrafts.id not in (select variantof from setxml)") |
|
ré-écriture complète
|
107 |
if test -n "$missing_setxml"; then |
improve output for missing a...
|
108 |
echo -e "missing setxml config for :\n$missing_setxml" |
ré-écriture complète
|
109 |
fi |
complete rewrite
|
110 | |
111 |
for data_presence_check in ${missing_data_check[@]}; do |
|
112 |
if [[ -v data[$data_presence_check] ]]; then |
|
113 |
local missing_data=$(sqlite_request "select count(setxml.file) |
|
114 |
from aircrafts inner join setxml |
|
115 |
where aircrafts.id = setxml.variantof and setxml.\`$data_presence_check\` = ''") |
|
116 |
if test $missing_data -gt 0; then |
|
117 |
echo "$missing_data aircrafts without $data_presence_check information" |
|
118 |
if test $missing_data -le 10; then |
|
119 |
echo "aircrafts without $data_presence_check information:" |
|
120 |
sqlite_request "select printf(' - %s/%s (%s)', aircrafts.name, setxml.file, hangars.name) |
|
121 |
from aircrafts inner join setxml, hangars |
|
122 |
where |
|
123 |
aircrafts.id = setxml.variantof |
|
124 |
and |
|
125 |
aircrafts.hangar = hangars.id |
|
126 |
and |
|
127 |
setxml.\`$data_presence_check\` = ''" |
|
128 |
fi |
|
129 |
fi |
|
list missing models
|
130 |
fi |
complete rewrite
|
131 |
done |
132 | ||
ajout de gestion de bdd pour...
|
133 |
if test -r "$database" && md5sum $in_ram_database | sed "s,$in_ram_database,$database," | md5sum --status -c -; then |
many improvements
|
134 |
echo "no changes in $database" |
ajout de gestion de bdd pour...
|
135 |
elif test -w "$database"; then |
complete rewrite
|
136 |
rm -f "$database" |
137 |
sqlite_request '.dump' | sqlite3 "$database" |
|
many improvements
|
138 |
echo "database $database updated" |
complete rewrite
|
139 |
elif test ! -e "$database" -a -w ${database%/*}; then |
140 |
sqlite_request '.dump' | sqlite3 "$database" |
|
many improvements
|
141 |
echo "database $database created" |
ajout de gestion de bdd pour...
|
142 |
else |
many improvements
|
143 |
echo "nothing can be done with $database !" |
ajout de gestion de bdd pour...
|
144 |
fi |
complete rewrite
|
145 |
rm -f $temppath/*-$tempid |
ré-écriture complète
|
146 |
} |
147 | ||
148 |
function update_database () { |
|
complete rewrite
|
149 |
sqlite_request "insert into aircrafts (name, author, revision, date, hangar) |
150 |
select name, author, revision, date, hangar from recover_aircrafts |
|
151 |
where recover_aircrafts.name = '$ac' and recover_aircrafts.hangar = ${hangar[id]} |
|
152 |
on conflict (name, hangar) where aircrafts.name = '$ac' and aircrafts.hangar = ${hangar[id]} do |
|
153 |
update set |
|
154 |
author = (select author from recover_aircrafts where name = '$ac'), |
|
155 |
revision = (select revision from recover_aircrafts where name = '$ac'), |
|
156 |
date = (select date from recover_aircrafts where name = '$ac') |
|
157 |
where aircrafts.name = '$ac' and aircrafts.hangar = ${hangar[id]}" |
|
ajout de gestion de bdd pour...
|
158 | |
complete rewrite
|
159 |
id=$(sqlite_request "select id from aircrafts where name is '${ac}' and hangar = ${hangar[id]}") |
try to fix left to do count
|
160 | |
complete rewrite
|
161 |
echo $(sqlite_request "select printf('[ %i/%i ] $ac', count(sx), count(distinct ac)) from recover_setxml") |
162 | ||
fix when aircraft updated mu...
|
163 |
for sx in $(sqlite_request "select distinct sx from recover_setxml where ac = '$ac'"); do |
ré-écriture complète
|
164 |
for col in ${!data[@]}; do |
165 |
data[$col]= |
|
166 |
done |
|
complete rewrite
|
167 | |
remove -set.xml from filenam...
|
168 |
echo " -> $sx" |
complete rewrite
|
169 |
getfromrepo ${ac}/$sx-set.xml > $setxml |
ré-écriture complète
|
170 | |
complete rewrite
|
171 |
unset xmlgetnext_empty_tag property include include_rootpath ac_save |
172 |
while xmlgetnext; do |
|
ré-écriture complète
|
173 |
if [[ "$TAG" =~ ^"PropertyList include=" ]]; then |
174 |
include_rootpath=${include%/*} |
|
175 |
test $include = $include_rootpath && unset include_rootpath |
|
complete rewrite
|
176 | |
177 |
eval $(echo ${TAG#* }) # include="..." |
|
178 | ||
179 |
if [[ "$include" =~ ^Aircraft/Generic/ ]]; then |
|
180 |
unset include include_rootpath |
|
181 |
continue |
|
182 | ||
183 |
elif [[ "$include" =~ ^'../' ]]; then |
|
ré-écriture complète
|
184 |
if test -n "$include_rootpath"; then |
185 |
if [[ "$include_rootpath" =~ '/' ]]; then |
|
186 |
include_rootpath=${include_rootpath%/*} |
|
187 |
else |
|
188 |
unset include_rootpath |
|
189 |
fi |
|
190 |
else |
|
191 |
ac_save=$ac |
|
192 |
unset ac |
|
193 |
fi |
|
194 |
include=${include/\.\.\/} |
|
195 |
fi |
|
complete rewrite
|
196 |
getfromrepo ${ac}/${include_rootpath:+$include_rootpath/}$include >> $setxml |
ré-écriture complète
|
197 |
fi |
complete rewrite
|
198 |
done < $setxml |
199 | ||
200 |
test -n "$ac_save" && ac=$ac_save |
|
201 | ||
202 |
# some aircrafts (mostly from the helijah's files architecture template) |
|
203 |
# break because of infinite loop in middle of file |
|
204 |
# I can't find the reason of this infinite loop |
|
205 |
# this is the reason of this double-pass |
|
206 |
unset xmlgetnext_empty_tag property |
|
207 |
while xmlgetnext; do |
|
208 |
case "${TAG:0:1}" in |
|
209 |
''|'?'|'!') |
|
210 |
continue;; |
|
211 |
/) |
|
212 |
property=${property%/*};; |
|
213 |
*) |
|
214 |
if test "${TAG: -1}" != '/'; then |
|
215 |
property+=/${TAG%% *} |
|
216 |
fi;; |
|
217 |
esac |
|
ré-écriture complète
|
218 | |
219 |
if [[ "$property" = /PropertyList@($data_pattern) ]]; then |
|
fix overriding descs with in...
|
220 |
if test -z "${data[${property/\/PropertyList}]}"; then |
221 |
eval "data[${property/\/PropertyList}]=\"${VALUE//\"/\\\"}\"" |
|
222 |
data[${property/\/PropertyList}]=$(tr '\n' ' ' <<< ${data[${property/\/PropertyList}]} | sed -r 's/^\s*//;s/\s+/ /g;s/\s*$//') |
|
223 |
fi |
|
many improvement
|
224 |
fi |
ajout de gestion de bdd pour...
|
225 | |
ré-écriture complète
|
226 |
# continue parsing (while loop) until everything's found |
227 |
for col in ${!data[@]}; do |
|
228 |
test -z "${data[$col]}" && continue 2 |
|
229 |
done |
|
230 |
break # everything's found |
|
231 |
done < $setxml |
|
ajout de gestion de bdd pour...
|
232 | |
ré-écriture complète
|
233 |
if eval "test -z \"$data_test_null\""; then |
234 |
echo "WARNING: no info found, skipping" |
|
complete rewrite
|
235 |
mkdir -p $temppath/no-data-ac |
236 |
cp -f $setxml $temppath/no-data-ac/${ac}-${sx} |
|
ajout de gestion de bdd pour...
|
237 |
else |
complete rewrite
|
238 |
insert_values="'$sx', $id, " |
239 |
insert_col='file, variantof, ' |
|
240 |
update_values='' |
|
ré-écriture complète
|
241 |
for col in ${!data[@]}; do |
complete rewrite
|
242 |
insert_col+="\`$col\`, " |
243 |
insert_values+="'${data[$col]//\'/\'\'}', " |
|
244 |
if test -n "${data[$col]}"; then |
|
245 |
update_values+="\`$col\` = '${data[$col]//\'/\'\'}', " |
|
246 |
fi |
|
ré-écriture complète
|
247 |
done |
complete rewrite
|
248 |
sqlite_request "insert into setxml (${insert_col%,*}, installed) values (${insert_values%,*}, 0) |
249 |
on conflict (file, variantof) where file = '$sx' and variantof = $id do |
|
250 |
update set |
|
251 |
${update_values%,*}, installed = 0 |
|
252 |
where |
|
253 |
file = '$sx' and variantof = $id" |
|
ré-écriture complète
|
254 |
fi |
complete rewrite
|
255 | |
256 |
sqlite_request "delete from recover_setxml where ac = '$ac' and sx = '$sx'" |
|
257 |
done |
|
258 |
} |
|
259 | ||
260 |
function add_record () { |
|
261 |
ac_ass_array[$1]="$2" |
|
262 |
} |
|
263 | ||
264 |
function get_record () { |
|
265 |
if test -n "$1"; then |
|
266 |
echo "${ac_ass_array[$1]}" |
|
267 |
else |
|
268 |
for k in ${!ac_ass_array[@]}; do |
|
269 |
echo $k = ${ac_ass_array[$k]} |
|
270 |
done |
|
271 |
fi |
|
272 |
} |
|
273 | ||
274 |
function add_aircraft () { |
|
275 |
for key in name revision date author; do |
|
better comment explanation
|
276 |
test -n "${ac_ass_array[$key]}" # exit if missing data (with the help of "set -e") |
complete rewrite
|
277 |
done |
fix issue with multiple revi...
|
278 |
local new_revision=$(sqlite_request "select revision from recover_aircrafts |
279 |
where name = '${ac_ass_array[name]}'") |
|
280 |
if test -z "${new_revision}"; then |
|
281 |
sqlite_request "insert into recover_aircrafts (name, revision, date, author, hangar) |
|
282 |
values ( |
|
283 |
'${ac_ass_array[name]}', |
|
284 |
${ac_ass_array[revision]}, |
|
285 |
${ac_ass_array[date]}, |
|
286 |
'${ac_ass_array[author]}', |
|
287 |
${hangar[id]})" |
|
288 |
elif test ${new_revision} -lt ${ac_ass_array[revision]//\"}; then |
|
289 |
sqlite_request "update recover_aircrafts |
|
290 |
set |
|
291 |
revision = ${ac_ass_array[revision]}, |
|
292 |
date = ${ac_ass_array[date]}, |
|
293 |
author = '${ac_ass_array[author]}', |
|
294 |
hangar = ${hangar[id]} |
|
295 |
where name = '${ac_ass_array[name]}'" |
|
296 |
fi |
|
complete rewrite
|
297 |
for key in name revision date author; do |
298 |
ac_ass_array[$key]='' |
|
ré-écriture complète
|
299 |
done |
300 |
} |
|
301 | ||
complete rewrite
|
302 |
function add_setxml_for_aircraft () { |
fix issue with multiple revi...
|
303 |
sqlite_request "insert into recover_setxml values ('$1', '${2/%-set.xml}') |
304 |
on conflict (ac, sx) where ac = '$1' and sx = '${2/%-set.xml}' |
|
305 |
do nothing" |
|
complete rewrite
|
306 |
} |
307 | ||
ré-écriture complète
|
308 |
function apply_revision () { |
complete rewrite
|
309 |
for ac in $(sqlite_request "select name from recover_aircrafts"); do |
310 |
# delete aircrafts that have been deleted from the repo |
|
311 |
sqlite_request "delete from setxml |
|
312 |
where (file, variantof) in ( |
|
313 |
select file, variantof from setxml |
|
314 |
inner join aircrafts |
|
315 |
where aircrafts.id = setxml.variantof |
|
316 |
and aircrafts.name = '$ac' |
|
317 |
and aircrafts.hangar = ${hangar[id]} |
|
318 |
and setxml.file not in ( |
|
319 |
select sx from recover_setxml where ac = '$ac' |
|
320 |
) |
|
321 |
)" |
|
322 | ||
323 |
# delete aircrafts without setxml found |
|
324 |
sqlite_request "delete from recover_aircrafts |
|
325 |
where name not in (select distinct ac from recover_setxml)" |
|
326 | ||
ré-écriture complète
|
327 |
update_database |
complete rewrite
|
328 |
if test -d ${hangar[path]}/${ac}/.${hangar[type]} \ |
329 |
&& \ |
|
330 |
case ${hangar[type]} in |
|
331 |
svn) test "$(svn info --show-item=url ${hangar[path]}/${ac})" != "${hangar[url]}/${ac}";; |
|
fix git discovering of aircr...
|
332 |
git) test "$(git -C ${hangar[path]}/${ac} config --get remote.origin.url)" != "${hangar[url]}/${ac}.git";; |
complete rewrite
|
333 |
esac \ |
334 |
|| test -d ${hangar[path]}/${ac} -a ! -d ${hangar[path]}/${ac}/.${hangar[type]}; then |
|
335 |
echo "INFO: local ${ac} installed out from repo" >&2 |
|
ajout de gestion de bdd pour...
|
336 |
fi |
complete rewrite
|
337 |
sqlite_request "delete from recover_aircrafts where name = '$ac'" |
ajout de gestion de bdd pour...
|
338 |
done |
339 |
} |
|
340 | ||
ré-écriture complète
|
341 |
trap trap_break INT |
ajout de gestion de bdd pour...
|
342 |
trap trap_exit EXIT |
343 | ||
ré-écriture complète
|
344 |
stty -echoctl |
345 | ||
complete rewrite
|
346 |
declare -A hangar |
ré-écriture complète
|
347 |
data_pattern=$(printf "%s|" ${!data[@]}) |
348 |
data_pattern=${data_pattern:0:-1} |
|
349 |
data_test_null=$(printf '${data[%s]}' ${!data[@]}) |
|
350 | ||
351 |
if test -e $database; then |
|
352 |
cp $database $in_ram_database |
|
complete rewrite
|
353 | |
ré-écriture complète
|
354 |
sql_cols=$(sqlite_request "pragma table_info(setxml)" | awk -F'|' '{printf("%s %s ", $2, $3)}') |
355 |
script_cols="file text variantof integer " |
|
356 |
for col in ${!data[@]}; do |
|
357 |
script_cols+="$col ${data["$col"]} " |
|
358 |
done |
|
359 |
script_cols+="installed integer " # last space is important |
|
360 |
if test "$sql_cols" != "$script_cols"; then |
|
361 |
echo "ALERT: datbase version mismatch !" |
|
362 |
exit 1 |
|
363 |
fi |
|
complete rewrite
|
364 |
if sqlite_request '.tables' | grep -q 'recover_'; then |
ré-écriture complète
|
365 |
echo "recovering from previous saved state" |
complete rewrite
|
366 |
hangar[id]=$(sqlite_request "select hangar from recover_aircrafts limit 1") |
367 |
eval $(sqlite_request "select printf('hangar[name]=%s;hangar[url]=%s;hangar[type]=%s;hangar[source]=%s', |
|
368 |
name, url, type, source) |
|
369 |
from hangars |
|
370 |
where id = '${hangar[id]}'") |
|
371 |
source $(grep -l "^\s*hangar\[name\]=${hangar[name]}\s*$" ${0%*/}.d/*.hangar) |
|
372 |
eval "getfromrepo () {$(declare -f getfromrepo | sed '1,2d;$d'); xmlremovecomments;}" |
|
ré-écriture complète
|
373 |
apply_revision |
374 |
exit |
|
375 |
fi |
|
376 |
fi |
|
377 | ||
complete rewrite
|
378 |
sqlite_request "create table if not exists hangars ( |
379 |
id integer primary key, |
|
380 |
name text, |
|
381 |
source text, |
|
382 |
type text, |
|
383 |
url text, |
|
384 |
path text, |
|
385 |
active integer)" |
|
386 | ||
387 |
sqlite_request 'create unique index if not exists "index_hangars" on hangars (url)' |
|
388 | ||
ré-écriture complète
|
389 |
sqlite_request "create table if not exists aircrafts ( |
cosmetics
|
390 |
id integer primary key, |
391 |
name text, |
|
ré-écriture complète
|
392 |
revision integer, |
cosmetics
|
393 |
date integer, |
complete rewrite
|
394 |
author text, |
395 |
hangar integer)" |
|
396 | ||
397 |
sqlite_request 'create unique index if not exists "index_aircrafts" on aircrafts (name, hangar)' |
|
ajout de gestion de bdd pour...
|
398 | |
ré-écriture complète
|
399 |
sqlite_request "create table if not exists setxml ( |
400 |
file text, |
|
401 |
variantof integer, |
|
402 |
$(for col in ${!data[@]}; do printf "'%s' %s, " $col ${data[$col]}; done) |
|
403 |
installed integer)" |
|
ajout de gestion de bdd pour...
|
404 | |
complete rewrite
|
405 |
sqlite_request 'create unique index if not exists "index_setxml" on setxml (file, variantof)' |
406 | ||
407 |
for file in $(find ${0%*/}.d -type f -name "*.hangar"); do |
|
408 |
unset hangar error_message |
|
409 |
unset -f getfromrepo parse_repo_history |
|
410 |
declare -A hangar |
|
411 |
source $file |
|
412 | ||
413 |
test -n "${hangar[name]}" \ |
|
414 |
-a -n "${hangar[source]}" \ |
|
415 |
-a -n "${hangar[type]}" \ |
|
416 |
-a -n "${hangar[url]}" \ |
|
417 |
-a -n "${hangar[active]}" || \ |
|
418 |
error_message="${error_message:+$error_message, }missing hangar data" |
|
419 | ||
420 |
declare -f getfromrepo > /dev/null || \ |
|
421 |
error_message="${error_message:+$error_message, }missing getfromrepo function" |
|
422 | ||
423 |
declare -f parse_repo_history > /dev/null || \ |
|
424 |
error_message="${error_message:+$error_message, }missing parse_repo_history function" |
|
425 | ||
426 |
if test -n "$error_message"; then |
|
427 |
echo "file $file isn't a valid hangar ($error_message)" |
|
428 |
continue |
|
ré-écriture complète
|
429 |
fi |
430 | ||
complete rewrite
|
431 |
sqlite_request "insert into hangars (name, source, type, url, path, active) |
432 |
values ( |
|
433 |
'${hangar[name]}', '${hangar[source]}', '${hangar[type]}', |
|
434 |
'${hangar[url]}', '${hangar[path]}', ${hangar[active]}) |
|
435 |
on conflict (url) where url = '${hangar[url]}' do |
|
436 |
update set |
|
437 |
name = '${hangar[name]}', |
|
438 |
path = '${hangar[path]}', |
|
439 |
active = ${hangar[active]} |
|
440 |
where url = '${hangar[url]}'" |
|
441 |
done |
|
442 | ||
443 |
unset hangar |
|
444 |
unset -f getfromrepo parse_repo_history |
|
445 |
declare -A hangar ac_ass_array |
|
446 |
for h_id in $(sqlite_request "select id from hangars where active = 1"); do |
|
447 | ||
448 |
sqlite_request 'create table if not exists recover_aircrafts ( |
|
449 |
name text, |
|
450 |
revision integer, |
|
451 |
date integer, |
|
452 |
author text, |
|
453 |
hangar integer)' |
|
complete rewrite (use svn in...
|
454 | |
complete rewrite
|
455 |
sqlite_request 'create table if not exists recover_setxml ( |
456 |
ac text, |
|
457 |
sx text)' |
|
ré-écriture complète
|
458 | |
fix issue with multiple revi...
|
459 |
sqlite_request 'create unique index if not exists "index_recover_setxml" on recover_setxml (ac, sx)' |
460 | ||
complete rewrite
|
461 |
eval $(sqlite_request "select printf('hangar[id]=%i;hangar[source]=%s;', id, source) |
462 |
from hangars |
|
463 |
where id = '${h_id}'") |
|
464 | ||
465 |
source $(grep -l "^\s*hangar\[source\]=${hangar[source]}\s*$" ${0%*/}.d/*.hangar) |
|
466 | ||
467 |
eval "getfromrepo () {$(declare -f getfromrepo | sed '1,2d;$d'); xmlremovecomments;}" |
|
468 | ||
469 |
echo -e "=${hangar[name]//?/=}=\n ${hangar[name]} \n=${hangar[name]//?/=}=" |
|
470 | ||
471 |
latest_revision=$(( $(sqlite_request "select max(revision) |
|
472 |
from aircrafts inner join hangars |
|
473 |
where hangars.id = aircrafts.hangar and hangars.name = '${hangar[name]}'") + 1 )) |
|
474 | ||
475 |
parse_repo_history |
|
476 | ||
477 |
if declare -f on_exit > /dev/null; then |
|
478 |
on_exit |
|
479 |
fi |
|
fix issue with multiple revi...
|
480 |
sqlite_request "drop index 'index_recover_setxml'" |
complete rewrite
|
481 |
sqlite_request "drop table recover_aircrafts" |
482 |
sqlite_request "drop table recover_setxml" |
|
483 |
done |
|
ré-écriture complète
|
484 |