config / .fgfs / fgaddon /
Newer Older
436 lines | 16.355kb
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
1
#!/bin/bash
2

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
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
)
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
13
fgaddon_svn=https://svn.code.sf.net/p/flightgear/fgaddon/trunk/Aircraft
many improvement
Sébastien MARQUE authored on 2020-09-08
14
fgaddon_path=$HOME/.fgfs/flightgear-fgaddon/Aircraft
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
15
database=${DB:-$0.db}
16
#locale=fr
17

            
18
test -r "$0.conf" && source $0.conf && echo config red
19

            
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
20
aircrafts=$(mktemp --dry-run /dev/shm/Aircraft-XXXXXXXXX)
21
aircraft=$(mktemp --dry-run /dev/shm/aircraft-XXXXXXX)
22
setxml=$(mktemp --dry-run /dev/shm/setxml-XXXXXXXX)
23
in_ram_database=$(mktemp --dry-run /dev/shm/XXXXXXX)
24

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
25
function xmlgetnext () {
26
    local IFS='>'
27
    read -d '<' TAG VALUE
28
    # by design, the first TAG/VALUE pair is empty
29
    # to avoid infinite loops at end of file parsing we return an error
30
    # the next time we find an empty TAG
31
    if test -z "$TAG"; then
better infinite loop check
Sébastien MARQUE authored on 2020-10-19
32
        test ${xmlgetnext_empty_tag:-0} -gt 0 && return 1
33
        xmlgetnext_empty_tag=$(( xmlgetnext_empty_tag + 1 ))
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
34
    fi
35
    # process $TAG only if necessary
36
    local _TAG=$(printf '%q' $TAG)
37
    if test ${_TAG:0:1} = '$'; then
38
        TAG=$(tr '\n' ' ' <<< $TAG | sed 's/  */ /g; s/ *$//')
39
    fi
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
40
}
41

            
keep journal of sqlite reque...
Sébastien MARQUE authored on 2020-10-19
42
rm -f /dev/shm/sqlite_request
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
43
function sqlite_request () {
keep journal of sqlite reque...
Sébastien MARQUE authored on 2020-10-19
44
    local delimiter=';'
45
    test ${1:0:1} == '.' && delimiter=''
46
    echo "${1}${delimiter}" >> /dev/shm/sqlite_request
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
47
    if ! sqlite3 "$in_ram_database" <<< "$1"; then
48
        register_state
49
    fi
50
}
51

            
52
function xmlremovecomments () {
53
    sed -ri 's/<(!--|script>)/\n&/;s/(<\/script|--)>/&\n/' $setxml
54
    sed -ri '/<(script>|!--).*(<\/script|--)>/d;/<(script>|!--)/,/(<\/script|--)>/d' $setxml
small stuff
Sébastien MARQUE authored on 2020-09-27
55
    sed -i 's/\xef\xbb\xbf//' $setxml # removes BOM
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
56
}
57

            
58
function trap_break () {
59
    trap '' INT
60
    echo "stop requested"
61
    register_state
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
62
}
63

            
64
function trap_exit () {
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
65
    trapped_rc=$?
66
    trap '' INT
67
    rm -f $aircrafts $aircraft $setxml
68
    if test ! -e $in_ram_database; then
69
        exit
70
    fi
71
    test $trapped_rc -ne 0 && register_state
many improvements
Sébastien MARQUE authored on 2020-09-02
72
    echo "updating installation status"
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
73
    for ac in $(sqlite_request 'select printf("%i:%s/%s", aircrafts.id, aircrafts.name, setxml.file)
74
                                from aircrafts inner join setxml
75
                                where aircrafts.id = setxml.variantof and setxml.installed != 0;'); do
many improvements
Sébastien MARQUE authored on 2020-09-02
76
        ac_path=${ac#*:}
many improvement
Sébastien MARQUE authored on 2020-09-08
77
        if test ! -e $fgaddon_path/$ac_path-set.xml; then
78
            sqlite_request "update setxml set installed = 0 where file = '${ac_path#*/}' and variantof = ${ac%:*}"
79
        fi
80
    done
81
    for ac in $fgaddon_path/*/*-set.xml; do
82
        ac=${ac/$fgaddon_path}
83
        sx=${ac##*/}
84
        ac=${ac%/*}
85
        if test -d $fgaddon_path/$ac/.svn; then
86
            install_type=1
87
        elif test -d $fgaddon_path/$ac/.git; then
88
            install_type=2
89
        else
90
            install_type=3
91
        fi
92
        sqlite_request "update setxml set installed = $install_type
93
                        where exists (
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
94
                            select 1
95
                            from aircrafts
96
                            where name = '${ac/\/}' and setxml.variantof = id
many improvement
Sébastien MARQUE authored on 2020-09-08
97
                        )"
many improvements
Sébastien MARQUE authored on 2020-09-02
98
    done
cosmetics
Sébastien MARQUE authored on 2020-10-19
99
    local missing_setxml=$(sqlite_request "select printf(' - %s', name)
100
                                     from aircrafts
101
                                     where id not in (select variantof from setxml)")
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
102
    if test -n "$missing_setxml"; then
improve output for missing a...
Sébastien MARQUE authored on 2020-09-23
103
        echo -e "missing setxml config for :\n$missing_setxml"
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
104
    fi
list missing models
Sébastien MARQUE authored on 2020-10-19
105
    local missing_model=$(sqlite_request 'select count(setxml.file)
106
                                          from aircrafts inner join setxml
107
                                          where aircrafts.id = setxml.variantof and setxml.`/sim/model/path` = ""')
108
    if test $missing_model -gt 0; then
109
        echo "$missing_model aircrafts without /sim/model/path information"
110
        if test $missing_model -le 10; then
111
            echo "aircrafts without /sim/model/path information:"
112
            sqlite_request 'select printf(" - %s/%s", aircrafts.name, setxml.file)
113
                            from aircrafts inner join setxml
114
                            where aircrafts.id = setxml.variantof and setxml.`/sim/model/path` = ""'
115
        fi
116
    fi
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
117
    if test -r "$database" && md5sum $in_ram_database | sed "s,$in_ram_database,$database," | md5sum --status -c -; then
118
        rm -f $in_ram_database
many improvements
Sébastien MARQUE authored on 2020-09-02
119
        echo "no changes in $database"
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
120
    elif test -w "$database"; then
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
121
        sqlite_request "vacuum"
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
122
        mv -f $in_ram_database "$database"
many improvements
Sébastien MARQUE authored on 2020-09-02
123
        echo "database $database updated"
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
124
    elif ! test -e "$database"; then
125
        mv $in_ram_database "$database"
many improvements
Sébastien MARQUE authored on 2020-09-02
126
        echo "database $database created"
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
127
    else
128
        rm -f $in_ram_database
many improvements
Sébastien MARQUE authored on 2020-09-02
129
        echo "nothing can be done with $database !"
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
130
    fi
131
}
132

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
133
function register_state () {
134
    sqlite_request "drop table if exists recover_rev"
135
    sqlite_request "create table recover_rev (
136
                        revkey text,
137
                        revision integer,
138
                        revauthor text,
139
                        revdate integer
140
                    )"
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
141
    for revkey in ${!revindex[@]}; do
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
142
        sqlite_request "insert into recover_rev values (
143
                            '$revkey',
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
144
                            ${revindex[$revkey]:-0},
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
145
                            '${revauthor[$revkey]}',
146
                            ${revdate[$revkey]:-0}
147
                        )"
148
    done
149
    sqlite_request "drop table if exists recover_setxmlmodified"
150
    sqlite_request "create table if not exists recover_setxmlmodified (
151
                        sx text
152
                    )"
153
    for sx in ${!setxmlmodified[@]}; do
154
        sqlite_request "insert into recover_setxmlmodified values (
155
                            '$sx'
156
                        )"
157
    done
158
    exit
159
}
160

            
161
function update_database () {
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
162
    echo "[ ${#revindex[@]} ] ${ac:1}"
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
163

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
164
    dbupdate=$(sqlite_request "select revision from aircrafts where name is '${ac:1}'")
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
165
    if test -z "$dbupdate"; then
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
166
        sqlite_request "insert into aircrafts (name, revision, date, author)
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
167
                        values ('${ac:1}', ${revindex[$ac]}, ${revdate[$ac]}, '${revauthor[$ac]}')"
168
    elif test $dbupdate -lt ${revindex[$ac]}; then
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
169
        sqlite_request "update aircrafts set
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
170
                            revision = ${revindex[$ac]},
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
171
                            author   = '${revauthor[$ac]}',
172
                            date = ${revdate[$ac]}
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
173
                        where name is '${ac:1}'"
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
174
    fi
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
175
    id=$(sqlite_request "select id from aircrafts where name is '${ac:1}'")
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
176

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
177
    for sx in ${!setxmlmodified[@]}; do
178
        unset include include_rootpath
179
        [[ "$sx" =~ ^"${ac:1}/" ]] || continue
180
        for col in ${!data[@]}; do
181
            data[$col]=
182
        done
183
        sx=${sx#*/}
remove -set.xml from filenam...
Sébastien MARQUE authored on 2020-09-02
184
        echo " -> $sx"
use svn cat instead of expor...
Sébastien MARQUE authored on 2020-10-19
185
        if ! svn cat $fgaddon_svn/${ac:1}/$sx-set.xml > $setxml; then
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
186
            register_state
187
        fi
188
        xmlremovecomments
better infinite loop check
Sébastien MARQUE authored on 2020-10-19
189
        unset xmlgetnext_empty_tag property
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
190
        while xmlgetnext; do
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
191
            case "${TAG:0:1}" in
192
                ''|'?'|'!')
193
                    continue;;
194
                /)
195
                    property=${property%/*};;
196
                *)
197
                    if test "${TAG: -1}" != '/'; then
198
                        property+=/${TAG%% *}
fix syntax mistake
Sébastien MARQUE authored on 2020-09-21
199
                    fi;;
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
200
            esac
201

            
202
            if [[ "$TAG" =~ ^"PropertyList include=" ]]; then
203
                include_rootpath=${include%/*}
204
                test $include = $include_rootpath && unset include_rootpath
205
                eval $(echo ${TAG#* })
206
                [[ "$include" =~ ^Aircraft/Generic/ ]] && unset include include_rootpath && continue
207
                if [[ "$include" =~ ^'../' ]]; then
208
                    if test -n "$include_rootpath"; then
209
                        if [[ "$include_rootpath" =~ '/' ]]; then
210
                            include_rootpath=${include_rootpath%/*}
211
                        else
212
                            unset include_rootpath
213
                        fi
214
                    else
215
                        ac_save=$ac
216
                        unset ac
217
                    fi
218
                    include=${include/\.\.\/}
219
                fi
220
                if ! svn cat $fgaddon_svn/${ac:1}/${include_rootpath:+$include_rootpath/}$include >> $setxml; then
221
                    register_state
222
                fi
223
                xmlremovecomments
224
            fi
225

            
226
            if [[ "$property" = /PropertyList@($data_pattern) ]]; then
fix overriding descs with in...
Sébastien MARQUE authored on 2020-09-27
227
                if test -z "${data[${property/\/PropertyList}]}"; then
228
                    eval "data[${property/\/PropertyList}]=\"${VALUE//\"/\\\"}\""
229
                    data[${property/\/PropertyList}]=$(tr '\n' ' ' <<< ${data[${property/\/PropertyList}]} | sed -r 's/^\s*//;s/\s+/ /g;s/\s*$//')
230
                fi
many improvement
Sébastien MARQUE authored on 2020-09-08
231
            fi
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
232

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
233
            # continue parsing (while loop) until everything's found
234
            for col in ${!data[@]}; do
235
                test -z "${data[$col]}" && continue 2
236
            done
237
            break # everything's found
238
        done < $setxml
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
239

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
240
        if eval "test -z \"$data_test_null\""; then
241
            echo "WARNING: no info found, skipping"
242
            continue
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
243
        fi
244

            
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
245
        known=$(sqlite_request "select variantof from setxml where file is '$sx'")
246
        if test -n "$known"; then
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
247
            for col in ${!data[@]}; do
fix sqlite column name
Sébastien MARQUE authored on 2020-10-19
248
                dbvalue=$(sqlite_request "select \`$col\`
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
249
                                          from setxml
250
                                          where file is '$sx' and variantof = $known")
251
                if test "$dbvalue" != "${data[$col]}" -a -n "${data[$col]}"; then
252
                    sqlite_request "update setxml
fix sqlite column name
Sébastien MARQUE authored on 2020-10-19
253
                                    set \`$col\` = '${data[$col]//\'/\'\'}'
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
254
                                    where file is '$sx' and variantof = $known"
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
255
                fi
256
            done
257
        else
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
258
            values="'$sx', $id, "
259
            for col in ${!data[@]}; do
260
                values+="'${data[$col]//\'/\'\'}', "
261
            done
262
            values+=0
263
            sqlite_request "insert into setxml values ($values)"
264
        fi
265
        test -n "$ac_save" && ac=$ac_save
266
        unset setxmlmodified[${ac:1}/$sx]
267
    done
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
268
    unset revindex[$ac]
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
269
}
270

            
271
function apply_revision () {
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
272
    for ac in "${!revindex[@]}"; do
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
273
        update_database
274
        if test -d $fgaddon_path/${ac:1}/.svn \
275
        && test "$(svn info --show-item=url $fgaddon_path/${ac:1})" != "$fgaddon_svn/${ac:1}" \
276
        || test -d $fgaddon_path/${ac:1} -a ! -d $fgaddon_path/${ac:1}/.svn; then
277
            echo "INFO: local ${ac:1} installed out from repo" >&2
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
278
        fi
279
    done
280
}
281

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
282
trap trap_break INT
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
283
trap trap_exit EXIT
284

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
285
stty -echoctl
286

            
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
287
declare -A revindex revauthor revdate setxmlmodified files revpath
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
288
data_pattern=$(printf "%s|" ${!data[@]})
289
data_pattern=${data_pattern:0:-1}
290
data_test_null=$(printf '${data[%s]}' ${!data[@]})
291

            
292
if test -e $database; then
293
    cp $database $in_ram_database
294
    sql_cols=$(sqlite_request "pragma table_info(setxml)" | awk -F'|' '{printf("%s %s ", $2, $3)}')
295
    script_cols="file text variantof integer "
296
    for col in ${!data[@]}; do
297
        script_cols+="$col ${data["$col"]} "
298
    done
299
    script_cols+="installed integer " # last space is important
300
    if test "$sql_cols" != "$script_cols"; then
301
        echo "ALERT: datbase version mismatch !"
302
        exit 1
303
    fi
304
    if sqlite_request '.tables' | grep -q 'recover_' && test -z "$1"; then
305
        echo "recovering from previous saved state"
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
306
        eval $(sqlite_request "select printf('revindex[%s]=%u;revauthor[%s]=%s;revdate[%s]=%u;',
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
307
                                       revkey, revision,
308
                                       revkey, revauthor,
309
                                       revkey, revdate)
310
                               from recover_rev")
311
        eval $(sqlite_request "select printf('setxmlmodified[%s]=1;', sx)
312
                               from recover_setxmlmodified")
313
        sqlite_request "drop table recover_rev"
314
        sqlite_request "drop table recover_setxmlmodified"
315
        apply_revision
316
        exit
317
    fi
318
fi
319

            
320
sqlite_request "create table if not exists aircrafts (
cosmetics
Sébastien MARQUE authored on 2020-10-19
321
                    id       integer primary key,
322
                    name     text,
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
323
                    revision integer,
cosmetics
Sébastien MARQUE authored on 2020-10-19
324
                    date     integer,
325
                    author   text)"
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
326

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
327
sqlite_request "create table if not exists setxml (
328
                    file text,
329
                    variantof integer,
330
                    $(for col in ${!data[@]}; do printf "'%s' %s, " $col ${data[$col]}; done)
331
                    installed integer)"
ajout de gestion de bdd pour...
Sébastien MARQUE authored on 2020-08-24
332

            
search for next revision
Sébastien MARQUE authored on 2020-10-19
333
latest_revision=$(( $(sqlite_request "select max(revision) from aircrafts") + 1 ))
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
334

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
335
# for debugging purpose
336
if test -n "$2"; then
337
    ac=_${1%/*}
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
338
    revindex[$ac]=1
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
339
    revdate[$ac]=0
340
    revauthor[$ac]=foobar
341
    setxmlmodified[${ac:1}/${1#*/}]=1
342
    set -x
343
    update_database
344
    set +x
345
    exit
346
elif test -n "$1"; then
347
    ac=_${1%/*}
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
348
    eval $(sqlite_request "select printf('revindex[_%s]=%s;revdate[_%s]=%i;revauthor[_%s]=%s;',
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
349
                                            name, revision,
350
                                            name, date,
351
                                            name, author)
352
                           from aircrafts
353
                           where name = '${ac:1}'")
354
    setxmlmodified[${ac:1}/${1#*/}]=1
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
355
    if test -z "${revindex[$ac]}"; then
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
356
        echo "aircraft ${ac:1} not found"
357
        rm $in_ram_database
358
        exit
359
    fi
360
    update_database
361
    exit
362
fi
363

            
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
364
echo "downloading FGADDON history from revision ${latest_revision:-0}"
365
svn log --revision ${latest_revision:-0}:HEAD --xml --verbose $fgaddon_svn > $aircrafts
366

            
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
367
total=$(grep -c '<logentry' $aircrafts)
368
progress=0
369

            
370
echo parsing history
371

            
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
372
while xmlgetnext; do
373
    case "$TAG" in
374
        'logentry revision='*)
375
            eval $(echo ${TAG#* })
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
376
            for action in ${!revpath[@]}; do
377
                unset revpath[$action]
378
            done
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
379
        ;;
380
        'author')
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
381
            revauthor=${VALUE//\'/\'\'}
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
382
        ;;
383
        'date')
384
            revdate=$(date +%s -d "$VALUE")
385
        ;;
386
        'path '*)
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
387
            TAG=${TAG#* }
388
            TAG=${TAG// /;}
389
            TAG=${TAG//-/_}
390
            eval $(echo ${TAG// /;})
391
            path=(${VALUE//\// })
392
            if test $kind = 'file' -a ${#path[@]} -gt 3; then
393
                revpath[$action]+="$VALUE "
394
            elif test $kind = 'dir' -a ${#path[@]} -eq 3 -a $action = 'D'; then
395
                files[_${path[2]}]=0
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
396
                unset revindex[_${path[2]}] revauthor[_${path[2]}] revdate[_${path[2]}]
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
397
                for sx in ${!setxmlmodified[@]}; do
398
                    [[ "$sx" =~ "${path[2]}/" ]] && unset setxmlmodified[$sx]
399
                done
400
            fi
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
401
        ;;
402
        '/logentry')
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
403
            for item in ${revpath[D]}; do
404
                path=(${item//\// })
manage aircraft deletion
Sébastien MARQUE authored on 2020-09-23
405
                if [[ "${path[3]}" =~ "-set.xml" ]]; then
406
                    unset setxmlmodified[${path[2]}/${path[3]/-set.xml}]
407
                    sqlite_request "delete from setxml where file = '${path[3]/-set.xml}'"
408
                fi
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
409
                files[_${path[2]}]=$(( --files[_${path[2]}] ))
410
                if test ${files[_${path[2]}]} -le 0; then
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
411
                    unset revindex[_${path[2]}] revauthor[_${path[2]}] revdate[_${path[2]}]
manage aircraft deletion
Sébastien MARQUE authored on 2020-09-23
412
                    sqlite_request "delete from aircrafts where name = '${path[2]}'"
many improvement
Sébastien MARQUE authored on 2020-09-08
413
                fi
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
414
            done
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
415
            for action in A M R; do
416
                for item in ${revpath[$action]}; do
417
                    path=(${item//\// })
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
418
                    revindex[_${path[2]}]=$revision
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
419
                    revauthor[_${path[2]}]=$revauthor
420
                    revdate[_${path[2]}]=$revdate
421
                    [[ "${path[3]}" =~ "-set.xml" ]] && setxmlmodified[${path[2]}/${path[3]/-set.xml}]=1
422
                    test $action = 'A' && files[_${path[2]}]=$(( ++files[_${path[2]}] ))
423
                done
424
            done
425
            newprogress=$((++logentry * 100 / $total))
426
            if test $(( $newprogress - $progress )) -ge ${progress_granularity:-1}; then
427
                progress=$newprogress
fix variable name conflict
Sébastien MARQUE authored on 2020-09-23
428
                echo "$progress% (${#revindex[@]})"
ré-écriture complète
Sébastien MARQUE authored on 2020-09-20
429
            fi
430
        ;;
431
        '/log')
432
            apply_revision
complete rewrite (use svn in...
Sébastien MARQUE authored on 2020-09-07
433
            break
434
        ;;
435
    esac
436
done < $aircrafts