Commit 4d9e6ffad97f632139a75acce899d6a6b0594576

Authored by Silvan Calarco
1 parent 4f56214e72
Exists in master

Make contentslist generation optional using --gencontentslist

backend-sqlite: only output data for local repository to work also when executed with other arguments

Showing 4 changed files with 279 additions and 235 deletions Side-by-side Diff

src/backend-sqlite3.c
1 1 /*
2 2 * distromatic - tool for RPM based repositories
3 3 *
4   - * Copyright (C) 2013 by Silvan Calarco <silvan.calarco@mambasoft.it>
  4 + * Copyright (C) 2013-2015 by Silvan Calarco <silvan.calarco@mambasoft.it>
5 5 *
6 6 * This program is free software; you can redistribute it and/or modify it under
7 7 * the terms of version 2 of the GNU General Public License as published by the
8 8  
9 9  
10 10  
11 11  
... ... @@ -68,29 +68,41 @@
68 68 struct configTag* ct,
69 69 int arch) {
70 70  
  71 + int thisrep, i;
  72 +
71 73 while (ft) {
72   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO files VALUES(%ld,?,%ld,%ld,%ld,%d);",
73   - ft->id,
74   - (ft->firstchild?ft->firstchild->id:-1),
75   - (ft->next?ft->next->id:-1),
76   - (ft->parent?ft->parent->id:-1),
77   - ft->numproviders);
78   - sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL);
79   - sqlite3_bind_text(stmt, 1, ft->name, -1, SQLITE_STATIC);
80   - if (sqlite3_step(stmt) != SQLITE_DONE) {
81   - fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
82   - return 1;
  74 + i = 0;
  75 + thisrep = 0;
  76 + for (i = 0; i < ft->numproviders; i++) {
  77 + if (ft->provider[i]->altrepository == ct->repository_level) {
  78 + thisrep = 1;
  79 + break;
  80 + }
83 81 }
84   - sqlite3_finalize(stmt);
  82 + if (thisrep) {
  83 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO files VALUES(%ld,?,%ld,%ld,%ld,%d);",
  84 + ft->id,
  85 + (ft->firstchild?ft->firstchild->id:-1),
  86 + (ft->next?ft->next->id:-1),
  87 + (ft->parent?ft->parent->id:-1),
  88 + ft->numproviders);
  89 + sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL);
  90 + sqlite3_bind_text(stmt, 1, ft->name, -1, SQLITE_STATIC);
  91 + if (sqlite3_step(stmt) != SQLITE_DONE) {
  92 + fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
  93 + return 1;
  94 + }
  95 + sqlite3_finalize(stmt);
85 96  
86   - sqlite3_transaction_size += strlen(sqlite3_query);
87   - if (sqlite3_transaction_size >= sqlite3_transaction_maxsize) {
88   - SQLite_commit_transaction(db);
89   - SQLite_begin_transaction(db);
90   - }
  97 + sqlite3_transaction_size += strlen(sqlite3_query);
  98 + if (sqlite3_transaction_size >= sqlite3_transaction_maxsize) {
  99 + SQLite_commit_transaction(db);
  100 + SQLite_begin_transaction(db);
  101 + }
91 102  
92   - if (ft->firstchild) {
93   - if (SQLite_print_contents_subtree(db, ft->firstchild, ct, arch)) return 1;
  103 + if (ft->firstchild) {
  104 + if (SQLite_print_contents_subtree(db, ft->firstchild, ct, arch)) return 1;
  105 + }
94 106 }
95 107 ft=ft->next;
96 108 }
97 109  
... ... @@ -163,36 +175,37 @@
163 175  
164 176 currpackage = ct->headerlist[arch];
165 177 while (currpackage) {
166   - /* packages <-> files relations */
167   - for (i = 0; i < currpackage->filenamecount; i++) {
168   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages_files_rel VALUES(NULL,%ld,%ld,%ld,%ld,%d,?,?,?);",
169   - currpackage->id,
170   - currpackage->file[i]->id,
171   - currpackage->fileuser[i]->id,
172   - currpackage->filegroup[i]->id,
173   - currpackage->fileflags[i]);
174   - if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
175   - fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
176   - return 1;
177   - }
178   - sqlite3_bind_text(stmt, 1, currpackage->name, -1, SQLITE_STATIC);
179   - sqlite3_bind_text(stmt, 2, currpackage->version, -1, SQLITE_STATIC);
180   - sqlite3_bind_text(stmt, 3, currpackage->release, -1, SQLITE_STATIC);
181   - if (sqlite3_step(stmt) != SQLITE_DONE) {
182   - fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_query, sqlite3_errmsg(db));
183   - return 3;
184   - }
185   - sqlite3_finalize(stmt);
186   - sqlite3_transaction_size += strlen(sqlite3_query);
187   - if (sqlite3_transaction_size >= sqlite3_transaction_maxsize) {
188   - SQLite_commit_transaction(db);
189   - SQLite_begin_transaction(db);
190   - }
191   - }
192   - currpackage = currpackage->next;
  178 + if (currpackage->altrepository == ct->repository_level) {
  179 + /* packages <-> files relations */
  180 + for (i = 0; i < currpackage->filenamecount; i++) {
  181 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages_files_rel VALUES(NULL,%ld,%ld,%ld,%ld,%d,?,?,?);",
  182 + currpackage->id,
  183 + currpackage->file[i]->id,
  184 + currpackage->fileuser[i]->id,
  185 + currpackage->filegroup[i]->id,
  186 + currpackage->fileflags[i]);
  187 + if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
  188 + fprintf(stderr, "ERROR: sqlite3_prepare_v2: %s (%s)\n", sqlite3_errmsg(db), sqlite3_query);
  189 + return 1;
  190 + }
  191 + sqlite3_bind_text(stmt, 1, currpackage->name, -1, SQLITE_STATIC);
  192 + sqlite3_bind_text(stmt, 2, currpackage->version, -1, SQLITE_STATIC);
  193 + sqlite3_bind_text(stmt, 3, currpackage->release, -1, SQLITE_STATIC);
  194 + if (sqlite3_step(stmt) != SQLITE_DONE) {
  195 + fprintf(stderr, "ERROR: sqlite3_step: %s (%s)\n", sqlite3_query, sqlite3_errmsg(db));
  196 + return 3;
  197 + }
  198 + sqlite3_finalize(stmt);
  199 + sqlite3_transaction_size += strlen(sqlite3_query);
  200 + if (sqlite3_transaction_size >= sqlite3_transaction_maxsize) {
  201 + SQLite_commit_transaction(db);
  202 + SQLite_begin_transaction(db);
  203 + }
  204 + }
  205 + }
  206 + currpackage = currpackage->next;
193 207 }
194 208 SQLite_commit_transaction(db);
195   -
196 209 return 0;
197 210 }
198 211  
... ... @@ -202,6 +215,7 @@
202 215 int generateSQLite_provided(struct configTag* ct, sqlite3 *db, int arch) {
203 216  
204 217 struct providedList* provided;
  218 + int i, thisrep;
205 219  
206 220 snprintf(sqlite3_query, PATH_MAX, "provided");
207 221 SQLite_init_table(db, sqlite3_query, SQLITE_TABLE_provided);
208 222  
209 223  
210 224  
... ... @@ -209,22 +223,30 @@
209 223  
210 224 provided = ct->providedlist_idx[arch][0];
211 225 while (provided) {
212   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provided VALUES(%ld,?,%ld,%d);",
213   - provided->id,
214   - provided->flags,
215   - provided->numproviders);
216   - sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL);
217   - sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC);
218   - if (sqlite3_step(stmt) != SQLITE_DONE) {
219   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
220   - return 1;
  226 + i = 0;
  227 + thisrep = 0;
  228 + for (i = 0; i < provided->numproviders; i++) {
  229 + if (provided->provider[i]->altrepository == ct->repository_level) {
  230 + thisrep = 1;
  231 + break;
  232 + }
221 233 }
222   - sqlite3_finalize(stmt);
  234 + if (thisrep) {
  235 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provided VALUES(%ld,?,%ld,%d);",
  236 + provided->id,
  237 + provided->flags,
  238 + provided->numproviders);
  239 + sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL);
  240 + sqlite3_bind_text(stmt, 1, provided->name, -1, SQLITE_STATIC);
  241 + if (sqlite3_step(stmt) != SQLITE_DONE) {
  242 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  243 + return 1;
  244 + }
  245 + sqlite3_finalize(stmt);
  246 + }
223 247 provided = provided->next;
224 248 }
225   -
226 249 SQLite_commit_transaction(db);
227   -
228 250 return 0;
229 251 }
230 252  
... ... @@ -238,7 +260,7 @@
238 260  
239 261 SQLite_init_table(db, "packagers", SQLITE_TABLE_packagers);
240 262 SQLite_begin_transaction(db);
241   -
  263 +
242 264 while (packager) {
243 265 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packagers VALUES(NULL,?,%d,%d,%d);",
244 266 packager->role,
245 267  
246 268  
247 269  
248 270  
249 271  
250 272  
251 273  
252 274  
253 275  
... ... @@ -316,92 +338,93 @@
316 338  
317 339 currpackage = ct->headerlist[arch];
318 340 while (currpackage) {
  341 + if (currpackage->altrepository == ct->repository_level) {
  342 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages VALUES(NULL,?,%d,%ld,?,?,?,?,?,%ld,%ld);",
  343 + currpackage->altrepository,
  344 + currpackage->epoch,
  345 + currpackage->size,
  346 + currpackage->sourceheader->id);
  347 + if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
  348 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  349 + return 1;
  350 + }
319 351  
320   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO packages VALUES(NULL,?,%d,%ld,?,?,?,?,?,%ld,%ld);",
321   - currpackage->altrepository,
322   - currpackage->epoch,
323   - currpackage->size,
324   - currpackage->sourceheader->id);
325   - if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
326   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
327   - return 1;
328   - }
  352 + sqlite3_bind_text(stmt, 1, currpackage->name, -1, SQLITE_STATIC);
  353 + sqlite3_bind_text(stmt, 2, currpackage->version, -1, SQLITE_STATIC);
  354 + sqlite3_bind_text(stmt, 3, currpackage->release, -1, SQLITE_STATIC);
  355 + sqlite3_bind_text(stmt, 4, currpackage->summary, -1, SQLITE_STATIC);
  356 + sqlite3_bind_text(stmt, 5, currpackage->group, -1, SQLITE_STATIC);
  357 + sqlite3_bind_text(stmt, 6, currpackage->description, -1, SQLITE_STATIC);
329 358  
330   - sqlite3_bind_text(stmt, 1, currpackage->name, -1, SQLITE_STATIC);
331   - sqlite3_bind_text(stmt, 2, currpackage->version, -1, SQLITE_STATIC);
332   - sqlite3_bind_text(stmt, 3, currpackage->release, -1, SQLITE_STATIC);
333   - sqlite3_bind_text(stmt, 4, currpackage->summary, -1, SQLITE_STATIC);
334   - sqlite3_bind_text(stmt, 5, currpackage->group, -1, SQLITE_STATIC);
335   - sqlite3_bind_text(stmt, 6, currpackage->description, -1, SQLITE_STATIC);
  359 + if (sqlite3_step(stmt) != SQLITE_DONE) {
  360 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  361 + return 3;
  362 + }
  363 + currpackage->id = sqlite3_last_insert_rowid(db);
  364 + sqlite3_finalize(stmt);
336 365  
337   - if (sqlite3_step(stmt) != SQLITE_DONE) {
338   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
339   - return 3;
340   - }
341   - currpackage->id = sqlite3_last_insert_rowid(db);
342   - sqlite3_finalize(stmt);
  366 + /* obsoletes */
  367 + for (i = 0; i < currpackage->obsoletecount; i++) {
  368 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO obsoletes VALUES(NULL,%ld,?,%d,?);",
  369 + currpackage->id,
  370 + currpackage->obsoleteflags[i]);
343 371  
344   - /* obsoletes */
345   - for (i = 0; i < currpackage->obsoletecount; i++) {
346   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO obsoletes VALUES(NULL,%ld,?,%d,?);",
347   - currpackage->id,
348   - currpackage->obsoleteflags[i]);
  372 + if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
  373 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  374 + }
  375 + sqlite3_bind_text(stmt, 1, currpackage->obsoletename[i], -1, SQLITE_STATIC);
  376 + sqlite3_bind_text(stmt, 2, currpackage->obsoleteversion[i], -1, SQLITE_STATIC);
  377 + if (sqlite3_step(stmt) != SQLITE_DONE) {
  378 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  379 + return 3;
  380 + }
  381 + sqlite3_finalize(stmt);
  382 + }
349 383  
350   - if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
351   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
352   - }
353   - sqlite3_bind_text(stmt, 1, currpackage->obsoletename[i], -1, SQLITE_STATIC);
354   - sqlite3_bind_text(stmt, 2, currpackage->obsoleteversion[i], -1, SQLITE_STATIC);
355   - if (sqlite3_step(stmt) != SQLITE_DONE) {
356   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
357   - return 3;
358   - }
359   - sqlite3_finalize(stmt);
360   - }
  384 + /* provides */
  385 + for (i = 0; i < currpackage->providecount; i++) {
  386 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provides VALUES(NULL,%ld,%ld,%d,?);",
  387 + currpackage->id,
  388 + currpackage->provided[i]->id,
  389 + currpackage->provideflags[i]);
361 390  
362   - /* provides */
363   - for (i = 0; i < currpackage->providecount; i++) {
364   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO provides VALUES(NULL,%ld,%ld,%d,?);",
365   - currpackage->id,
366   - currpackage->provided[i]->id,
367   - currpackage->provideflags[i]);
  391 + if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
  392 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  393 + }
  394 + sqlite3_bind_text(stmt, 1, currpackage->provideversion[i], -1, SQLITE_STATIC);
  395 + if (sqlite3_step(stmt) != SQLITE_DONE) {
  396 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  397 + return 3;
  398 + }
  399 + sqlite3_finalize(stmt);
  400 + }
368 401  
369   - if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
370   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
371   - }
372   - sqlite3_bind_text(stmt, 1, currpackage->provideversion[i], -1, SQLITE_STATIC);
373   - if (sqlite3_step(stmt) != SQLITE_DONE) {
374   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
375   - return 3;
376   - }
377   - sqlite3_finalize(stmt);
378   - }
  402 + /* requires */
  403 + for (i = 0; i < currpackage->requirecount; i++) {
  404 + if (currpackage->require[i]->resolved) {
  405 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO requires VALUES(NULL,%ld,%ld,%ld,?);",
  406 + currpackage->id,
  407 + currpackage->require[i]->resolved->id,
  408 + currpackage->require[i]->flags);
379 409  
380   - /* requires */
381   - for (i = 0; i < currpackage->requirecount; i++) {
382   - if (currpackage->require[i]->resolved) {
383   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO requires VALUES(NULL,%ld,%ld,%ld,?);",
384   - currpackage->id,
385   - currpackage->require[i]->resolved->id,
386   - currpackage->require[i]->flags);
387   -
388   - if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
389   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
390   - }
391   - sqlite3_bind_text(stmt, 1, currpackage->require[i]->version, -1, SQLITE_STATIC);
392   - if (sqlite3_step(stmt) != SQLITE_DONE) {
393   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
394   - return 3;
395   - }
396   - sqlite3_finalize(stmt);
397   - } else if (strstr(currpackage->require[i]->name,"rpmlib(") != currpackage->require[i]->name) {
398   - fprintf(stderr, "WARNING: package %s require %s not in provided list\n", currpackage->name, currpackage->require[i]->name);
  410 + if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
  411 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  412 + }
  413 + sqlite3_bind_text(stmt, 1, currpackage->require[i]->version, -1, SQLITE_STATIC);
  414 + if (sqlite3_step(stmt) != SQLITE_DONE) {
  415 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  416 + return 3;
  417 + }
  418 + sqlite3_finalize(stmt);
  419 + } else if (strstr(currpackage->require[i]->name,"rpmlib(") != currpackage->require[i]->name) {
  420 + fprintf(stderr, "WARNING: package %s require %s not in provided list\n", currpackage->name, currpackage->require[i]->name);
  421 + }
399 422 }
400   - }
401   - currpackage = currpackage->next;
402   - }
403   - SQLite_commit_transaction(db);
404   - return 0;
  423 + }
  424 + currpackage = currpackage->next;
  425 + }
  426 + SQLite_commit_transaction(db);
  427 + return 0;
405 428 }
406 429  
407 430 #define SQLITE_TABLE_sources_source "id INTEGER PRIMARY KEY, id_source INTEGER, source STRING"
408 431  
409 432  
410 433  
411 434  
412 435  
413 436  
414 437  
415 438  
416 439  
417 440  
418 441  
419 442  
420 443  
... ... @@ -435,96 +458,96 @@
435 458  
436 459 currsource = ct->headersourcelist;
437 460 while (currsource != NULL) {
  461 + if (currsource->altrepository == ct->repository_level) {
  462 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources VALUES(%ld,?,%d,%ld,?,?,?,%ld,?,?,?,?,?,?,?,%ld,%ld,%ld);",
  463 + currsource->id,
  464 + currsource->altrepository,
  465 + currsource->epoch,
  466 + currsource->packager->id,
  467 + currsource->buildtime,
  468 + currsource->size,
  469 + (currsource->changelog?nextchangelogid:0));
  470 + if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
  471 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  472 + }
438 473  
439   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources VALUES(%ld,?,%d,%ld,?,?,?,%ld,?,?,?,?,?,?,?,%ld,%ld,%ld);",
440   - currsource->id,
441   - currsource->altrepository,
442   - currsource->epoch,
443   - currsource->packager->id,
444   - currsource->buildtime,
445   - currsource->size,
446   - (currsource->changelog?nextchangelogid:0));
447   - if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
448   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
449   - }
  474 + sqlite3_bind_text(stmt, 1, currsource->name, -1, SQLITE_STATIC);
  475 + sqlite3_bind_text(stmt, 2, currsource->version, -1, SQLITE_STATIC);
  476 + sqlite3_bind_text(stmt, 3, currsource->release, -1, SQLITE_STATIC);
  477 + sqlite3_bind_text(stmt, 4, currsource->summary, -1, SQLITE_STATIC);
  478 + sqlite3_bind_text(stmt, 5, currsource->group, -1, SQLITE_STATIC);
  479 + sqlite3_bind_text(stmt, 6, currsource->description, -1, SQLITE_STATIC);
  480 + sqlite3_bind_text(stmt, 7, currsource->url, -1, SQLITE_STATIC);
  481 + sqlite3_bind_text(stmt, 8, currsource->license, -1, SQLITE_STATIC);
  482 + sqlite3_bind_text(stmt, 9, currsource->arch, -1, SQLITE_STATIC);
  483 + sqlite3_bind_text(stmt, 10, currsource->buildarchs, -1, SQLITE_STATIC);
  484 + sqlite3_bind_text(stmt, 11, currsource->excludearch, -1, SQLITE_STATIC);
450 485  
451   - sqlite3_bind_text(stmt, 1, currsource->name, -1, SQLITE_STATIC);
452   - sqlite3_bind_text(stmt, 2, currsource->version, -1, SQLITE_STATIC);
453   - sqlite3_bind_text(stmt, 3, currsource->release, -1, SQLITE_STATIC);
454   - sqlite3_bind_text(stmt, 4, currsource->summary, -1, SQLITE_STATIC);
455   - sqlite3_bind_text(stmt, 5, currsource->group, -1, SQLITE_STATIC);
456   - sqlite3_bind_text(stmt, 6, currsource->description, -1, SQLITE_STATIC);
457   - sqlite3_bind_text(stmt, 7, currsource->url, -1, SQLITE_STATIC);
458   - sqlite3_bind_text(stmt, 8, currsource->license, -1, SQLITE_STATIC);
459   - sqlite3_bind_text(stmt, 9, currsource->arch, -1, SQLITE_STATIC);
460   - sqlite3_bind_text(stmt, 10, currsource->buildarchs, -1, SQLITE_STATIC);
461   - sqlite3_bind_text(stmt, 11, currsource->excludearch, -1, SQLITE_STATIC);
  486 + if (sqlite3_step(stmt) != SQLITE_DONE) {
  487 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  488 + return 3;
  489 + }
  490 + currsource->id = sqlite3_last_insert_rowid(db);
  491 + sqlite3_finalize(stmt);
462 492  
463   - if (sqlite3_step(stmt) != SQLITE_DONE) {
464   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
465   - return 3;
466   - }
467   - currsource->id = sqlite3_last_insert_rowid(db);
468   - sqlite3_finalize(stmt);
  493 + /* source */
  494 + if (currsource->source) {
  495 + i=0;
  496 + while (currsource->source[i]) {
  497 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_source VALUES(NULL,%ld,?);",
  498 + currsource->id);
469 499  
470   - /* source */
471   - if (currsource->source) {
472   - i=0;
473   - while (currsource->source[i]) {
474   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_source VALUES(NULL,%ld,?);",
475   - currsource->id);
  500 + if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
  501 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  502 + }
  503 + sqlite3_bind_text(stmt, 1, currsource->source[i], -1, SQLITE_STATIC);
  504 + if (sqlite3_step(stmt) != SQLITE_DONE) {
  505 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  506 + return 3;
  507 + }
  508 + sqlite3_finalize(stmt);
  509 + i++;
  510 + }
  511 + }
476 512  
477   - if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
478   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  513 + /* patch */
  514 + if (currsource->patch) {
  515 + i=0;
  516 + while (currsource->patch[i]) {
  517 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_patch VALUES(NULL,%ld,?);",
  518 + currsource->id);
  519 +
  520 + if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
  521 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  522 + }
  523 + sqlite3_bind_text(stmt, 1, currsource->patch[i], -1, SQLITE_STATIC);
  524 + if (sqlite3_step(stmt) != SQLITE_DONE) {
  525 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  526 + return 3;
  527 + }
  528 + sqlite3_finalize(stmt);
  529 + i++;
479 530 }
480   - sqlite3_bind_text(stmt, 1, currsource->source[i], -1, SQLITE_STATIC);
481   - if (sqlite3_step(stmt) != SQLITE_DONE) {
482   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
483   - return 3;
484   - }
485   - sqlite3_finalize(stmt);
486   - i++;
487 531 }
488   - }
489 532  
490   - /* patch */
491   - if (currsource->patch) {
492   - i=0;
493   - while (currsource->patch[i]) {
494   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_patch VALUES(NULL,%ld,?);",
495   - currsource->id);
  533 + /* buildrequires */
  534 + for (i = 0; i < currsource->requirecount; i++) {
  535 + snprintf(sqlite3_query, PATH_MAX, "INSERT INTO buildrequires VALUES(NULL,%ld,?,%ld,?);",
  536 + currsource->id,
  537 + currsource->require[i]->flags);
496 538  
497 539 if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
498   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
  540 + fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
499 541 }
500   - sqlite3_bind_text(stmt, 1, currsource->patch[i], -1, SQLITE_STATIC);
  542 + sqlite3_bind_text(stmt, 1, currsource->require[i]->name, -1, SQLITE_STATIC);
  543 + sqlite3_bind_text(stmt, 2, currsource->require[i]->version, -1, SQLITE_STATIC);
501 544 if (sqlite3_step(stmt) != SQLITE_DONE) {
502 545 fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
503 546 return 3;
504 547 }
505 548 sqlite3_finalize(stmt);
506   - i++;
507 549 }
508   - }
509 550  
510   - /* buildrequires */
511   - for (i = 0; i < currsource->requirecount; i++) {
512   - snprintf(sqlite3_query, PATH_MAX, "INSERT INTO buildrequires VALUES(NULL,%ld,?,%ld,?);",
513   - currsource->id,
514   - currsource->require[i]->flags);
515   -
516   - if (sqlite3_prepare_v2(db, sqlite3_query, -1, &stmt, NULL)) {
517   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
518   - }
519   - sqlite3_bind_text(stmt, 1, currsource->require[i]->name, -1, SQLITE_STATIC);
520   - sqlite3_bind_text(stmt, 2, currsource->require[i]->version, -1, SQLITE_STATIC);
521   - if (sqlite3_step(stmt) != SQLITE_DONE) {
522   - fprintf(stderr, "ERROR: SQLite: (%s) %s\n", sqlite3_query, sqlite3_errmsg(db));
523   - return 3;
524   - }
525   - sqlite3_finalize(stmt);
526   - }
527   -
528 551 /* sources <-> provided relations (buildrequirements) */
529 552 /* for (i=0; i<currsource->providecount; i++) {
530 553 snprintf(sqlite3_query, PATH_MAX, "INSERT INTO sources_provided_rel VALUES(NULL,%d,%d);",
... ... @@ -541,8 +564,9 @@
541 564 sqlite3_finalize(stmt);
542 565 }*/
543 566  
544   - if (currsource->changelog) {
545   - nextchangelogid = generateSQLite_add_changelog(db, currsource->changelog, currsource->id) + 1;
  567 + if (currsource->changelog) {
  568 + nextchangelogid = generateSQLite_add_changelog(db, currsource->changelog, currsource->id) + 1;
  569 + }
546 570 }
547 571 currsource = currsource->next;
548 572 }
... ... @@ -92,6 +92,7 @@
92 92 #define MODE_GENPKGLIST 64
93 93 #define MODE_SQLITE3 128
94 94 #define MODE_SQLITE3_FILES 256
  95 +#define MODE_GENCONTENTSLIST 512
95 96  
96 97 static void program_usage(int exit_code);
97 98 static void program_version(void);
... ... @@ -147,6 +148,7 @@
147 148 " --gensrcpkglist generate a source packages list with version",
148 149 " --gensqlite3 dump data to SQLite3 databases",
149 150 " --gensqlite3files dump files to SQLite3 databases",
  151 +" --gencontentslist generate files listing all files in packages",
150 152 " --find-deps <package> find dependencies for given package name",
151 153 " --changelog <package> print changelog for given package name",
152 154 " --changelogsince <mmddyy> print changelog for all packages since given date",
153 155  
... ... @@ -895,10 +897,16 @@
895 897 }
896 898  
897 899 if (mode & MODE_DATA_TABLES) {
898   - if (!quietmode) fprintf(stdout,"%s: writing dependencies table...\n",configtag->arch[arch]);
899   - print_datatables(configtag,arch);
  900 + if (!quietmode) fprintf(stdout,"%s: writing dependencies tables...\n",configtag->arch[arch]);
  901 + print_datatables(configtag,arch);
900 902 }
901 903  
  904 +
  905 + if (mode & MODE_GENCONTENTSLIST) {
  906 + if (!quietmode) fprintf(stdout,"%s: writing contentslist files...\n",configtag->arch[arch]);
  907 + print_contentslist(configtag,arch);
  908 + }
  909 +
902 910 if (genheader_mode & GENHEADER_STATS) {
903 911 if (!quietmode) fprintf(stdout,"%s: generating statistics...\n",configtag->arch[arch]);
904 912  
... ... @@ -956,6 +964,7 @@
956 964 { "gensrcpkglist", no_argument, 0, 0 },
957 965 { "gensqlite3", no_argument, 0, 0 },
958 966 { "gensqlite3files", no_argument, 0, 0 },
  967 + { "gencontentslist", no_argument, 0, 0 },
959 968 { "arch", required_argument, 0, 'a' },
960 969 { "conf", required_argument, 0, 'c' },
961 970 { "help", no_argument, 0, 'h' },
... ... @@ -1019,6 +1028,9 @@
1019 1028 } else if (!strcmp(longopts[longindex].name, "genbuildinfo")) {
1020 1029 mode |= MODE_GENBUILDINFO;
1021 1030 genheader_mode |= GENHEADER_BASE;
  1031 + name = NULL;
  1032 + } else if (!strcmp(longopts[longindex].name, "gencontentslist")) {
  1033 + mode |= MODE_GENCONTENTSLIST;
1022 1034 name = NULL;
1023 1035 }
1024 1036 break;
src/include/reports.h
... ... @@ -28,6 +28,7 @@
28 28 int generateHTMLMainIndex(struct configTag *configtag);
29 29 char *groupdirname(char *group,char *dest,unsigned int max);
30 30 int write_RPM_HTML(struct configTag *ct,FILE *fout, struct headerList *currheaderlist);
  31 +int print_contentslist(struct configTag *ct, int arch);
31 32 int print_datatables(struct configTag *ct, int arch);
32 33 char *ftname(struct fileTree* ft, char* buf, unsigned int bufsize);
33 34 void print_contents_subtree(FILE *f,
... ... @@ -1764,13 +1764,32 @@
1764 1764  
1765 1765 }
1766 1766  
1767   -int
1768   -print_datatables(struct configTag *ct, int arch) {
  1767 +int print_contentslist(struct configTag *ct, int arch) {
  1768 + FILE *fc;
  1769 + char contents_filename[PATH_MAX],buf[PATH_MAX];
1769 1770  
1770   - FILE *fbd,*fd,*fv,*fb,*fbsh,*fs,*fc,*fw;
  1771 + snprintf(contents_filename, PATH_MAX, "%scontentslist-%s", ct->repository_dir, ct->arch[arch]);
  1772 +
  1773 + fc=fopen(contents_filename,"w");
  1774 + if (!fc) {
  1775 + fprintf(stderr, "Error: can't open file for writing: %s. Aborting.\n", contents_filename);
  1776 + return 1;
  1777 + }
  1778 +
  1779 + //write contents (filenames)
  1780 + logmsg(LOG_DEBUG,"writing contents file");
  1781 + print_contents_subtree(fc, ct->filetree[arch], ct, buf, PATH_MAX);
  1782 +
  1783 + fclose(fc);
  1784 + return 0;
  1785 +}
  1786 +
  1787 +int print_datatables(struct configTag *ct, int arch) {
  1788 +
  1789 + FILE *fbd,*fd,*fv,*fb,*fbsh,*fs,*fw;
1771 1790 char builddeps_filename[PATH_MAX], deps_filename[PATH_MAX], virtual_filename[PATH_MAX],
1772 1791 builds_filename[PATH_MAX], builds_sh_filename[PATH_MAX], sources_filename[PATH_MAX],
1773   - contents_filename[PATH_MAX], warnings_filename[PATH_MAX], buf[PATH_MAX];
  1792 + warnings_filename[PATH_MAX];
1774 1793 char obsoletebuf[PATH_MAX];
1775 1794 struct headerList *currheaderlist, *currchild;
1776 1795 struct headerSourceList *currheadersourcelist, *oldheadersourcelist;
... ... @@ -1783,7 +1802,6 @@
1783 1802 snprintf(builds_filename, PATH_MAX, "%sbuilds-%s", ct->html_dir, ct->arch[arch]);
1784 1803 snprintf(builds_sh_filename, PATH_MAX, "%sbuilds-%s.sh", ct->html_dir, ct->arch[arch]);
1785 1804 snprintf(sources_filename, PATH_MAX, "%ssources-%s", ct->html_dir, ct->arch[arch]);
1786   - snprintf(contents_filename, PATH_MAX, "%scontentslist-%s", ct->repository_dir, ct->arch[arch]);
1787 1805 snprintf(warnings_filename, PATH_MAX, "%swarnings-%s", ct->repository_dir, ct->arch[arch]);
1788 1806  
1789 1807 fbd=fopen(builddeps_filename,"w");
... ... @@ -1822,12 +1840,6 @@
1822 1840 return 1;
1823 1841 }
1824 1842  
1825   - fc=fopen(contents_filename,"w");
1826   - if (!fc) {
1827   - fprintf(stderr, "Error: can't open file for writing: %s. Aborting.\n", contents_filename);
1828   - return 1;
1829   - }
1830   -
1831 1843 fw=fopen(warnings_filename,"w");
1832 1844 if (!fw) {
1833 1845 fprintf(stderr, "Error: can't open file for writing: %s. Aborting.\n", warnings_filename);
... ... @@ -1933,10 +1945,6 @@
1933 1945 provided = provided->next;
1934 1946 }
1935 1947  
1936   - //write contents (filenames)
1937   - logmsg(LOG_DEBUG,"writing contents file");
1938   - print_contents_subtree(fc, ct->filetree[arch], ct, buf, PATH_MAX);
1939   -
1940 1948 logmsg(LOG_DEBUG,"writing deps files (2)");
1941 1949 currheaderlist = ct->headerlist[arch];
1942 1950 while (currheaderlist) {
... ... @@ -2112,7 +2120,6 @@
2112 2120 fclose(fbsh);
2113 2121 fclose(fb);
2114 2122 fclose(fs);
2115   - fclose(fc);
2116 2123 fclose(fw);
2117 2124  
2118 2125 return 0;