Commit f9a13a13 authored by Bernhard Link's avatar Bernhard Link

readded the preliminary remove function

parent e32098a0
...@@ -13,6 +13,10 @@ ...@@ -13,6 +13,10 @@
/* get files out of a "Packages.gz"-chunk. */ /* get files out of a "Packages.gz"-chunk. */
retvalue binaries_parse_getfiles(const char *chunk,struct strlist *files); retvalue binaries_parse_getfiles(const char *chunk,struct strlist *files);
/* Look for an old version of the Package in the database,
* returns RET_NOTHING, if there is none */
retvalue binaries_lookforold(DB *pkgs,const char *name,struct strlist *files);
/* Look for an older version of the Package in the database. /* Look for an older version of the Package in the database.
* return RET_NOTHING if there is none, otherwise * return RET_NOTHING if there is none, otherwise
* Set *oldversion, if there is already a newer (or equal) version to * Set *oldversion, if there is already a newer (or equal) version to
......
...@@ -296,16 +296,60 @@ static int zexportpackages(int argc,char *argv[]) { ...@@ -296,16 +296,60 @@ static int zexportpackages(int argc,char *argv[]) {
result = packages_dozprintout(dbdir,argv[1],argv[2]); result = packages_dozprintout(dbdir,argv[1],argv[2]);
return EXIT_RET(result); return EXIT_RET(result);
} }
/*
// TODO: needs to be rewritten... static int removesource(int argc,char *argv[]) {
static int removepackage(int argc,char *argv[]) { retvalue result,r;
DB *pkgs,*refs;
int i;
struct strlist files;
if( argc < 3 ) {
fprintf(stderr,"mirrorer _removesource <identifier> <package-name>\n");
return 1;
}
refs = references_initialize(dbdir);
if( ! refs )
return 1;
pkgs = packages_initialize(dbdir,argv[1]);
if( ! pkgs ) {
(void)references_done(refs);
return 1;
}
result = RET_NOTHING;
for( i = 2 ; i< argc ; i++ ) {
r = sources_lookforold(pkgs,argv[i],&files);
if( RET_IS_OK(r) ) {
if( verbose > 0 )
fprintf(stderr,"removing '%s' from '%s'...\n",argv[i],argv[1]);
r = packages_remove(pkgs,argv[i]);
if( RET_IS_OK(r) ) {
r = references_delete(refs,argv[1],&files,NULL);
}
strlist_done(&files);
} else if( r == RET_NOTHING ) {
if( verbose >= 0 )
fprintf(stderr,"Could not find '%s' in '%s'...\n",argv[i],argv[1]);
}
RET_UPDATE(result,r);
}
r = packages_done(pkgs);
RET_ENDUPDATE(result,r);
r = references_done(refs);
RET_ENDUPDATE(result,r);
return EXIT_RET(result);
}
static int removebinary(int argc,char *argv[]) {
retvalue result,r; retvalue result,r;
DB *pkgs,*refs; DB *pkgs,*refs;
int i; int i;
char *filekey,*chunk; struct strlist files;
if( argc < 3 ) { if( argc < 3 ) {
fprintf(stderr,"mirrorer _removepackage <identifier> <package-name>\n"); fprintf(stderr,"mirrorer _removebinary <identifier> <package-name>\n");
return 1; return 1;
} }
refs = references_initialize(dbdir); refs = references_initialize(dbdir);
...@@ -317,28 +361,22 @@ static int removepackage(int argc,char *argv[]) { ...@@ -317,28 +361,22 @@ static int removepackage(int argc,char *argv[]) {
return 1; return 1;
} }
// TODO: split this in binary/source and use binaries_lookforold
result = RET_NOTHING; result = RET_NOTHING;
for( i = 2 ; i< argc ; i++ ) { for( i = 2 ; i< argc ; i++ ) {
chunk = packages_get(pkgs,argv[i]); r = binaries_lookforold(pkgs,argv[i],&files);
if( verbose > 0 )
fprintf(stderr,"removing '%s' from '%s'...\n",argv[i],argv[1]);
r = packages_remove(pkgs,argv[i]);
if( RET_IS_OK(r) ) { if( RET_IS_OK(r) ) {
r = binaries_parse_chunk(chunk,NULL,&filekey,NULL,NULL,NULL,NULL); if( verbose > 0 )
fprintf(stderr,"removing '%s' from '%s'...\n",argv[i],argv[1]);
r = packages_remove(pkgs,argv[i]);
if( RET_IS_OK(r) ) { if( RET_IS_OK(r) ) {
if( verbose > 1 ) r = references_delete(refs,argv[1],&files,NULL);
fprintf(stderr,"unreferencing '%s' to '%s' \n",argv[1],filekey);
r = references_decrement(refs,filekey,argv[1]);
free(filekey);
} else if( r == RET_NOTHING ) {
if( verbose > 1 )
fprintf(stderr,"unreferencing needed srcfiles in '%s' about '%s' \n",argv[1],argv[i]);
r = sources_dereference(refs,argv[1],chunk);
} }
strlist_done(&files);
} else if( r == RET_NOTHING ) {
if( verbose >= 0 )
fprintf(stderr,"Could not find '%s' in '%s'...\n",argv[i],argv[1]);
} }
if( chunk )
free(chunk);
RET_UPDATE(result,r); RET_UPDATE(result,r);
} }
...@@ -348,7 +386,7 @@ static int removepackage(int argc,char *argv[]) { ...@@ -348,7 +386,7 @@ static int removepackage(int argc,char *argv[]) {
RET_ENDUPDATE(result,r); RET_ENDUPDATE(result,r);
return EXIT_RET(result); return EXIT_RET(result);
} }
*/
/****** reference_{binary,source} *****/ /****** reference_{binary,source} *****/
struct referee { struct referee {
DB *refs; DB *refs;
...@@ -1264,7 +1302,8 @@ static struct action { ...@@ -1264,7 +1302,8 @@ static struct action {
{"addpackages", addpackages}, {"addpackages", addpackages},
{"_genpackages", exportpackages}, {"_genpackages", exportpackages},
{"_genzpackages", zexportpackages}, {"_genzpackages", zexportpackages},
/* {"_removepackage", removepackage},*/ {"_removesource", removesource},
{"_removebinary", removebinary},
{"export", export}, {"export", export},
{"check", check}, {"check", check},
{"rereference", rereference}, {"rereference", rereference},
......
...@@ -18,8 +18,15 @@ retvalue sources_getfile(const char *fileline, ...@@ -18,8 +18,15 @@ retvalue sources_getfile(const char *fileline,
retvalue sources_parse_getfiles(const char *chunk, struct strlist *files); retvalue sources_parse_getfiles(const char *chunk, struct strlist *files);
/* call <action> for each package in the "Sources.gz"-style file <source_file> missing in /* Look for an old version of the Package in the database.
* <pkgs> and using <component> as subdir of pool (i.e. "main","contrib",...) for generated paths */ * return RET_NOTHING, if there is none at all. */
retvalue sources_lookforold(DB *packages,const char *packagename,
struct strlist *oldfiles);
/* call <action> for each package in the "Sources.gz"-style file <source_file>
* missing in <pkgs> and using <component> as subdir of pool
* (i.e. "main","contrib",...) for generated paths */
retvalue sources_findnew(DB *pkgs,const char *component,const char *sources_file,new_package_action action,void *data,int force); retvalue sources_findnew(DB *pkgs,const char *component,const char *sources_file,new_package_action action,void *data,int force);
#endif #endif
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