Commit 3702e5da authored by Bernhard Link's avatar Bernhard Link

atomize architecture, component and packagetype fields (at least in most places)

parent 23357fd0
2008-10-05
* Internaly atomize components architectures and packagetypes.
Causes multiple checks for unknown identifiers to be earlier or
more strict. (And fields in conf/distributions have more
restrictions w.r.t their order).
2008-10-01
* warn if an update rule references local components or architectures
that were not seen in conf/distributions (old behaviour was to check
......
......@@ -13,7 +13,8 @@ TODO:
(or alternatively allow ! in inclusion lists).
half far goals:
handle components, architectures and types as numeric atoms for filters
use numeric atoms for components, architectures and types in more
places (especially in filters)
rewrite error handling, caching error messages and handling Ctrl-C better.
far goals:
......
......@@ -26,22 +26,47 @@
const char **atoms_architectures;
const char **atoms_components;
const char * const packagetypes[3] = { "dsc", "deb", "udeb" };
const char **atoms_packagetype = (const char **)&packagetypes;
const char * const packagetypes[4] = { "!!NONE!!", "dsc", "deb", "udeb" };
const char **atoms_packagetypes = (const char **)&packagetypes;
const char **atoms_commands;
static int command_count;
static const char * const types[4] = {"architecture", "component", "packagetype", "command"};
const char **atomtypes = (const char **)types;
/* trivial implementation for now, perhaps make it more complicated later */
static struct strlist architectures, components;
retvalue atoms_init(void) {
retvalue atoms_init(int count) {
retvalue r;
strlist_init(&architectures);
strlist_init(&components);
/* add a 0th entry to all, so 0 means uninitialized */
r = strlist_add_dup(&architectures, "!!NONE!!");
if( RET_WAS_ERROR(r) )
return r;
r = strlist_add_dup(&architectures, "source");
if( RET_WAS_ERROR(r) )
return r;
r = strlist_add_dup(&architectures, "all");
if( RET_WAS_ERROR(r) )
return r;
r = strlist_add_dup(&components, "!!NONE!!");
if( RET_WAS_ERROR(r) )
return r;
/* a fallback component to put things without a component in */
r = strlist_add_dup(&components, "strange");
if( RET_WAS_ERROR(r) )
return r;
atoms_components = (const char**)components.values;
atoms_architectures = (const char**)architectures.values;
command_count = count;
if( command_count > 0 ) {
atoms_commands = calloc(command_count + 1, sizeof(const char*));
if( FAILEDTOALLOC(atoms_commands) )
return RET_ERROR_OOM;
}
return RET_OK;
}
......@@ -83,18 +108,213 @@ retvalue component_intern(const char *value, component_t *atom_p) {
}
architecture_t architecture_find(const char *value) {
return (architecture_t)strlist_ofs(&architectures, value);
int i = strlist_ofs(&architectures, value);
if( i < 0 )
return atom_unknown;
else
return (architecture_t)i;
}
architecture_t architecture_find_l(const char *value, size_t l) {
architecture_t a;
for( a = architectures.count - 1 ; a > 0 ; a-- ) {
const char *name = atoms_architectures[a];
size_t len = strlen(name);
if( len == l && memcmp(name, value, len) == 0 )
return a;
}
return atom_unknown;
}
component_t component_find(const char *value) {
return (component_t)strlist_ofs(&components, value);
int i = strlist_ofs(&components, value);
if( i < 0 )
return atom_unknown;
else
return (architecture_t)i;
}
packagetype_t packagetype_find(const char *value) {
if( strcmp(value, "dsc") == 0 )
return (packagetype_t)0;
return pt_dsc;
else if( strcmp(value, "deb") == 0 )
return (packagetype_t)1;
return pt_deb;
else if( strcmp(value, "udeb") == 0 )
return (packagetype_t)2;
return pt_udeb;
else
return atom_unknown;
}
static inline command_t command_find(const char *value) {
command_t c;
for( c = command_count ; c > 0 ; c-- ) {
if( strcmp(atoms_commands[c], value) == 0 )
return c;
}
return atom_unknown;
}
atom_t atom_find(enum atom_type type, const char *value) {
switch( type ) {
case at_packagetype:
return packagetype_find(value);
case at_architecture:
return architecture_find(value);
case at_component:
return component_find(value);
case at_command:
return command_find(value);
default:
return atom_unknown;
}
}
retvalue atom_intern(enum atom_type type, const char *value, atom_t *atom_p) {
assert( type == at_architecture || type == at_component );
switch( type ) {
case at_architecture:
return architecture_intern(value, atom_p);
case at_component:
return component_intern(value, atom_p);
default:
return RET_ERROR;
}
}
void atomlist_init(struct atomlist *list) {
list->count = 0; list->size = 0;
list->atoms = 0;
}
void atomlist_done(struct atomlist *list) {
if( list->size > 0 ) {
assert( list->atoms != 0 );
free(list->atoms);
}
/* reset atoms but not size, so reuse can be catched */
list->atoms = NULL;
}
/* add a atom uniquely (perhaps sorted), RET_NOTHING when already there */
retvalue atomlist_add_uniq(struct atomlist *list, atom_t atom) {
int i;
atom_t *n;
assert( atom_defined(atom) );
for( i = 0 ; i < list->count ; i++ ) {
if( list->atoms[i] == atom )
return RET_NOTHING;
}
if( list->size <= list->count ) {
n = realloc(list->atoms, (sizeof(atom_t))*(list->count + 8) );
if( FAILEDTOALLOC(n) )
return RET_ERROR_OOM;
list->size = list->count + 8;
list->atoms = n;
}
list->atoms[list->count++] = atom;
return RET_OK;
}
retvalue atomlist_add(struct atomlist *list, atom_t atom) {
atom_t *n;
assert( atom_defined(atom) );
if( list->size <= list->count ) {
n = realloc(list->atoms, (sizeof(atom_t))*(list->count + 8) );
if( FAILEDTOALLOC(n) )
return RET_ERROR_OOM;
list->size = list->count + 8;
list->atoms = n;
}
list->atoms[list->count++] = atom;
return RET_OK;
}
/* replace the contents of dest with those from orig, which get emptied */
void atomlist_move(struct atomlist *dest, struct atomlist *orig) {
dest->atoms = orig->atoms;
dest->count = orig->count;
dest->size = orig->size;
/* reset atoms but not size, so reuse can be catched */
orig->atoms = NULL;
}
bool atomlist_in(const struct atomlist *list, atom_t atom) {
int i;
for( i = 0 ; i < list->count ; i++ ) {
if( list->atoms[i] == atom )
return true;
}
return false;
}
int atomlist_ofs(const struct atomlist *list, atom_t atom) {
int i;
for( i = 0 ; i < list->count ; i++ ) {
if( list->atoms[i] == atom )
return i;
}
return -1;
}
bool atomlist_subset(const struct atomlist *list, const struct atomlist *subset, atom_t *missing) {
int i, j;
for( j = 0 ; j < subset->count ; j++ ) {
atom_t atom = subset->atoms[j];
for( i = 0 ; i < list->count ; i++ ) {
if( list->atoms[i] == atom )
break;
}
if( i >= list->count ) {
if( missing != NULL )
*missing = atom;
return false;
}
}
return true;
}
retvalue atomlist_fprint(FILE *file, enum atom_type type, const struct atomlist *list) {
const char **atoms = NULL;
int c;
atom_t *p;
retvalue result;
assert(list != NULL);
assert(file != NULL);
switch( type ) {
case at_architecture:
atoms = atoms_architectures;
break;
case at_component:
atoms = atoms_components;
break;
case at_packagetype:
atoms = atoms_packagetypes;
break;
case at_command:
atoms = atoms_commands;
break;
}
assert(atoms != NULL);
c = list->count;
p = list->atoms;
result = RET_OK;
while( c > 0 ) {
if( fputs(atoms[*(p++)], file) == EOF )
result = RET_ERROR;
if( --c > 0 && fputc(' ', file) == EOF )
result = RET_ERROR;
}
return result;
}
......@@ -5,18 +5,64 @@ typedef int atom_t;
typedef atom_t architecture_t;
typedef atom_t component_t;
typedef atom_t packagetype_t;
typedef atom_t command_t;
#define atom_unknown ((atom_t)-1)
#define architecture_all ((atom_t)0)
enum atom_type { at_architecture, at_component, at_packagetype, at_command };
extern const char **atoms_architectures, **atoms_components, **atoms_packagetype;
#define atom_unknown ((atom_t)0)
retvalue atoms_init(void);
#define architecture_source ((architecture_t)1)
#define architecture_all ((architecture_t)2)
#define component_strange ((component_t)1)
#define pt_dsc ((packagetype_t)1)
#define pt_deb ((packagetype_t)2)
#define pt_udeb ((packagetype_t)3)
#define atom_defined(a) ((a) > (atom_t)0)
extern const char **atomtypes, **atoms_architectures, **atoms_components, **atoms_packagetypes, **atoms_commands;
retvalue atoms_init(int command_count);
retvalue architecture_intern(const char *, /*@out@*/architecture_t *);
architecture_t architecture_find(const char *);
architecture_t architecture_find_l(const char *, size_t);
retvalue component_intern(const char *, /*@out@*/component_t *);
component_t component_find(const char *);
packagetype_t packagetype_find(const char *);
atom_t atom_find(enum atom_type, const char *);
retvalue atom_intern(enum atom_type, const char *, /*@out@*/atom_t *);
#define limitation_missed(a, b) ((atom_defined(a) && (a) != (b) ))
struct atomlist {
atom_t *atoms;
int count, size;
};
void atomlist_init(/*@out@*/struct atomlist *);
void atomlist_done(/*@special@*/struct atomlist *atomlist) /*@releases atomlist->values @*/;
/* add a atom uniquely (not sorted, component guessing might not like it),
* RET_NOTHING when already there */
retvalue atomlist_add_uniq(struct atomlist *, atom_t);
/* always add to the end */
retvalue atomlist_add(struct atomlist *, atom_t);
/* replace the contents of dest with those from orig, which get emptied */
void atomlist_move(/*@out@*/struct atomlist *, /*@special@*/struct atomlist *orig) /*@releases orig->values @*/;
bool atomlist_in(const struct atomlist *, atom_t);
int atomlist_ofs(const struct atomlist *, atom_t);
/* if missing != NULL And subset no subset of atomlist, set *missing to the first missing one */
bool atomlist_subset(const struct atomlist *, const struct atomlist *subset, /*@null@*/atom_t *missing);
/* print a space separated list of elements */
retvalue atomlist_fprint(FILE *, enum atom_type, const struct atomlist *);
#endif
This diff is collapsed.
......@@ -15,7 +15,8 @@
/* Functions for the target.h-stuff: */
retvalue binaries_getversion(const char *chunk,char **version);
retvalue binaries_getinstalldata(const struct target *t, const char *packagename, const char *version, const char *chunk, /*@out@*/char **control, /*@out@*/struct strlist *filekeys, /*@out@*/struct checksumsarray *origfiles, /*@null@*//*@out@*/enum filetype *);
retvalue binaries_getinstalldata(const struct target *t, const char *packagename, const char *version, architecture_t, const char *chunk, /*@out@*/char **control, /*@out@*/struct strlist *filekeys, /*@out@*/struct checksumsarray *origfiles);
retvalue binaries_getarchitecture(const char *chunk, /*@out@*/architecture_t *);
retvalue binaries_getfilekeys(const char *chunk, /*@out@*/struct strlist *);
retvalue binaries_getchecksums(const char *chunk, /*@out@*/struct checksumsarray *);
retvalue binaries_doreoverride(const struct distribution *,const char *packagename,const char *controlchunk,/*@out@*/char **newcontrolchunk);
......@@ -27,7 +28,8 @@ retvalue binaries_getsourceandversion(const char *chunk, const char *packagename
struct deb_headers {
char *name,*version;
char *source,*architecture;
char *source;
architecture_t architecture_atom;
char *control;
/* only extracted when requested: */
/*@null@*/char *sourceversion;
......@@ -44,11 +46,11 @@ struct deb_headers {
retvalue binaries_readdeb(struct deb_headers *, const char *filename, bool needssourceversion);
void binaries_debdone(struct deb_headers *);
retvalue binaries_calcfilekeys(const char *component,const struct deb_headers *,const char *packagetype,struct strlist *filekeys);
retvalue binaries_calcfilekeys(component_t, const struct deb_headers *, packagetype_t, /*@out@*/struct strlist *);
struct overrideinfo;
retvalue binaries_complete(const struct deb_headers *, const char *filekey, const struct checksums *, const struct overrideinfo *, const char *section, const char *priority, char **newcontrol);
retvalue binaries_adddeb(const struct deb_headers *, struct database *, /*@null@*/const char *forcearchitecture, const char *packagetype, struct distribution *, /*@null@*/struct strlist *dereferencedfilekeys, /*@null@*/struct trackingdata *, const char *component, const struct strlist *filekeys, bool *usedmarker, const char *control);
retvalue binaries_checkadddeb(const struct deb_headers *, struct database *, const char *forcearchitecture, const char *packagetype, struct distribution *, bool tracking, const char *component, bool permitnewerold);
retvalue binaries_adddeb(const struct deb_headers *, struct database *, architecture_t forcedarchitecture, packagetype_t, struct distribution *, /*@null@*/struct strlist *dereferencedfilekeys, /*@null@*/struct trackingdata *, component_t, const struct strlist *filekeys, bool *usedmarker, const char *control);
retvalue binaries_checkadddeb(const struct deb_headers *, struct database *, architecture_t forcearchitecture, packagetype_t, struct distribution *, bool tracking, component_t, bool permitnewerold);
#endif
......@@ -28,7 +28,7 @@
#include "checksums.h"
#include "changes.h"
retvalue changes_parsefileline(const char *fileline, /*@out@*/filetype *result_type, /*@out@*/char **result_basename, /*@out@*/struct hash_data *hash_p, /*@out@*/struct hash_data *size_p, /*@out@*/char **result_section, /*@out@*/char **result_priority, /*@out@*/char **result_architecture, /*@out@*/char **result_name) {
retvalue changes_parsefileline(const char *fileline, /*@out@*/filetype *result_type, /*@out@*/char **result_basename, /*@out@*/struct hash_data *hash_p, /*@out@*/struct hash_data *size_p, /*@out@*/char **result_section, /*@out@*/char **result_priority, /*@out@*/architecture_t *result_architecture, /*@out@*/char **result_name) {
const char *p,*md5start,*md5end;
const char *sizestart,*sizeend;
......@@ -38,7 +38,8 @@ retvalue changes_parsefileline(const char *fileline, /*@out@*/filetype *result_t
const char *archstart,*archend;
const char *versionstart,*typestart;
filetype type;
char *section, *priority, *basefilename, *architecture, *name;
char *section, *priority, *basefilename, *name;
architecture_t architecture;
p = fileline;
while( *p !='\0' && xisspace(*p) )
......@@ -193,13 +194,12 @@ retvalue changes_parsefileline(const char *fileline, /*@out@*/filetype *result_t
section = strndup(sectionstart, sectionend - sectionstart);
priority = strndup(priostart, prioend - priostart);
basefilename = strndup(filestart, fileend - filestart);
architecture = strndup(archstart, archend - archstart);
architecture = architecture_find_l(archstart, archend - archstart);
name = strndup(filestart, nameend - filestart);
if( FAILEDTOALLOC(section) || FAILEDTOALLOC(priority) ||
FAILEDTOALLOC(basefilename) || FAILEDTOALLOC(architecture) ||
FAILEDTOALLOC(name) ) {
FAILEDTOALLOC(basefilename) || FAILEDTOALLOC(name) ) {
free(section); free(priority);
free(basefilename); free(architecture); free(name);
free(basefilename); free(name);
return RET_ERROR_OOM;
}
hash_p->start = md5start;
......
#ifndef REPREPRO_CHANGES_H
#define REPREPRO_CHANGES_H
#ifndef REPREPRO_ATOMS_H
#include "atoms.h"
#endif
typedef enum { fe_UNKNOWN=0,fe_DEB,fe_UDEB,fe_DSC,fe_DIFF,fe_ORIG,fe_TAR} filetype;
#define FE_PACKAGE(ft) ( (ft) == fe_DEB || (ft) == fe_UDEB || (ft) == fe_DSC )
......@@ -8,5 +12,5 @@ typedef enum { fe_UNKNOWN=0,fe_DEB,fe_UDEB,fe_DSC,fe_DIFF,fe_ORIG,fe_TAR} filety
#define FE_SOURCE(ft) ( (ft) == fe_DIFF || (ft) == fe_ORIG || (ft) == fe_TAR || (ft) == fe_DSC || (ft) == fe_UNKNOWN)
struct hash_data;
retvalue changes_parsefileline(const char *fileline, /*@out@*/filetype *result_type, /*@out@*/char **result_basename, /*@out@*/struct hash_data *, /*@out@*/struct hash_data *, /*@out@*/char **result_section, /*@out@*/char **result_priority, /*@out@*/char **result_architecture, /*@out@*/char **result_name);
retvalue changes_parsefileline(const char *fileline, /*@out@*/filetype *result_type, /*@out@*/char **result_basename, /*@out@*/struct hash_data *, /*@out@*/struct hash_data *, /*@out@*/char **result_section, /*@out@*/char **result_priority, /*@out@*/architecture_t *, /*@out@*/char **result_name);
#endif
This diff is collapsed.
......@@ -11,13 +11,16 @@
#ifndef REPREPRO_DISTRIBUTION_H
#include "distribution.h"
#endif
#ifndef REPREPRO_ATOMS_H
#include "atoms.h"
#endif
/* insert the given .changes into the mirror in the <distribution>
* if forcecomponent, forcesection or forcepriority is NULL
* get it from the files or try to guess it.
* if dereferencedfilekeys is != NULL, add filekeys that lost reference,
* if tracks != NULL, update/add tracking information there... */
retvalue changes_add(struct database *,/*@null@*/trackingdb tracks,/*@null@*/const char *packagetypeonly,/*@null@*/const char *forcecomponent,/*@null@*/const char *forcearchitecture,/*@null@*/const char *forcesection,/*@null@*/const char *forcepriority,struct distribution *distribution,const char *changesfilename,int delete,/*@null@*/struct strlist *dereferencedfilekeys);
retvalue changes_add(struct database *, /*@null@*/trackingdb tracks, packagetype_t packagetypeonly, component_t, architecture_t forcearchitecture, /*@null@*/const char *forcesection, /*@null@*/const char *forcepriority, struct distribution *, const char *changesfilename, int delete, /*@null@*/struct strlist *dereferencedfilekeys);
#endif
......@@ -60,7 +60,7 @@ struct debpackage {
/* things to be set by deb_read: */
struct deb_headers deb;
/* things that will still be NULL then: */
char *component; //This might be const, too and save some strdups, but...
component_t component_atom;
/* with deb_calclocations: */
const char *filekey;
struct strlist filekeys;
......@@ -69,7 +69,6 @@ struct debpackage {
void deb_free(/*@only@*/struct debpackage *pkg) {
if( pkg != NULL ) {
binaries_debdone(&pkg->deb);
free(pkg->component);
if( pkg->filekey != NULL )
strlist_done(&pkg->filekeys);
}
......@@ -92,8 +91,6 @@ static retvalue deb_read(/*@out@*/struct debpackage **pkg, const char *filename,
r = properversion(deb->deb.sourceversion);
if( RET_IS_OK(r) )
r = properversion(deb->deb.version);
if( !RET_WAS_ERROR(r) )
r = properfilenamepart(deb->deb.architecture);
if( RET_WAS_ERROR(r) ) {
deb_free(deb);
return r;
......@@ -103,13 +100,13 @@ static retvalue deb_read(/*@out@*/struct debpackage **pkg, const char *filename,
return RET_OK;
}
static retvalue deb_preparelocation(struct debpackage *pkg, const char * const forcecomponent, const char * const forcearchitecture, const char *forcesection, const char *forcepriority, const char * const packagetype, struct distribution *distribution, const struct overrideinfo **oinfo_ptr, const char *debfilename){
const struct strlist *components;
static retvalue deb_preparelocation(struct debpackage *pkg, component_t forcecomponent, architecture_t forcearchitecture, const char *forcesection, const char *forcepriority, packagetype_t packagetype, struct distribution *distribution, const struct overrideinfo **oinfo_ptr, const char *debfilename){
const struct atomlist *components;
const struct overrideinfo *binoverride;
const struct overrideinfo *oinfo;
retvalue r;
if( strcmp(packagetype,"udeb") == 0 ) {
if( packagetype == pt_udeb ) {
binoverride = distribution->overrides.udeb;
components = &distribution->udebcomponents;
} else {
......@@ -156,38 +153,48 @@ static retvalue deb_preparelocation(struct debpackage *pkg, const char * const f
r = guess_component(distribution->codename, components,
pkg->deb.name, pkg->deb.section,
forcecomponent, &pkg->component);
forcecomponent, &pkg->component_atom);
if( RET_WAS_ERROR(r) )
return r;
if( verbose > 0 && forcecomponent == NULL ) {
fprintf(stderr,"%s: component guessed as '%s'\n",debfilename,pkg->component);
if( verbose > 0 && !atom_defined(forcecomponent) ) {
fprintf(stderr, "%s: component guessed as '%s'\n", debfilename,
atoms_components[pkg->component_atom]);
}
/* some sanity checks: */
if( forcearchitecture != NULL && strcmp(forcearchitecture,"all") != 0 &&
strcmp(pkg->deb.architecture,forcearchitecture) != 0 &&
strcmp(pkg->deb.architecture,"all") != 0 ) {
if( atom_defined(forcearchitecture) &&
forcearchitecture != architecture_all &&
pkg->deb.architecture_atom != forcearchitecture &&
pkg->deb.architecture_atom != architecture_all ) {
fprintf(stderr,"Cannot put '%s' into architecture '%s', as it is '%s'!\n",
debfilename,forcearchitecture,pkg->deb.architecture);
debfilename,
atoms_architectures[forcearchitecture],
atoms_architectures[pkg->deb.architecture_atom]);
return RET_ERROR;
} else if( strcmp(pkg->deb.architecture,"all") != 0 &&
!strlist_in( &distribution->architectures, pkg->deb.architecture )) {
(void)fprintf(stderr,"Error looking at '%s': '%s' is not one of the valid architectures: '",
debfilename, pkg->deb.architecture);
(void)strlist_fprint(stderr, &distribution->architectures);
} else if( pkg->deb.architecture_atom != architecture_all &&
!atomlist_in(&distribution->architectures,
pkg->deb.architecture_atom)) {
(void)fprintf(stderr,
"Error looking at '%s': '%s' is not one of the valid architectures: '",
debfilename,
atoms_architectures[pkg->deb.architecture_atom]);
(void)atomlist_fprint(stderr, at_architecture,
&distribution->architectures);
(void)fputs("'\n",stderr);
return RET_ERROR;
}
if( !strlist_in(components,pkg->component) ) {
if( !atomlist_in(components, pkg->component_atom) ) {
fprintf(stderr,
"Error looking at %s': Would be placed in unavailable component '%s'!\n",
debfilename, pkg->component);
debfilename,
atoms_components[pkg->component_atom]);
/* this cannot be ignored as there is not data structure available*/
return RET_ERROR;
}
r = binaries_calcfilekeys(pkg->component, &pkg->deb, packagetype, &pkg->filekeys);
r = binaries_calcfilekeys(pkg->component_atom, &pkg->deb,
packagetype, &pkg->filekeys);
if( RET_WAS_ERROR(r) )
return r;
pkg->filekey = pkg->filekeys.values[0];
......@@ -195,7 +202,7 @@ static retvalue deb_preparelocation(struct debpackage *pkg, const char * const f
}
retvalue deb_prepare(/*@out@*/struct debpackage **deb, const char * const forcecomponent, const char * const forcearchitecture, const char *forcesection, const char *forcepriority, const char * const packagetype, struct distribution *distribution, const char *debfilename, const char * const givenfilekey, const struct checksums * checksums, const struct strlist *allowed_binaries, const char *expectedsourcepackage, const char *expectedsourceversion){
retvalue deb_prepare(/*@out@*/struct debpackage **deb, component_t forcecomponent, architecture_t forcearchitecture, const char *forcesection, const char *forcepriority, packagetype_t packagetype, struct distribution *distribution, const char *debfilename, const char * const givenfilekey, const struct checksums * checksums, const struct strlist *allowed_binaries, const char *expectedsourcepackage, const char *expectedsourceversion){
retvalue r;
struct debpackage *pkg;
const struct overrideinfo *oinfo;
......@@ -264,11 +271,11 @@ retvalue deb_prepare(/*@out@*/struct debpackage **deb, const char * const forcec
return RET_OK;
}
retvalue deb_addprepared(const struct debpackage *pkg, struct database *database, const char *forcearchitecture, const char *packagetype, struct distribution *distribution, struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata, bool *usedmarker) {
retvalue deb_addprepared(const struct debpackage *pkg, struct database *database, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata, bool *usedmarker) {
return binaries_adddeb(&pkg->deb, database, forcearchitecture,
packagetype, distribution, dereferencedfilekeys,
trackingdata,
pkg->component, &pkg->filekeys, usedmarker,
pkg->component_atom, &pkg->filekeys, usedmarker,
pkg->deb.control);
}
......@@ -276,7 +283,7 @@ retvalue deb_addprepared(const struct debpackage *pkg, struct database *database
* putting things with architecture of "all" into <d->architectures> (and also
* causing error, if it is not one of them otherwise)
* if component is NULL, guessing it from the section. */
retvalue deb_add(struct database *database,const char *forcecomponent,const char *forcearchitecture,const char *forcesection,const char *forcepriority,const char *packagetype,struct distribution *distribution,const char *debfilename,int delete,struct strlist *dereferencedfilekeys,/*@null@*/trackingdb tracks){
retvalue deb_add(struct database *database, component_t forcecomponent, architecture_t forcearchitecture, const char *forcesection, const char *forcepriority, packagetype_t packagetype, struct distribution *distribution, const char *debfilename, int delete, struct strlist *dereferencedfilekeys, /*@null@*/trackingdb tracks){
struct debpackage *pkg;
retvalue r;
struct trackingdata trackingdata;
......@@ -332,7 +339,7 @@ retvalue deb_add(struct database *database,const char *forcecomponent,const char
r = binaries_adddeb(&pkg->deb, database, forcearchitecture,
packagetype, distribution, dereferencedfilekeys,
(tracks!=NULL)?&trackingdata:NULL,
pkg->component, &pkg->filekeys, &fileused,
pkg->component_atom, &pkg->filekeys, &fileused,
pkg->deb.control);
assert( !RET_IS_OK(r) || fileused );
if( !fileused )
......
......@@ -19,11 +19,11 @@
* package. (forcesection and forcepriority have higher priority than the
* information there),
* if dereferencedfilekeys is != NULL, add there filekeys that lost a reference */
retvalue deb_add(struct database *,/*@null@*/const char *forcecomponent,/*@null@*/const char *forcearchitecture,/*@null@*/const char *forcesection,/*@null@*/const char *forcepriority,const char *packagetype,struct distribution *distribution,const char *debfilename,int delete,/*@null@*/struct strlist *dereferencedfilekeys,/*@null@*/trackingdb);
retvalue deb_add(struct database *, component_t forcecomponent, architecture_t forcearchitecture, /*@null@*/const char *forcesection, /*@null@*/const char *forcepriority, packagetype_t, struct distribution *, const char *debfilename, int delete, /*@null@*/struct strlist *dereferencedfilekeys, /*@null@*/trackingdb);
/* in two steps */
struct debpackage;
retvalue deb_addprepared(const struct debpackage *pkg, struct database *, /*@null@*/const char *forcearchitecture, const char *packagetype, struct distribution *distribution, struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata, bool *usedmarker);
retvalue deb_prepare(/*@out@*/struct debpackage **deb, const char * const forcecomponent, const char * const forcearchitecture, const char *forcesection, const char *forcepriority, const char * const packagetype, struct distribution *distribution, const char *debfilename, const char * const filekey, const struct checksums *checksums, const struct strlist *allowed_binaries, const char *expectedsourcename, const char *expectedsourceversion);
retvalue deb_addprepared(const struct debpackage *pkg, struct database *, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata, bool *usedmarker);
retvalue deb_prepare(/*@out@*/struct debpackage **deb, component_t forcecomponent, architecture_t forcearchitecture, const char *forcesection, const char *forcepriority, packagetype_t, struct distribution *distribution, const char *debfilename, const char * const filekey, const struct checksums *checksums, const struct strlist *allowed_binaries, const char *expectedsourcename, const char *expectedsourceversion);
void deb_free(/*@only@*/struct debpackage *pkg);
#endif
......@@ -86,7 +86,7 @@ struct dscpackage {
/* things to be set by dsc_read: */
struct dsc_headers dsc;
/* things that will still be NULL then: */
char *component; //This might be const, too and save some strdups, but...
component_t component_atom;
/* Things that may be calculated by dsc_calclocations: */
struct strlist filekeys;
/* if set, everything set to true should be deleted when not used */
......@@ -108,7 +108,6 @@ static void dsc_free(/*@only@*/struct dscpackage *pkg, struct database *database
free(pkg->deleteonfailure);
}
sources_done(&pkg->dsc);
free(pkg->component);
strlist_done(&pkg->filekeys);
free(pkg);
}
......@@ -138,14 +137,16 @@ static retvalue dsc_read(/*@out@*/struct dscpackage **pkg, const char *filename)
dsc_free(dsc, NULL);
return r;
}
dsc->component_atom = atom_unknown;
*pkg = dsc;
return RET_OK;
}
retvalue dsc_addprepared(struct database *database, const struct dsc_headers *dsc, const char *component, const struct strlist *filekeys, bool *usedmarker, struct distribution *distribution, struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata){
retvalue dsc_addprepared(struct database *database, const struct dsc_headers *dsc, component_t component, const struct strlist *filekeys, bool *usedmarker, struct distribution *distribution, struct strlist *dereferencedfilekeys, struct trackingdata *trackingdata){
retvalue r;
struct target *t = distribution_getpart(distribution,component,"source","dsc");
struct target *t = distribution_getpart(distribution,
component, architecture_source, pt_dsc);
assert( logger_isprepared(distribution->logger) );
......@@ -161,7 +162,8 @@ retvalue dsc_addprepared(struct database *database, const struct dsc_headers *ds
dsc->control, filekeys,
usedmarker,
false, dereferencedfilekeys,
trackingdata, ft_SOURCE);
trackingdata,
architecture_source);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
}
......@@ -174,7 +176,7 @@ retvalue dsc_addprepared(struct database *database, const struct dsc_headers *ds
* If basename, filekey and directory are != NULL, then they are used instead
* of being newly calculated.
* (And all files are expected to already be in the pool). */
retvalue dsc_add(struct database *database,const char *forcecomponent,const char *forcesection,const char *forcepriority,struct distribution *distribution,const char *dscfilename,int delete,struct strlist *dereferencedfilekeys, trackingdb tracks){
retvalue dsc_add(struct database *database, component_t forcecomponent, const char *forcesection, const char *forcepriority, struct distribution *distribution, const char *dscfilename, int delete, struct strlist *dereferencedfilekeys, trackingdb tracks){
retvalue r;
struct dscpackage *pkg;
struct trackingdata trackingdata;
......@@ -188,8 +190,10 @@ retvalue dsc_add(struct database *database,const char *forcecomponent,const char
/* First make sure this distribution has a source section at all,