Commit 15bbaf07 authored by Bernhard Link's avatar Bernhard Link

Clean up some target methods, getinstalldata exports filetype

parent 4dfa1049
......@@ -75,7 +75,7 @@ static retvalue binaries_parse_checksums(const char *chunk, /*@out@*/struct chec
}
/* get somefields out of a "Packages.gz"-chunk. returns RET_OK on success, RET_NOTHING if incomplete, error otherwise */
static retvalue binaries_parse_chunk(const char *chunk,const char *packagename,const char *packagetype,const char *version,/*@out@*/char **sourcename,/*@out@*/char **basename) {
static retvalue binaries_parse_chunk(const char *chunk, const char *packagename, const char *packagetype, const char *version, /*@out@*/char **sourcename, /*@out@*/char **basename, /*@out@*/enum filetype *ft_p) {
retvalue r;
char *parch;
char *mysourcename,*mybasename;
......@@ -99,6 +99,10 @@ static retvalue binaries_parse_chunk(const char *chunk,const char *packagename,c
free(mysourcename);
return r;
}
if( strcmp(parch, "all") == 0 )
*ft_p = ft_ALL_BINARY;
else
*ft_p = ft_ARCH_BINARY;
r = properpackagename(packagename);
if( !RET_WAS_ERROR(r) )
r = properversion(version);
......@@ -170,7 +174,7 @@ static inline retvalue calcnewcontrol(const char *chunk,const char *sourcename,c
return RET_OK;
}
retvalue binaries_getname(UNUSED(struct target *t),const char *control,char **packagename){
retvalue binaries_getname(const char *control, char **packagename){
retvalue r;
r = chunk_getvalue(control,"Package",packagename);
......@@ -182,7 +186,7 @@ retvalue binaries_getname(UNUSED(struct target *t),const char *control,char **pa
}
return r;
}
retvalue binaries_getversion(UNUSED(struct target *t),const char *control,char **version) {
retvalue binaries_getversion(const char *control, char **version) {
retvalue r;
r = chunk_getvalue(control,"Version",version);
......@@ -195,12 +199,14 @@ retvalue binaries_getversion(UNUSED(struct target *t),const char *control,char *
return r;
}
retvalue binaries_getinstalldata(struct target *t, const char *packagename, const char *version, const char *chunk, char **control, struct strlist *filekeys, struct checksumsarray *origfiles) {
retvalue binaries_getinstalldata(const struct target *t, const char *packagename, const char *version, const char *chunk, char **control, struct strlist *filekeys, struct checksumsarray *origfiles, /*@null@*//*@out@*/enum filetype *type_p) {
char *sourcename IFSTUPIDCC(=NULL) ,*basename IFSTUPIDCC(=NULL);
struct checksumsarray origfilekeys;
retvalue r;
enum filetype ft IFSTUPIDCC(='?');
r = binaries_parse_chunk(chunk,packagename,t->packagetype,version,&sourcename,&basename);
r = binaries_parse_chunk(chunk, packagename, t->packagetype,
version, &sourcename, &basename, &ft);
if( RET_WAS_ERROR(r) ) {
return r;
} else if( r == RET_NOTHING ) {
......@@ -213,13 +219,16 @@ retvalue binaries_getinstalldata(struct target *t, const char *packagename, cons
return r;
}
r = calcnewcontrol(chunk,sourcename,basename,t->component,filekeys,control);
r = calcnewcontrol(chunk, sourcename, basename,
t->component, filekeys, control);
if( RET_WAS_ERROR(r) ) {
checksumsarray_done(&origfilekeys);
} else {
assert( r != RET_NOTHING );
checksumsarray_move(origfiles, &origfilekeys);
}
if( type_p != NULL )
*type_p = ft;
free(sourcename);free(basename);
return r;
}
......@@ -248,12 +257,10 @@ retvalue binaries_getchecksums(const char *chunk, struct checksumsarray *filekey
return RET_OK;
}
char *binaries_getupstreamindex(UNUSED(struct target *target),const char *suite_from,
const char *component_from,const char *architecture) {
char *binaries_getupstreamindex(const char *suite_from, const char *component_from, const char *architecture) {
return mprintf("dists/%s/%s/binary-%s/Packages.gz",suite_from,component_from,architecture);
}
char *ubinaries_getupstreamindex(UNUSED(struct target *target),const char *suite_from,
const char *component_from,const char *architecture) {
char *ubinaries_getupstreamindex(const char *suite_from, const char *component_from, const char *architecture) {
return mprintf("dists/%s/%s/debian-installer/binary-%s/Packages.gz",suite_from,component_from,architecture);
}
......@@ -388,7 +395,7 @@ retvalue binaries_retrack(const char *packagename, const char *chunk, trackingdb
return tracking_save(tracks, pkg);
}
retvalue binaries_getsourceandversion(UNUSED(struct target *t),const char *chunk,const char *packagename,char **source,char **version) {
retvalue binaries_getsourceandversion(const char *chunk, const char *packagename, char **source, char **version) {
retvalue r;
char *sourcename,*sourceversion;
......
......@@ -14,19 +14,17 @@
/* Functions for the target.h-stuff: */
retvalue binaries_getname(struct target *t,const char *chunk,char **packagename);
retvalue binaries_getversion(struct target *t,const char *chunk,char **version);
retvalue binaries_getinstalldata(struct target *t, const char *packagename, const char *version, const char *chunk, /*@out@*/char **control, /*@out@*/struct strlist *filekeys, /*@out@*/struct checksumsarray *origfiles);
retvalue binaries_getname(const char *chunk,char **packagename);
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_getfilekeys(const char *chunk, /*@out@*/struct strlist *);
retvalue binaries_getchecksums(const char *chunk, /*@out@*/struct checksumsarray *);
char *binaries_getupstreamindex(struct target *target,const char *suite_from,
const char *component_from,const char *architecture);
char *ubinaries_getupstreamindex(struct target *target,const char *suite_from,
const char *component_from,const char *architecture);
char *binaries_getupstreamindex(const char *suite_from, const char *component_from, const char *architecture);
char *ubinaries_getupstreamindex(const char *suite_from, const char *component_from, const char *architecture);
retvalue binaries_doreoverride(const struct distribution *,const char *packagename,const char *controlchunk,/*@out@*/char **newcontrolchunk);
retvalue ubinaries_doreoverride(const struct distribution *,const char *packagename,const char *controlchunk,/*@out@*/char **newcontrolchunk);
retvalue binaries_retrack(const char *packagename, const char *chunk, trackingdb tracks, struct database *);
retvalue binaries_getsourceandversion(struct target *,const char *chunk,const char *packagename,char **source,char **version);
retvalue binaries_getsourceandversion(const char *chunk, const char *packagename, char **source, char **version);
/* Functions for checkindeb.c and incoming.c: */
......
......@@ -592,7 +592,7 @@ static retvalue package_source_fits(UNUSED(struct database *da), UNUSED(struct d
char *sourcename, *sourceversion;
retvalue r;
r = target->getsourceandversion(target, control, packagename,
r = target->getsourceandversion(control, packagename,
&sourcename, &sourceversion);
if( !RET_IS_OK(r) )
return r;
......@@ -767,7 +767,7 @@ static retvalue list_in_target(void *data, struct target *target,
result = table_getrecord(target->packages, packagename, &control);
if( RET_IS_OK(result) ) {
r = (*target->getversion)(target, control, &version);
r = target->getversion(control, &version);
if( RET_IS_OK(r) ) {
printf("%s: %s %s\n",target->identifier,packagename,version);
free(version);
......@@ -805,7 +805,7 @@ static retvalue listfilterprint(UNUSED(struct database *da), UNUSED(struct distr
r = term_decidechunk(condition, control);
if( RET_IS_OK(r) ) {
r = (*target->getversion)(target, control, &version);
r = target->getversion(control, &version);
if( RET_IS_OK(r) ) {
printf("%s: %s %s\n", target->identifier,
packagename, version);
......@@ -1225,7 +1225,7 @@ static retvalue copy(/*@temp@*/void *data, struct target *origtarget,
return result;
}
result = origtarget->getversion(origtarget, chunk, &version);
result = origtarget->getversion(chunk, &version);
assert( result != RET_NOTHING );
if( RET_WAS_ERROR(result) ) {
free(chunk);
......
......@@ -114,7 +114,7 @@ static retvalue getBasenames(const struct strlist *filelines,/*@out@*/struct str
return r;
}
retvalue sources_getname(UNUSED(struct target *t),const char *control,char **packagename){
retvalue sources_getname(const char *control, char **packagename){
retvalue r;
r = chunk_getvalue(control,"Package",packagename);
......@@ -126,7 +126,7 @@ retvalue sources_getname(UNUSED(struct target *t),const char *control,char **pac
}
return r;
}
retvalue sources_getversion(UNUSED(struct target *t),const char *control,char **version) {
retvalue sources_getversion(const char *control, char **version) {
retvalue r;
r = chunk_getvalue(control,"Version",version);
......@@ -139,7 +139,7 @@ retvalue sources_getversion(UNUSED(struct target *t),const char *control,char **
return r;
}
retvalue sources_getinstalldata(struct target *t, const char *packagename, UNUSED(const char *version), const char *chunk, char **control, struct strlist *filekeys, struct checksumsarray *origfiles) {
retvalue sources_getinstalldata(const struct target *t, const char *packagename, UNUSED(const char *version), const char *chunk, char **control, struct strlist *filekeys, struct checksumsarray *origfiles, /*@null@*//*@out@*/enum filetype *type_p) {
retvalue r;
char *origdirectory, *directory, *mychunk;
struct strlist myfilekeys;
......@@ -221,6 +221,8 @@ retvalue sources_getinstalldata(struct target *t, const char *packagename, UNUSE
*control = mychunk;
strlist_move(filekeys, &myfilekeys);
checksumsarray_move(origfiles, &files);
if( type_p != NULL )
*type_p = ft_SOURCE;
return RET_OK;
}
......@@ -317,8 +319,7 @@ retvalue sources_getchecksums(const char *chunk, struct checksumsarray *out) {
return RET_OK;
}
char *sources_getupstreamindex(UNUSED(struct target *target),const char *suite_from,
const char *component_from,UNUSED(const char *architecture)) {
char *sources_getupstreamindex(const char *suite_from, const char *component_from, UNUSED(const char *architecture)) {
return mprintf("dists/%s/%s/source/Sources.gz",suite_from,component_from);
}
......@@ -402,7 +403,7 @@ retvalue sources_retrack(const char *sourcename, const char *chunk, trackingdb t
return tracking_save(tracks, pkg);
}
retvalue sources_getsourceandversion(UNUSED(struct target *t),const char *chunk,const char *packagename,char **source,char **version) {
retvalue sources_getsourceandversion(const char *chunk, const char *packagename, char **source, char **version) {
retvalue r;
char *sourceversion;
char *sourcename;
......
......@@ -13,16 +13,15 @@
retvalue sources_calcfilelines(const struct checksumsarray *, /*@out@*/char **item);
/* Functions for the target.h-stuff: */
retvalue sources_getname(struct target * t,const char *chunk,/*@out@*/char **packagename);
retvalue sources_getversion(struct target *t,const char *chunk,/*@out@*/char **version);
retvalue sources_getinstalldata(struct target *t, const char *packagename, const char *version, const char *chunk, char **control, /*@out@*/struct strlist *filekeys, /*@out@*/struct checksumsarray *origfiles);
retvalue sources_getname(const char *chunk, /*@out@*/char **packagename);
retvalue sources_getversion(const char *chunk, /*@out@*/char **version);
retvalue sources_getinstalldata(const struct target *t, const char *packagename, const char *version, const char *chunk, char **control, /*@out@*/struct strlist *filekeys, /*@out@*/struct checksumsarray *origfiles, /*@null@*//*@out@*/enum filetype *);
retvalue sources_getfilekeys(const char *, /*@out@*/struct strlist *);
retvalue sources_getchecksums(const char *, /*@out@*/struct checksumsarray *);
char *sources_getupstreamindex(struct target *target,const char *suite_from,
const char *component_from,const char *architecture);
char *sources_getupstreamindex(const char *suite_from, const char *component_from, const char *architecture);
retvalue sources_doreoverride(const struct distribution *,const char *packagename,const char *controlchunk,/*@out@*/char **newcontrolchunk);
retvalue sources_retrack(const char *packagename, const char *chunk, trackingdb tracks, struct database *);
retvalue sources_getsourceandversion(struct target *,const char *chunk,const char *packagename,char **source,char **version);
retvalue sources_getsourceandversion(const char *chunk, const char *packagename, char **source, char **version);
/* Functions for checkindsc.c and incoming.c: */
struct dsc_headers {
......
......@@ -180,8 +180,7 @@ retvalue target_removereadpackage(struct target *target, struct logger *logger,
if( logger != NULL && oldpversion == NULL ) {
/* need to get the version for logging, if not available */
r = target->getversion(target, oldcontrol,
&oldpversion_ifunknown);
r = target->getversion(oldcontrol, &oldpversion_ifunknown);
if( RET_IS_OK(r) )
oldpversion = oldpversion_ifunknown;
}
......@@ -191,7 +190,7 @@ retvalue target_removereadpackage(struct target *target, struct logger *logger,
return r;
}
if( trackingdata != NULL ) {
r = target->getsourceandversion(target, oldcontrol,
r = target->getsourceandversion(oldcontrol,
name, &oldsource, &oldsversion);
if( !RET_IS_OK(r) ) {
oldsource = oldsversion = NULL;
......@@ -262,8 +261,7 @@ retvalue target_removepackage_by_cursor(struct target *target, struct logger *lo
if( logger != NULL && oldpversion == NULL ) {
/* need to get the version for logging, if not available */
r = target->getversion(target, control,
&oldpversion_ifunknown);
r = target->getversion(control, &oldpversion_ifunknown);
if( RET_IS_OK(r) )
oldpversion = oldpversion_ifunknown;
}
......@@ -273,7 +271,7 @@ retvalue target_removepackage_by_cursor(struct target *target, struct logger *lo
return r;
}
if( trackingdata != NULL ) {
r = target->getsourceandversion(target, control,
r = target->getsourceandversion(control,
name, &oldsource, &oldsversion);
if( !RET_IS_OK(r) ) {
oldsource = oldsversion = NULL;
......@@ -387,7 +385,7 @@ retvalue target_addpackage(struct target *target, struct logger *logger, struct
oldcontrol = NULL;
} else {
r = target->getversion(target,oldcontrol,&oldpversion);
r = target->getversion(oldcontrol, &oldpversion);
if( RET_WAS_ERROR(r) && !IGNORING_(brokenold,"Error parsing old version!\n") ) {
free(oldcontrol);
return r;
......@@ -429,7 +427,8 @@ retvalue target_addpackage(struct target *target, struct logger *logger, struct
return r;
}
} else if(trackingdata != NULL) {
r = (*target->getsourceandversion)(target,oldcontrol,name,&oldsource,&oldsversion);
r = target->getsourceandversion(oldcontrol,
name, &oldsource, &oldsversion);
if( RET_WAS_ERROR(r) ) {
strlist_done(ofk);
if( IGNORING_(brokenold,"Error searching for source name of installed version of %s!\n",name)) {
......@@ -484,7 +483,7 @@ retvalue target_checkaddpackage(struct target *target, const char *name, const c
} else {
int versioncmp;
r = target->getversion(target,oldcontrol,&oldpversion);
r = target->getversion(oldcontrol, &oldpversion);
if( RET_WAS_ERROR(r) ) {
fprintf(stderr,
"Error extracting version from old '%s' in '%s'. Database corrupted?\n", name, target->identifier);
......@@ -545,8 +544,8 @@ retvalue target_checkaddpackage(struct target *target, const char *name, const c
return r;
}
if( tracking ) {
r = (*target->getsourceandversion)(target,
oldcontrol, name, &oldsource, &oldsversion);
r = target->getsourceandversion(oldcontrol,
name, &oldsource, &oldsversion);
if( RET_WAS_ERROR(r) ) {
fprintf(stderr,
"Error extracting source name and version from '%s' in '%s'. Database corrupted?\n",
......@@ -638,7 +637,7 @@ retvalue package_check(struct database *database, UNUSED(struct distribution *di
char *dummy, *version;
retvalue result,r;
r = target->getversion(target, chunk, &version);
r = target->getversion(chunk, &version);
if( !RET_IS_OK(r) ) {
fprintf(stderr, "Error extraction version number from package control info of '%s'!\n", package);
if( r == RET_NOTHING )
......@@ -646,7 +645,7 @@ retvalue package_check(struct database *database, UNUSED(struct distribution *di
return r;
}
r = target->getinstalldata(target, package, version, chunk, &dummy,
&expectedfilekeys, &files);
&expectedfilekeys, &files, NULL);
if( RET_WAS_ERROR(r) ) {
fprintf(stderr, "Error extracting information of package '%s'!\n",
package);
......@@ -782,7 +781,7 @@ retvalue package_rerunnotifiers(UNUSED(struct database *da), struct distribution
char *version;
retvalue r;
r = target->getversion(target, chunk, &version);
r = target->getversion(chunk, &version);
if( !RET_IS_OK(r) ) {
fprintf(stderr,"Error extraction version number from package control info of '%s'!\n",package);
if( r == RET_NOTHING )
......
......@@ -23,17 +23,16 @@
struct target;
struct alloverrides;
typedef retvalue get_name(struct target *,const char *,/*@out@*/char **);
typedef retvalue get_version(struct target *,const char *,/*@out@*/char **);
typedef retvalue get_installdata(struct target *,const char *,const char *,const char *,/*@out@*/char **,/*@out@*/struct strlist *,/*@out@*/struct checksumsarray *);
typedef retvalue get_name(const char *, /*@out@*/char **);
typedef retvalue get_version(const char *, /*@out@*/char **);
typedef retvalue get_installdata(const struct target *,const char *,const char *,const char *,/*@out@*/char **,/*@out@*/struct strlist *,/*@out@*/struct checksumsarray *,/*@null@*//*@out@*/enum filetype *);
/* md5sums may be NULL */
typedef retvalue get_filekeys(const char *, /*@out@*/struct strlist *);
typedef retvalue get_checksums(const char *, /*@out@*/struct checksumsarray *);
typedef char *get_upstreamindex(struct target *,const char *suite_from,
const char *component_from,const char *architecture);
typedef char *get_upstreamindex(const char *suite_from, const char *component_from, const char *architecture);
typedef retvalue do_reoverride(const struct distribution *,const char *packagename,const char *controlchunk,/*@out@*/char **newcontrolchunk);
typedef retvalue do_retrack(const char *packagename, const char *controlchunk, trackingdb, struct database *);
typedef retvalue get_sourceandversion(struct target *,const char *chunk,const char *packagename,char **source,char **version);
typedef retvalue get_sourceandversion(const char *chunk, const char *packagename, /*@out@*/char **source, /*@out@*/char **version);
struct target {
char *codename;
......
......@@ -1170,7 +1170,7 @@ static retvalue targetremovesourcepackage(trackingdb t, struct trackedpackage *p
free(package);
continue;
}
r = target->getsourceandversion(target, control, package,
r = target->getsourceandversion(control, package,
&source, &version);
assert( r != RET_NOTHING );
if( RET_WAS_ERROR(r) ) {
......
......@@ -612,9 +612,9 @@ static inline retvalue newindex(struct update_index **indices,
return RET_ERROR_OOM;
}
index->original_filename = NULL;
index->upstream = (*target->getupstreamindex)(target,
origin->suite_from,component_from,architecture_from);
if( index->upstream == NULL ) {
index->upstream = target->getupstreamindex(origin->suite_from,
component_from, architecture_from);
if( FAILEDTOALLOC(index->upstream) ) {
free(index->filename);
free(index);
return RET_ERROR_OOM;
......
......@@ -61,6 +61,7 @@ struct package_data {
* same validity */
struct strlist new_filekeys;
struct checksumsarray new_origfiles;
enum filetype new_filetype;
};
struct upgradelist {
......@@ -96,7 +97,7 @@ static retvalue save_package_version(struct upgradelist *upgrade, const char *pa
retvalue r;
struct package_data *package;
r = (*upgrade->target->getversion)(upgrade->target,chunk,&version);
r = upgrade->target->getversion(chunk, &version);
if( RET_WAS_ERROR(r) )
return r;
......@@ -213,10 +214,10 @@ static retvalue upgradelist_trypackage(void *data,const char *chunk){
upgrade_decision decision;
struct package_data *current,*insertafter;
r = (*upgrade->target->getname)(upgrade->target,chunk,&packagename);
r = upgrade->target->getname(chunk, &packagename);
if( RET_WAS_ERROR(r) )
return r;
r = (*upgrade->target->getversion)(upgrade->target,chunk,&version);
r = upgrade->target->getversion(chunk, &version);
if( RET_WAS_ERROR(r) ) {
free(packagename);
return r;
......@@ -314,7 +315,10 @@ static retvalue upgradelist_trypackage(void *data,const char *chunk){
new->new_version = version;
new->version = version;
version = NULL; //to be sure...
r = upgrade->target->getinstalldata(upgrade->target, new->name, new->new_version, chunk, &new->new_control, &new->new_filekeys, &new->new_origfiles);
r = upgrade->target->getinstalldata(upgrade->target,
new->name, new->new_version, chunk,
&new->new_control, &new->new_filekeys,
&new->new_origfiles, &new->new_filetype);
if( RET_WAS_ERROR(r) ) {
package_data_free(new);
return RET_ERROR_OOM;
......@@ -332,6 +336,7 @@ static retvalue upgradelist_trypackage(void *data,const char *chunk){
char *control;
struct strlist files;
struct checksumsarray origfiles;
enum filetype filetype;
int versioncmp;
upgrade->last = current;
......@@ -421,7 +426,7 @@ static retvalue upgradelist_trypackage(void *data,const char *chunk){
// if( versioncmp >= 0 && current->version == current->version_in_use
// && current->new_version != NULL ) {
r = upgrade->target->getinstalldata(upgrade->target, packagename, version, chunk, &control, &files, &origfiles);
r = upgrade->target->getinstalldata(upgrade->target, packagename, version, chunk, &control, &files, &origfiles, &filetype);
free(packagename);
if( RET_WAS_ERROR(r) ) {
free(version);
......@@ -436,6 +441,7 @@ static retvalue upgradelist_trypackage(void *data,const char *chunk){
strlist_move(&current->new_filekeys,&files);
checksumsarray_move(&current->new_origfiles, &origfiles);
free(current->new_control);
current->new_filetype = filetype;
current->new_control = control;
}
return RET_OK;
......@@ -594,7 +600,8 @@ retvalue upgradelist_install(struct upgradelist *upgrade, struct logger *logger,
pkg->new_version,
pkg->new_control,
&pkg->new_filekeys, NULL, true,
dereferencedfilekeys, NULL, 0);
dereferencedfilekeys, NULL,
pkg->new_filetype);
}
RET_UPDATE(result,r);
if( RET_WAS_ERROR(r) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment