Редакция 464 | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
462 | diffor | 1 | filesdir="/root/nix-files/apt-scan-files" |
464 | diffor | 2 | sql="sqlite" |
462 | diffor | 3 | db="$filesdir/apt.db" |
4 | |||
5 | rm $db |
||
464 | diffor | 6 | $sql $db "CREATE TABLE reps (id INTEGER PRIMARY KEY, rep VARCHAR)" |
7 | $sql $db "CREATE TABLE dists (id INTEGER PRIMARY KEY, dist VARCHAR)" |
||
8 | $sql $db "CREATE TABLE sects (id INTEGER PRIMARY KEY, sect VARCHAR)" |
||
9 | $sql $db "CREATE TABLE reps2dists (id INTEGER PRIMARY KEY, rep_id INTEGER KEY, dist_id INTEGER KEY)" |
||
10 | $sql $db "CREATE TABLE reps2dists2sects (id INTEGER PRIMARY KEY, reps2dists_id INTEGER KEY, sect_id INTEGER KEY)" |
||
462 | diffor | 11 | |
12 | cat $filesdir/dists.lst | grep -v "debian-installer" | while read LINE |
||
13 | do |
||
14 | eval "$(echo $LINE | sed 's,\([^/]*\)/dists/\(.*\)/\([^/]*\)$, rep="\1" ; dist="\2"; sect="\3";,i')" |
||
15 | for part in rep dist sect |
||
16 | do |
||
17 | eval cval=\$$part; |
||
18 | parts=$part's' |
||
19 | |||
464 | diffor | 20 | id_current="$($sql $db "SELECT id FROM $parts WHERE $part='$cval'")"; |
462 | diffor | 21 | |
22 | if [ "$id_current" == "" ]; then |
||
23 | echo Adding $part $cval; |
||
464 | diffor | 24 | $sql $db "INSERT INTO $parts VALUES (NULL,'$cval')"; |
25 | id_current="$($sql $db "SELECT id FROM $parts WHERE $part='$cval'")"; |
||
462 | diffor | 26 | fi; |
27 | eval id_$part=$id_current |
||
28 | done |
||
29 | |||
464 | diffor | 30 | id_current="$($sql $db "SELECT id FROM reps2dists WHERE rep_id=$id_rep AND dist_id=$id_dist")"; |
462 | diffor | 31 | if [ "$id_current" == "" ]; then |
32 | echo Adding r2d $id_rep $id_dist; |
||
464 | diffor | 33 | $sql $db "INSERT INTO reps2dists VALUES (NULL, $id_rep, $id_dist)"; |
465 | diffor | 34 | fi; |
464 | diffor | 35 | id_current="$($sql $db "SELECT id FROM reps2dists WHERE rep_id=$id_rep AND dist_id=$id_dist")"; |
462 | diffor | 36 | echo Adding r2d2s $id_current $id_sect; |
464 | diffor | 37 | $sql $db "INSERT INTO reps2dists2sects VALUES (NULL, $id_current, $id_sect)"; |
462 | diffor | 38 | done |