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