~ubuntu-branches/ubuntu/raring/reprepro/raring

« back to all changes in this revision

Viewing changes to sourcecheck.c

  • Committer: Bazaar Package Importer
  • Author(s): Bernhard R. Link
  • Date: 2011-05-05 16:34:23 UTC
  • mfrom: (21.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110505163423-x49kbdijyoubai4x
Tags: 4.6.0-1
* new release
- general cleanup
- new FilterSrcList
* increase Standards-Version, no changes needed

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
        }
67
67
}
68
68
 
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;
71
71
        struct target *t;
72
72
        struct target_cursor target_cursor = TARGET_CURSOR_ZERO;
74
74
        retvalue result = RET_NOTHING, r;
75
75
 
76
76
        for (t = d->targets ; t != NULL ; t = t->next) {
77
 
                if (t->architecture_atom != architecture_source)
 
77
                if (t->architecture != architecture_source)
78
78
                        continue;
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);
82
82
                        break;
126
126
                                }
127
127
                        }
128
128
                        if (into != NULL) {
129
 
                                last = calloc(1, sizeof(struct info_source));
 
129
                                last = zNEW(struct info_source);
130
130
                                if (FAILEDTOALLOC(last)) {
131
131
                                        free(version);
132
132
                                        result = RET_ERROR_OOM;
146
146
                                continue;
147
147
                        }
148
148
                        assert (last != NULL);
149
 
                        assert (strcmp(name,last->name)==0);
 
149
                        assert (strcmp(name, last->name)==0);
150
150
 
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)) {
156
156
                                                free(version);
157
157
                                                result = RET_ERROR_OOM;
182
182
        return result;
183
183
}
184
184
 
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;
190
190
 
191
191
        for (t = d->targets ; t != NULL ; t = t->next) {
192
 
                if (t->architecture_atom == architecture_source)
 
192
                if (t->architecture == architecture_source)
193
193
                        continue;
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);
197
197
                        break;
240
240
        bool hasbinary = false, hassource = false;
241
241
        int i;
242
242
 
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)
245
245
                        continue;
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;
252
252
        }
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,
 
255
                                pkg->sourceversion);
255
256
                return RET_OK;
256
257
        }
257
258
        return RET_NOTHING;
258
259
}
259
260
 
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;
263
264
 
264
 
        for( d = alldistributions ; d != NULL ; d = d->next ) {
265
 
                if( !d->selected )
266
 
                        continue;
267
 
                if( !atomlist_in(&d->architectures, architecture_source) )
268
 
                        continue;
269
 
                if( d->tracking != dt_NONE ) {
270
 
                        r = tracking_foreach_ro(database, d, listunusedsources);
 
265
        for (d = alldistributions ; d != NULL ; d = d->next) {
 
266
                if (!d->selected)
 
267
                        continue;
 
268
                if (!atomlist_in(&d->architectures, architecture_source))
 
269
                        continue;
 
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))
273
274
                                return r;
274
275
                        continue;
275
276
                }
277
278
                const struct info_source *s;
278
279
                const struct info_source_version *v;
279
280
 
280
 
                r = collect_source_versions(database, d, &sources);
 
281
                r = collect_source_versions(d, &sources);
281
282
                if (!RET_IS_OK(r))
282
283
                        continue;
283
284
 
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;
301
302
        int i;
302
303
 
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)
305
306
                        continue;
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;
312
313
        }
313
 
        if( hasbinary && ! hassource ) {
314
 
                for( i = 0 ; i < pkg->filekeys.count ; i++ ) {
315
 
                        if( pkg->refcounts[i] == 0 )
316
 
                                continue;
317
 
                        if( pkg->filetypes[i] != 'b' && pkg->filetypes[i] != 'a' )
318
 
                                continue;
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)
 
317
                                continue;
 
318
                        if (pkg->filetypes[i] != 'b' && pkg->filetypes[i] != 'a')
 
319
                                continue;
 
320
                        printf("%s %s %s %s\n", d->codename, pkg->sourcename,
 
321
                                        pkg->sourceversion,
 
322
                                        pkg->filekeys.values[i]);
320
323
                }
321
324
                return RET_OK;
322
325
        }
336
339
        return RET_OK;
337
340
}
338
341
 
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;
342
345
 
343
 
        for( d = alldistributions ; d != NULL ; d = d->next ) {
344
 
                if( !d->selected )
 
346
        for (d = alldistributions ; d != NULL ; d = d->next) {
 
347
                if (!d->selected)
345
348
                        continue;
346
 
                if( !atomlist_in(&d->architectures, architecture_source) ) {
347
 
                        if( verbose >= 0 )
 
349
                if (!atomlist_in(&d->architectures, architecture_source)) {
 
350
                        if (verbose >= 0)
348
351
                                fprintf(stderr,
349
352
"Not processing distribution '%s', as it has no source packages.\n",
350
353
                                                d->codename);
351
354
                        continue;
352
355
                }
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))
357
360
                                return r;
358
361
                } else {
359
362
                        struct info_source *sources = NULL;
360
363
 
361
 
                        r = collect_source_versions(database, d, &sources);
 
364
                        r = collect_source_versions(d, &sources);
362
365
                        if (!RET_IS_OK(r))
363
366
                                continue;
364
367
 
365
 
                        r = process_binaries(database, d, sources,
366
 
                                        listmissing, NULL);
 
368
                        r = process_binaries(d, sources, listmissing, NULL);
367
369
                        RET_UPDATE(result, r);
368
370
                        free_source_info(sources);
369
371
                }
376
378
        bool hasbinary = false, hassource = false;
377
379
        int i;
378
380
 
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)
381
383
                        continue;
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;
388
390
        }
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);
391
394
                return RET_OK;
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);
394
398
                return RET_OK;
395
399
        }
396
400
        return RET_NOTHING;
407
411
                        continue;
408
412
                return RET_NOTHING;
409
413
        }
410
 
        s = calloc(1, sizeof(struct info_source));
 
414
        s = zNEW(struct info_source);
411
415
        if (FAILEDTOALLOC(s))
412
416
                return RET_ERROR_OOM;
413
417
        s->name = strdup(source);
425
429
        return RET_OK;
426
430
}
427
431
 
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;
431
435
 
432
 
        for( d = alldistributions ; d != NULL ; d = d->next ) {
433
 
                if( !d->selected )
 
436
        for (d = alldistributions ; d != NULL ; d = d->next) {
 
437
                if (!d->selected)
434
438
                        continue;
435
 
                if( !atomlist_in(&d->architectures, architecture_source) ) {
436
 
                        if( verbose >= 0 )
 
439
                if (!atomlist_in(&d->architectures, architecture_source)) {
 
440
                        if (verbose >= 0)
437
441
                                fprintf(stderr,
438
442
"Not processing distribution '%s', as it has no source packages.\n",
439
443
                                                d->codename);
440
444
                        continue;
441
445
                }
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))
446
450
                                return r;
447
451
                        continue;
448
452
                }
451
455
                const struct info_source *s;
452
456
                const struct info_source_version *v;
453
457
 
454
 
                r = collect_source_versions(database, d, &sources);
 
458
                r = collect_source_versions( d, &sources);
455
459
                if (!RET_IS_OK(r))
456
460
                        continue;
457
461
 
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) {
463
467
                                if (v->used)
464
468
                                        continue;
465
469
                                printf("source-without-binaries %s %s %s\n",
466
 
                                                d->codename, s->name, v->version);
 
470
                                        d->codename, s->name, v->version);
467
471
                        }
468
472
                }
469
473
                free_source_info(list);