Commit 094f8fef authored by Bernhard Link's avatar Bernhard Link

added ability to print missing files in the new upgrade code

parent eafea02d
......@@ -410,7 +410,7 @@ retvalue binaries_getversion(target t,const char *control,char **version) {
return r;
}
retvalue binaries_getinstalldata(target t,const char *packagename,const char *version,const char *chunk,char **control,struct strlist *filekeys,struct strlist *md5sums) {
retvalue binaries_getinstalldata(target t,const char *packagename,const char *version,const char *chunk,char **control,struct strlist *filekeys,struct strlist *md5sums,struct strlist *origfiles) {
char *sourcename,*basename;
retvalue r;
......@@ -422,6 +422,12 @@ retvalue binaries_getinstalldata(target t,const char *packagename,const char *ve
fprintf(stderr,"Does not look like a binary package: '%s'!\n",chunk);
return RET_ERROR;
}
r = binaries_parse_getfiles(chunk,origfiles);
if( RET_WAS_ERROR(r) ) {
free(sourcename);free(basename);
strlist_done(md5sums);
return r;
}
r = calcnewcontrol(chunk,sourcename,basename,t->component,filekeys,control);
if( RET_WAS_ERROR(r) ) {
......
......@@ -54,6 +54,6 @@ retvalue binaries_addtodist(const char *dbpath,DB *references,const char *codena
/* Functions for the target.h-stuff: */
retvalue binaries_getname(target t,const char *chunk,char **packagename);
retvalue binaries_getversion(target t,const char *chunk,char **version);
retvalue binaries_getinstalldata(target t,const char *packagename,const char *version,const char *chunk,char **control,struct strlist *files,struct strlist *md5sums);
retvalue binaries_getinstalldata(target t,const char *packagename,const char *version,const char *chunk,char **control,struct strlist *filekeys,struct strlist *md5sums,struct strlist *origfiles);
#endif
......@@ -894,6 +894,7 @@ static int upgrade(int argc,char *argv[]) {
retvalue result,r;
upgradelist upgrade;
packagesdb pkgs;
filesdb files;
target target;
if( argc <=1 ) {
......@@ -926,6 +927,13 @@ static int upgrade(int argc,char *argv[]) {
result = upgradelist_update(upgrade,argv[1],force);
upgradelist_dump(upgrade);
r = files_initialize(&files,dbdir,mirrordir);
if( RET_IS_OK(r) ) {
upgradelist_listmissing(upgrade,files);
files_done(files);
}
r = upgradelist_done(upgrade);
RET_ENDUPDATE(result,r);
r = packages_done(pkgs);
......
......@@ -341,11 +341,11 @@ retvalue sources_lookforolder(
return RET_OK;
}
static retvalue calcnewcontrol(
static inline retvalue calcnewcontrol(
const char *chunk, const char *package,
const struct strlist *basenames,
const char *component,
struct strlist *filekeys,char **newchunk) {
const char *component,const char *origdirectory,
struct strlist *filekeys,char **newchunk,struct strlist *origfiles) {
char *directory;
retvalue r;
......@@ -364,6 +364,12 @@ static retvalue calcnewcontrol(
strlist_done(filekeys);
return RET_ERROR_OOM;
}
r = calc_dirconcats(origdirectory,basenames,origfiles);
if( RET_WAS_ERROR(r) ) {
strlist_done(filekeys);
free(*newchunk);
return r;
}
return RET_OK;
}
......@@ -376,16 +382,10 @@ static inline retvalue callaction(new_package_action *action, void *data,
struct strlist origfiles,filekeys;
retvalue r;
r = calcnewcontrol(chunk,package,basenames,component,&filekeys,&newchunk);
r = calcnewcontrol(chunk,package,basenames,component,origdirectory,&filekeys,&newchunk,&origfiles);
if( RET_WAS_ERROR(r) )
return r;
r = calc_dirconcats(origdirectory,basenames,&origfiles);
if( RET_WAS_ERROR(r) ) {
strlist_done(&filekeys);
free(newchunk);
return r;
}
// Calculating origfiles and newchunk will both not be needed in half of the
// cases. This could be avoided by pushing flags to sources_findnew which
......@@ -566,8 +566,9 @@ retvalue sources_getversion(target t,const char *control,char **version) {
return r;
}
retvalue sources_getinstalldata(target t,const char *packagename,const char *version,const char *chunk,char **control,struct strlist *filekeys,struct strlist *md5sums) {
retvalue sources_getinstalldata(target t,const char *packagename,const char *version,const char *chunk,char **control,struct strlist *filekeys,struct strlist *md5sums,struct strlist *origfiles) {
retvalue r;
char *origdirectory;
struct strlist filelines,basenames;
r = chunk_getextralinelist(chunk,"Files",&filelines);
......@@ -577,12 +578,22 @@ retvalue sources_getinstalldata(target t,const char *packagename,const char *ver
}
if( RET_WAS_ERROR(r) )
return r;
r = chunk_getvalue(chunk,"Directory",&origdirectory);
if( r == RET_NOTHING ) {
fprintf(stderr,"Missing 'Directory' entry in '%s'!\n",chunk);
r = RET_ERROR;
}
if( RET_WAS_ERROR(r) )
return r;
r = getBasenamesAndMd5(&filelines,&basenames,md5sums);
strlist_done(&filelines);
if( RET_WAS_ERROR(r) )
if( RET_WAS_ERROR(r) ) {
free(origdirectory);
return r;
}
r = calcnewcontrol(chunk,packagename,&basenames,t->component,
filekeys,control);
origdirectory,filekeys,control,origfiles);
free(origdirectory);
strlist_done(&basenames);
if( RET_WAS_ERROR(r) ) {
strlist_done(md5sums);
......
......@@ -43,6 +43,6 @@ retvalue sources_calcfilelines(const struct strlist *basenames,const struct strl
/* Functions for the target.h-stuff: */
retvalue sources_getname(target t,const char *chunk,char **packagename);
retvalue sources_getversion(target ,const char *chunk,char **version);
retvalue sources_getinstalldata(target t,const char *packagename,const char *version,const char *chunk,char **control,struct strlist *files,struct strlist *md5sums);
retvalue sources_getinstalldata(target t,const char *packagename,const char *version,const char *chunk,char **control,struct strlist *filekeys,struct strlist *md5sums,struct strlist *origfiles);
#endif
......@@ -9,7 +9,7 @@ typedef struct s_target *target;
typedef retvalue get_name(target,const char *,char **);
typedef retvalue get_version(target,const char *,char **);
typedef retvalue get_installdata(target,const char *,const char *,const char *,char **,struct strlist *,struct strlist *);
typedef retvalue get_installdata(target,const char *,const char *,const char *,char **,struct strlist *,struct strlist *,struct strlist *);
struct s_target {
char *codename;
......
......@@ -51,8 +51,9 @@ typedef struct s_package_data {
char *new_control;
/* the list of files that will belong to this:
* same validity */
struct strlist new_files;
struct strlist new_filekeys;
struct strlist new_md5sums;
struct strlist new_origfiles;
} package_data;
struct s_upgradelist {
......@@ -72,8 +73,9 @@ static void package_data_free(package_data *data){
free(data->new_version);
//free(data->new_from);
free(data->new_control);
strlist_done(&data->new_files);
strlist_done(&data->new_filekeys);
strlist_done(&data->new_md5sums);
strlist_done(&data->new_origfiles);
free(data);
}
......@@ -253,7 +255,7 @@ retvalue upgradelist_trypackage(upgradelist upgrade,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_files,&new->new_md5sums);
r = upgrade->target->getinstalldata(upgrade->target,new->name,new->new_version,chunk,&new->new_control,&new->new_filekeys,&new->new_md5sums,&new->new_origfiles);
if( RET_WAS_ERROR(r) ) {
package_data_free(new);
return RET_ERROR_OOM;
......@@ -269,7 +271,7 @@ retvalue upgradelist_trypackage(upgradelist upgrade,const char *chunk){
} else {
/* The package already exists: */
package_data *current = upgrade->current;
char *control;struct strlist files,md5sums;
char *control;struct strlist files,md5sums,origfiles;
r = dpkgversions_isNewer(version,current->version);
......@@ -306,7 +308,7 @@ retvalue upgradelist_trypackage(upgradelist upgrade,const char *chunk){
return RET_NOTHING;
}
r = upgrade->target->getinstalldata(upgrade->target,packagename,version,chunk,&control,&files,&md5sums);
r = upgrade->target->getinstalldata(upgrade->target,packagename,version,chunk,&control,&files,&md5sums,&origfiles);
free(packagename);
if( RET_WAS_ERROR(r) ) {
free(version);
......@@ -315,8 +317,9 @@ retvalue upgradelist_trypackage(upgradelist upgrade,const char *chunk){
free(current->new_version);
current->new_version = version;
current->version = version;
strlist_move(&current->new_files,&files);
strlist_move(&current->new_filekeys,&files);
strlist_move(&current->new_md5sums,&md5sums);
strlist_move(&current->new_origfiles,&origfiles);
free(current->new_control);
current->new_control = control;
}
......@@ -331,6 +334,21 @@ retvalue upgradelist_update(upgradelist upgrade,const char *filename,int force){
return chunk_foreach(filename,(void*)upgradelist_trypackage,upgrade,force,0);
}
retvalue upgradelist_listmissing(upgradelist upgrade,filesdb files){
package_data *pkg;
pkg = upgrade->list;
while( pkg ) {
if( pkg->version == pkg->new_version ) {
files_printmissing(files,&pkg->new_filekeys,&pkg->new_md5sums,&pkg->new_origfiles);
}
pkg = pkg->next;
}
return RET_OK;
}
retvalue upgradelist_dump(upgradelist upgrade){
package_data *pkg;
......@@ -348,7 +366,7 @@ retvalue upgradelist_dump(upgradelist upgrade){
"files needed: ",
pkg->name,pkg->version_in_use,
pkg->new_version);
strlist_fprint(stdout,&pkg->new_files);
strlist_fprint(stdout,&pkg->new_filekeys);
printf("\nwith md5sums: ");
strlist_fprint(stdout,&pkg->new_md5sums);
printf("\ninstalling as: '%s'\n",pkg->new_control);
......
......@@ -24,6 +24,7 @@ retvalue upgradelist_initialize(upgradelist *ul,target target, packagesdb packag
retvalue upgradelist_done(upgradelist upgrade);
retvalue upgradelist_dump(upgradelist upgrade);
retvalue upgradelist_listmissing(upgradelist upgrade,filesdb files);
retvalue upgradelist_update(upgradelist upgrade,const char *filename,int force);
......
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