69
static retvalue collect_source_versions(struct database *database, struct distribution *d, struct info_source **out) {
69
static retvalue collect_source_versions(struct distribution *d, struct info_source **out) {
70
70
struct info_source *root = NULL, *last = NULL;
72
72
struct target_cursor target_cursor = TARGET_CURSOR_ZERO;
74
74
retvalue result = RET_NOTHING, r;
76
76
for (t = d->targets ; t != NULL ; t = t->next) {
77
if (t->architecture_atom != architecture_source)
77
if (t->architecture != architecture_source)
79
r = target_openiterator(t, database, true, &target_cursor);
79
r = target_openiterator(t, true, &target_cursor);
80
80
if (RET_WAS_ERROR(r)) {
81
81
RET_UPDATE(result, r);
148
148
assert (last != NULL);
149
assert (strcmp(name,last->name)==0);
149
assert (strcmp(name, last->name)==0);
151
151
v = &last->version;
152
152
while (strcmp(v->version, version) != 0) {
153
153
if (v->next == NULL) {
154
v->next = calloc(1, sizeof(struct info_source_version));
154
v->next = zNEW(struct info_source_version);
155
155
if (FAILEDTOALLOC(v->next)) {
157
157
result = RET_ERROR_OOM;
185
static retvalue process_binaries(struct database *db, struct distribution *d, struct info_source *sources, retvalue (*action)(struct distribution *, struct target *,const char *, const char *, const char *, const char *, void *), void *privdata) {
185
static retvalue process_binaries(struct distribution *d, struct info_source *sources, retvalue (*action)(struct distribution *, struct target *, const char *, const char *, const char *, const char *, void *), void *privdata) {
186
186
struct target *t;
187
187
struct target_cursor target_cursor = TARGET_CURSOR_ZERO;
188
188
const char *name, *chunk;
189
189
retvalue result = RET_NOTHING, r;
191
191
for (t = d->targets ; t != NULL ; t = t->next) {
192
if (t->architecture_atom == architecture_source)
192
if (t->architecture == architecture_source)
194
r = target_openiterator(t, db, true, &target_cursor);
194
r = target_openiterator(t, true, &target_cursor);
195
195
if (RET_WAS_ERROR(r)) {
196
196
RET_UPDATE(result, r);
240
240
bool hasbinary = false, hassource = false;
243
for( i = 0 ; i < pkg->filekeys.count ; i++ ) {
244
if( pkg->refcounts[i] == 0 )
243
for (i = 0 ; i < pkg->filekeys.count ; i++) {
244
if (pkg->refcounts[i] == 0)
246
if( pkg->filetypes[i] == 's' )
246
if (pkg->filetypes[i] == 's')
247
247
hassource = true;
248
if( pkg->filetypes[i] == 'b' )
248
if (pkg->filetypes[i] == 'b')
249
249
hasbinary = true;
250
if( pkg->filetypes[i] == 'a' )
250
if (pkg->filetypes[i] == 'a')
251
251
hasbinary = true;
253
if( hassource && ! hasbinary ) {
254
printf("%s %s %s\n", d->codename, pkg->sourcename, pkg->sourceversion);
253
if (hassource && ! hasbinary) {
254
printf("%s %s %s\n", d->codename, pkg->sourcename,
257
258
return RET_NOTHING;
260
retvalue unusedsources(struct database *database, struct distribution *alldistributions) {
261
retvalue unusedsources(struct distribution *alldistributions) {
261
262
struct distribution *d;
262
263
retvalue result = RET_NOTHING, r;
264
for( d = alldistributions ; d != NULL ; d = d->next ) {
267
if( !atomlist_in(&d->architectures, architecture_source) )
269
if( d->tracking != dt_NONE ) {
270
r = tracking_foreach_ro(database, d, listunusedsources);
265
for (d = alldistributions ; d != NULL ; d = d->next) {
268
if (!atomlist_in(&d->architectures, architecture_source))
270
if (d->tracking != dt_NONE) {
271
r = tracking_foreach_ro(d, listunusedsources);
271
272
RET_UPDATE(result, r);
272
if( RET_WAS_ERROR(r) )
273
if (RET_WAS_ERROR(r))
277
278
const struct info_source *s;
278
279
const struct info_source_version *v;
280
r = collect_source_versions(database, d, &sources);
281
r = collect_source_versions(d, &sources);
281
282
if (!RET_IS_OK(r))
284
r = process_binaries(database, d, sources, NULL, NULL);
285
r = process_binaries(d, sources, NULL, NULL);
285
286
RET_UPDATE(result, r);
286
287
for (s = sources ; s != NULL ; s = s->next) {
287
288
for (v = &s->version ; v != NULL ; v = v->next) {
300
301
bool hasbinary = false, hassource = false;
303
for( i = 0 ; i < pkg->filekeys.count ; i++ ) {
304
if( pkg->refcounts[i] == 0 )
304
for (i = 0 ; i < pkg->filekeys.count ; i++) {
305
if (pkg->refcounts[i] == 0)
306
if( pkg->filetypes[i] == 's' )
307
if (pkg->filetypes[i] == 's')
307
308
hassource = true;
308
if( pkg->filetypes[i] == 'b' )
309
if (pkg->filetypes[i] == 'b')
309
310
hasbinary = true;
310
if( pkg->filetypes[i] == 'a' )
311
if (pkg->filetypes[i] == 'a')
311
312
hasbinary = true;
313
if( hasbinary && ! hassource ) {
314
for( i = 0 ; i < pkg->filekeys.count ; i++ ) {
315
if( pkg->refcounts[i] == 0 )
317
if( pkg->filetypes[i] != 'b' && pkg->filetypes[i] != 'a' )
319
printf("%s %s %s %s\n", d->codename, pkg->sourcename, pkg->sourceversion, pkg->filekeys.values[i]);
314
if (hasbinary && ! hassource) {
315
for (i = 0 ; i < pkg->filekeys.count ; i++) {
316
if (pkg->refcounts[i] == 0)
318
if (pkg->filetypes[i] != 'b' && pkg->filetypes[i] != 'a')
320
printf("%s %s %s %s\n", d->codename, pkg->sourcename,
322
pkg->filekeys.values[i]);
339
retvalue sourcemissing(struct database *database, struct distribution *alldistributions) {
342
retvalue sourcemissing(struct distribution *alldistributions) {
340
343
struct distribution *d;
341
344
retvalue result = RET_NOTHING, r;
343
for( d = alldistributions ; d != NULL ; d = d->next ) {
346
for (d = alldistributions ; d != NULL ; d = d->next) {
346
if( !atomlist_in(&d->architectures, architecture_source) ) {
349
if (!atomlist_in(&d->architectures, architecture_source)) {
349
352
"Not processing distribution '%s', as it has no source packages.\n",
353
if( d->tracking != dt_NONE ) {
354
r = tracking_foreach_ro(database, d, listsourcemissing);
356
if (d->tracking != dt_NONE) {
357
r = tracking_foreach_ro(d, listsourcemissing);
355
358
RET_UPDATE(result, r);
356
if( RET_WAS_ERROR(r) )
359
if (RET_WAS_ERROR(r))
359
362
struct info_source *sources = NULL;
361
r = collect_source_versions(database, d, &sources);
364
r = collect_source_versions(d, &sources);
362
365
if (!RET_IS_OK(r))
365
r = process_binaries(database, d, sources,
368
r = process_binaries(d, sources, listmissing, NULL);
367
369
RET_UPDATE(result, r);
368
370
free_source_info(sources);
376
378
bool hasbinary = false, hassource = false;
379
for( i = 0 ; i < pkg->filekeys.count ; i++ ) {
380
if( pkg->refcounts[i] == 0 )
381
for (i = 0 ; i < pkg->filekeys.count ; i++) {
382
if (pkg->refcounts[i] == 0)
382
if( pkg->filetypes[i] == 's' )
384
if (pkg->filetypes[i] == 's')
383
385
hassource = true;
384
if( pkg->filetypes[i] == 'b' )
386
if (pkg->filetypes[i] == 'b')
385
387
hasbinary = true;
386
if( pkg->filetypes[i] == 'a' )
388
if (pkg->filetypes[i] == 'a')
387
389
hasbinary = true;
389
if( hasbinary && ! hassource ) {
390
printf("binaries-without-source %s %s %s\n", d->codename, pkg->sourcename, pkg->sourceversion);
391
if (hasbinary && ! hassource) {
392
printf("binaries-without-source %s %s %s\n", d->codename,
393
pkg->sourcename, pkg->sourceversion);
392
} else if( hassource && ! hasbinary ) {
393
printf("source-without-binaries %s %s %s\n", d->codename, pkg->sourcename, pkg->sourceversion);
395
} else if (hassource && ! hasbinary) {
396
printf("source-without-binaries %s %s %s\n", d->codename,
397
pkg->sourcename, pkg->sourceversion);
396
400
return RET_NOTHING;
428
retvalue reportcruft(struct database *database, struct distribution *alldistributions) {
432
retvalue reportcruft(struct distribution *alldistributions) {
429
433
struct distribution *d;
430
434
retvalue result = RET_NOTHING, r;
432
for( d = alldistributions ; d != NULL ; d = d->next ) {
436
for (d = alldistributions ; d != NULL ; d = d->next) {
435
if( !atomlist_in(&d->architectures, architecture_source) ) {
439
if (!atomlist_in(&d->architectures, architecture_source)) {
438
442
"Not processing distribution '%s', as it has no source packages.\n",
442
if( d->tracking != dt_NONE ) {
443
r = tracking_foreach_ro(database, d, listcruft);
446
if (d->tracking != dt_NONE) {
447
r = tracking_foreach_ro(d, listcruft);
444
448
RET_UPDATE(result, r);
445
if( RET_WAS_ERROR(r) )
449
if (RET_WAS_ERROR(r))
451
455
const struct info_source *s;
452
456
const struct info_source_version *v;
454
r = collect_source_versions(database, d, &sources);
458
r = collect_source_versions( d, &sources);
455
459
if (!RET_IS_OK(r))
458
r = process_binaries(database, d, sources,
462
r = process_binaries( d, sources,
459
463
listmissingonce, &list);
460
464
RET_UPDATE(result, r);
461
465
for (s = sources ; s != NULL ; s = s->next) {
465
469
printf("source-without-binaries %s %s %s\n",
466
d->codename, s->name, v->version);
470
d->codename, s->name, v->version);
469
473
free_source_info(list);