Commit 6134e19d authored by Bernhard Link's avatar Bernhard Link

Make remove a bit saner

parent e590cf8f
2004-12-18 Bernhard R. Link <brlink@debian.org>
* remove now tells which packages were removed (with -v)
and which could not be deleted. Indicies will only
be exported when something was deleted.
2004-12-18 Bernhard R. Link <brlink@debian.org>
* Modify remove to allow -T to specify the
......
......@@ -292,7 +292,7 @@ static int action_addreference(int argc,const char *argv[]) {
}
struct remove_args {DB *references; int count; const char **names; };
struct remove_args {DB *references; int count; const char **names; int *gotremoved; int todo;};
static retvalue remove_from_target(void *data, struct target *target) {
retvalue result,r;
......@@ -307,8 +307,11 @@ static retvalue remove_from_target(void *data, struct target *target) {
result = RET_NOTHING;
for( i = 0 ; i < d->count ; i++ ){
r = target_removepackage(target,d->references,d->names[i]);
if( r == RET_ERROR_MISSING )
r = RET_NOTHING;
if( RET_IS_OK(r) ) {
if( d->gotremoved[i] == 0 )
d->todo--;
d->gotremoved[i] = 1;
}
RET_UPDATE(result,r);
}
r = target_closepackagesdb(target);
......@@ -340,15 +343,34 @@ static int action_remove(int argc,const char *argv[]) {
d.count = argc-2;
d.names = argv+2;
result = distribution_foreach_part(distribution,component,architecture,suffix,remove_from_target,&d,force);
r = distribution_export(distribution,dbdir,distdir,force,1);
RET_ENDUPDATE(result,r);
d.todo = d.count;
d.gotremoved = calloc(d.count,sizeof(int));
if( d.gotremoved == NULL )
result = RET_ERROR_OOM;
else
result = distribution_foreach_part(distribution,component,architecture,suffix,remove_from_target,&d,force);
if( d.todo < d.count ) {
r = distribution_export(distribution,dbdir,distdir,force,1);
RET_ENDUPDATE(result,r);
}
r = distribution_free(distribution);
RET_ENDUPDATE(result,r);
r = references_done(d.references);
RET_ENDUPDATE(result,r);
if( verbose >= 0 && !RET_WAS_ERROR(result) && d.todo > 0 ) {
fputs("Not removed as not found: ",stderr);
while( d.count > 0 ) {
d.count--;
if( d.gotremoved[d.count] == 0 ) {
fputs(d.names[d.count],stderr);
d.todo--;
if( d.todo > 0 )
fputs(", ",stderr);
}
}
fputc('\n',stderr);
}
return EXIT_RET(result);
}
......
/* This file is part of "reprepro"
* Copyright (C) 2003 Bernhard R. Link
* Copyright (C) 2003,2004 Bernhard R. Link
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
......@@ -164,7 +164,7 @@ retvalue references_decrement(DB* refdb,const char *needed,const char *neededby)
int dbret;
retvalue r;
r = RET_NOTHING;
r = RET_OK;
cursor = NULL;
if( (dbret = refdb->cursor(refdb,NULL,&cursor,0)) != 0 ) {
refdb->err(refdb, dbret, "references_decrement dberror:");
......
......@@ -163,10 +163,10 @@ retvalue target_removepackage(struct target *target,DB *references,const char *n
if( RET_WAS_ERROR(r) )
return r;
else if( r == RET_NOTHING ) {
if( verbose >= 0 )
if( verbose >= 10 )
fprintf(stderr,"Could not find '%s' in '%s'...\n",
name,target->identifier);
return RET_ERROR_MISSING;
return RET_NOTHING;
}
r = target->getfilekeys(target,oldchunk,&files,NULL);
free(oldchunk);
......
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