55
55
before the pgp-end-block.(in case someone
56
56
missed the newline there))
58
* check to have source,version,maintainer,
58
* check to have source, version, maintainer,
59
59
standards-version, files. And also look
60
at binary,architecture and build*, as
60
at binary, architecture and build*, as
61
61
described in policy 5.4
63
63
* Get overwrite information, ecspecially
84
84
/* things to be set by dsc_read: */
85
85
struct dsc_headers dsc;
86
86
/* things that will still be NULL then: */
87
component_t component_atom;
87
component_t component;
88
88
/* Things that may be calculated by dsc_calclocations: */
89
89
struct strlist filekeys;
92
92
static void dsc_free(/*@only@*/struct dscpackage *pkg) {
94
94
sources_done(&pkg->dsc);
95
95
strlist_done(&pkg->filekeys);
106
dsc = calloc(1,sizeof(struct dscpackage));
106
dsc = zNEW(struct dscpackage);
107
if (FAILEDTOALLOC(dsc))
108
return RET_ERROR_OOM;
108
110
r = sources_readdsc(&dsc->dsc, filename, filename, &broken);
109
if( RET_IS_OK(r) && broken && !IGNORING_(brokensignatures,
111
if (RET_IS_OK(r) && broken && !IGNORING(brokensignatures,
110
112
"'%s' contains only broken signatures.\n"
111
113
"This most likely means the file was damaged or edited improperly\n",
115
117
r = propersourcename(dsc->dsc.name);
117
119
r = properversion(dsc->dsc.version);
119
121
r = properfilenames(&dsc->dsc.files.names);
120
if( RET_WAS_ERROR(r) ) {
122
if (RET_WAS_ERROR(r)) {
124
dsc->component_atom = atom_unknown;
126
dsc->component = atom_unknown;
130
retvalue dsc_addprepared(struct database *database, const struct dsc_headers *dsc, component_t component, const struct strlist *filekeys, struct distribution *distribution, struct trackingdata *trackingdata){
132
retvalue dsc_addprepared(const struct dsc_headers *dsc, component_t component, const struct strlist *filekeys, struct distribution *distribution, struct trackingdata *trackingdata){
132
134
struct target *t = distribution_getpart(distribution,
133
135
component, architecture_source, pt_dsc);
135
assert( logger_isprepared(distribution->logger) );
137
assert (logger_isprepared(distribution->logger));
137
139
/* finally put it into the source distribution */
138
r = target_initpackagesdb(t, database, READWRITE);
139
if( !RET_WAS_ERROR(r) ) {
140
r = target_initpackagesdb(t, READWRITE);
141
if (!RET_WAS_ERROR(r)) {
142
144
r = RET_ERROR_INTERRUPTED;
144
r = target_addpackage(t, distribution->logger, database,
146
r = target_addpackage(t, distribution->logger,
145
147
dsc->name, dsc->version,
146
148
dsc->control, filekeys,
147
149
false, trackingdata,
148
150
architecture_source,
150
152
r2 = target_closepackagesdb(t);
153
RET_ENDUPDATE(r, r2);
153
155
RET_UPDATE(distribution->status, r);
159
161
* If basename, filekey and directory are != NULL, then they are used instead
160
162
* of being newly calculated.
161
163
* (And all files are expected to already be in the pool). */
162
retvalue dsc_add(struct database *database, component_t forcecomponent, const char *forcesection, const char *forcepriority, struct distribution *distribution, const char *dscfilename, int delete, trackingdb tracks){
164
retvalue dsc_add(component_t forcecomponent, const char *forcesection, const char *forcepriority, struct distribution *distribution, const char *dscfilename, int delete, trackingdb tracks){
164
166
struct dscpackage *pkg;
165
167
struct trackingdata trackingdata;
173
175
/* First make sure this distribution has a source section at all,
174
176
* for which it has to be listed in the "Architectures:"-field ;-) */
175
if( !atomlist_in(&distribution->architectures, architecture_source) ) {
177
if (!atomlist_in(&distribution->architectures, architecture_source)) {
177
179
"Cannot put a source package into Distribution '%s' not having 'source' in its 'Architectures:'-field!\n",
178
180
distribution->codename);
184
186
r = dsc_read(&pkg, dscfilename);
185
if( RET_WAS_ERROR(r) ) {
187
if (RET_WAS_ERROR(r)) {
189
oinfo = override_search(distribution->overrides.dsc,pkg->dsc.name);
190
if( forcesection == NULL ) {
191
forcesection = override_get(oinfo,SECTION_FIELDNAME);
191
oinfo = override_search(distribution->overrides.dsc, pkg->dsc.name);
192
if (forcesection == NULL) {
193
forcesection = override_get(oinfo, SECTION_FIELDNAME);
193
if( forcepriority == NULL ) {
194
forcepriority = override_get(oinfo,PRIORITY_FIELDNAME);
195
if (forcepriority == NULL) {
196
forcepriority = override_get(oinfo, PRIORITY_FIELDNAME);
197
if( forcesection != NULL ) {
199
if (forcesection != NULL) {
198
200
free(pkg->dsc.section);
199
201
pkg->dsc.section = strdup(forcesection);
200
if( pkg->dsc.section == NULL ) {
202
if (FAILEDTOALLOC(pkg->dsc.section)) {
202
204
return RET_ERROR_OOM;
205
if( forcepriority != NULL ) {
207
if (forcepriority != NULL) {
206
208
free(pkg->dsc.priority);
207
209
pkg->dsc.priority = strdup(forcepriority);
208
if( pkg->dsc.priority == NULL ) {
210
if (FAILEDTOALLOC(pkg->dsc.priority)) {
210
212
return RET_ERROR_OOM;
214
216
r = dirs_getdirectory(dscfilename, &origdirectory);
215
if( RET_WAS_ERROR(r) ) {
217
if (RET_WAS_ERROR(r)) {
220
if( pkg->dsc.section == NULL || pkg->dsc.priority == NULL ) {
222
if (pkg->dsc.section == NULL || pkg->dsc.priority == NULL) {
221
223
struct sourceextraction *extraction;
223
225
extraction = sourceextraction_init(
224
226
(pkg->dsc.section == NULL)?&pkg->dsc.section:NULL,
225
227
(pkg->dsc.priority == NULL)?&pkg->dsc.priority:NULL);
226
if( FAILEDTOALLOC(extraction) ) {
228
if (FAILEDTOALLOC(extraction)) {
227
229
free(origdirectory);
229
231
return RET_ERROR_OOM;
231
for( i = 0 ; i < pkg->dsc.files.names.count ; i ++ )
233
for (i = 0 ; i < pkg->dsc.files.names.count ; i ++)
232
234
sourceextraction_setpart(extraction, i,
233
235
pkg->dsc.files.names.values[i]);
234
while( sourceextraction_needs(extraction, &i) ) {
236
while (sourceextraction_needs(extraction, &i)) {
235
237
char *fullfilename = calc_dirconcat(origdirectory,
236
238
pkg->dsc.files.names.values[i]);
237
if( FAILEDTOALLOC(fullfilename) ) {
239
if (FAILEDTOALLOC(fullfilename)) {
238
240
free(origdirectory);
240
242
return RET_ERROR_OOM;
256
258
r = sourceextraction_finish(extraction);
257
if( RET_WAS_ERROR(r) ) {
259
if (RET_WAS_ERROR(r)) {
258
260
free(origdirectory);
264
if( pkg->dsc.section == NULL && pkg->dsc.priority == NULL ) {
265
fprintf(stderr, "No section and no priority for '%s', skipping.\n",
271
if( pkg->dsc.section == NULL ) {
272
fprintf(stderr, "No section for '%s', skipping.\n", pkg->dsc.name);
277
if( pkg->dsc.priority == NULL ) {
278
fprintf(stderr, "No priority for '%s', skipping.\n", pkg->dsc.name);
283
if( !atom_defined(forcecomponent) ) {
266
if (pkg->dsc.section == NULL && pkg->dsc.priority == NULL) {
268
"No section and no priority for '%s', skipping.\n",
274
if (pkg->dsc.section == NULL) {
275
fprintf(stderr, "No section for '%s', skipping.\n",
281
if (pkg->dsc.priority == NULL) {
282
fprintf(stderr, "No priority for '%s', skipping.\n",
288
if (!atom_defined(forcecomponent)) {
286
291
fc = override_get(oinfo, "$Component");
288
293
forcecomponent = component_find(fc);
289
if( !atom_defined(forcecomponent) ) {
294
if (!atom_defined(forcecomponent)) {
291
296
"Unparseable component '%s' in $Component override of '%s'\n",
292
297
fc, pkg->dsc.name);
300
305
r = guess_component(distribution->codename, &distribution->components,
301
306
pkg->dsc.name, pkg->dsc.section, forcecomponent,
302
&pkg->component_atom);
303
if( RET_WAS_ERROR(r) ) {
308
if (RET_WAS_ERROR(r)) {
304
309
free(origdirectory);
308
if( verbose > 0 && !atom_defined(forcecomponent) ) {
313
if (verbose > 0 && !atom_defined(forcecomponent)) {
309
314
fprintf(stderr, "%s: component guessed as '%s'\n", dscfilename,
310
atoms_components[pkg->component_atom]);
315
atoms_components[pkg->component]);
313
318
{ char *dscbasename, *dscfilekey;
314
319
struct checksums *dscchecksums;
316
321
dscbasename = calc_source_basename(pkg->dsc.name, pkg->dsc.version);
317
destdirectory = calc_sourcedir(pkg->component_atom, pkg->dsc.name);
322
destdirectory = calc_sourcedir(pkg->component, pkg->dsc.name);
318
323
/* Calculate the filekeys: */
319
if( destdirectory != NULL )
324
if (destdirectory != NULL)
320
325
r = calc_dirconcats(destdirectory,
321
326
&pkg->dsc.files.names,
323
if( dscbasename == NULL || destdirectory == NULL || RET_WAS_ERROR(r) ) {
328
if (dscbasename == NULL || destdirectory == NULL || RET_WAS_ERROR(r)) {
324
329
free(dscbasename);
325
330
free(destdirectory); free(origdirectory);
329
334
dscfilekey = calc_dirconcat(destdirectory, dscbasename);
330
335
dscchecksums = NULL;
331
if( dscfilename == NULL )
336
if (FAILEDTOALLOC(dscfilename))
332
337
r = RET_ERROR_OOM;
334
339
/* then look if we already have this, or copy it in */
335
r = files_preinclude(database,
340
r = files_preinclude(
336
341
dscfilename, dscfilekey,
339
if( !RET_WAS_ERROR(r) ) {
340
/* Add the dsc-file to basenames,filekeys and md5sums,
344
if (!RET_WAS_ERROR(r)) {
345
/* Add the dsc-file to basenames, filekeys and md5sums,
341
346
* so that it will be listed in the Sources.gz */
343
348
r = checksumsarray_include(&pkg->dsc.files,
344
349
dscbasename, dscchecksums);
346
351
r = strlist_include(&pkg->filekeys, dscfilekey);
348
353
free(dscfilekey);
353
358
checksums_free(dscchecksums);
356
assert( pkg->dsc.files.names.count == pkg->filekeys.count );
357
for( i = 1 ; i < pkg->dsc.files.names.count ; i ++ ) {
358
if( !RET_WAS_ERROR(r) ) {
359
r = files_checkincludefile(database, origdirectory,
361
assert (pkg->dsc.files.names.count == pkg->filekeys.count);
362
for (i = 1 ; i < pkg->dsc.files.names.count ; i ++) {
363
if (!RET_WAS_ERROR(r)) {
364
r = files_checkincludefile(origdirectory,
360
365
pkg->dsc.files.names.values[i],
361
366
pkg->filekeys.values[i],
362
367
&pkg->dsc.files.checksums[i]);
366
371
/* Calculate the chunk to include: */
368
if( !RET_WAS_ERROR(r) )
373
if (!RET_WAS_ERROR(r))
369
374
r = sources_complete(&pkg->dsc, destdirectory, oinfo,
370
375
pkg->dsc.section, pkg->dsc.priority, &control);
371
376
free(destdirectory);
373
378
free(pkg->dsc.control);
374
379
pkg->dsc.control = control;
381
if( interrupted() ) {
383
388
free(origdirectory);
384
389
return RET_ERROR_INTERRUPTED;
387
if( tracks != NULL ) {
388
r = trackingdata_summon(tracks,pkg->dsc.name,pkg->dsc.version,&trackingdata);
389
if( RET_WAS_ERROR(r) ) {
392
if (tracks != NULL) {
393
r = trackingdata_summon(tracks, pkg->dsc.name,
394
pkg->dsc.version, &trackingdata);
395
if (RET_WAS_ERROR(r)) {
390
396
free(origdirectory);
396
r = dsc_addprepared(database, &pkg->dsc, pkg->component_atom,
402
r = dsc_addprepared(&pkg->dsc, pkg->component,
397
403
&pkg->filekeys, distribution,
398
404
(tracks!=NULL)?&trackingdata:NULL);
400
406
/* delete source files, if they are to be */
401
if( ( RET_IS_OK(r) && delete >= D_MOVE ) ||
402
( r == RET_NOTHING && delete >= D_DELETE ) ) {
407
if ((RET_IS_OK(r) && delete >= D_MOVE) ||
408
(r == RET_NOTHING && delete >= D_DELETE)) {
403
409
char *fullfilename;
405
for( i = 0 ; i < pkg->dsc.files.names.count ; i++ ) {
411
for (i = 0 ; i < pkg->dsc.files.names.count ; i++) {
406
412
fullfilename = calc_dirconcat(origdirectory,
407
413
pkg->dsc.files.names.values[i]);
408
if( fullfilename == NULL ) {
414
if (FAILEDTOALLOC(fullfilename)) {
409
415
r = RET_ERROR_OOM;
412
if( isregularfile(fullfilename) )
418
if (isregularfile(fullfilename))
413
419
deletefile(fullfilename);
414
420
free(fullfilename);