Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/remove.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-02-20 02:14:27 +0000
committerDan McGee <dan@archlinux.org>2007-02-20 02:14:27 +0000
commit03f034ef0eacaca3611193007c24d6c2af94bdb8 (patch)
treed0b13f3e0c3cca0a07cd908e8d332697df03dff9 /lib/libalpm/remove.c
parent3f802fb38ed11a73f343191c0b3178d37d5e8a4d (diff)
* Updated conflict checking one last time. You can finally have a file move
from one package to another seemlessly (knock on wood). This is implemented through the use of two skip lists in the trans struct- skip_add and skip_remove, which replace the former trans->skiplist. * Removed an unnecessary function parameter, added a necessary one. * If a package has no backup files, print '(none)' under the heading so it is more obvious. * Updated my TODO list.
Diffstat (limited to 'lib/libalpm/remove.c')
-rw-r--r--lib/libalpm/remove.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index faa58f9c..4b2350f8 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -155,19 +155,15 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
return(0);
}
-static int can_remove_file(const char *path)
+static int can_remove_file(pmtrans_t *trans, const char *path)
{
- alpm_list_t *i;
char file[PATH_MAX+1];
snprintf(file, PATH_MAX, "%s%s", handle->root, path);
- for(i = handle->trans->skiplist; i; i = i->next) {
- if(strcmp(file, i->data) == 0) {
- /* skipping this file, return success because "removing" this
- * file does nothing */
- return(1);
- }
+ if(alpm_list_find_str(trans->skip_remove, file)) {
+ /* return success because we will never actually remove this file */
+ return(1);
}
/* If we fail write permissions due to a read-only filesystem, abort.
* Assume all other possible failures are covered somewhere else */
@@ -175,7 +171,8 @@ static int can_remove_file(const char *path)
if(access(file, F_OK) == 0) {
/* only return failure if the file ACTUALLY exists and we don't have
* permissions */
- _alpm_log(PM_LOG_ERROR, _("cannot remove file '%s': %s"), file, strerror(errno));
+ _alpm_log(PM_LOG_ERROR, _("cannot remove file '%s': %s"),
+ file, strerror(errno));
return(0);
}
}
@@ -230,19 +227,11 @@ static void unlink_file(pmpkg_t *info, alpm_list_t *lp, alpm_list_t *targ,
_alpm_log(PM_LOG_DEBUG, _("removing directory %s"), file);
}
} else {
- /* check the "skip list" before removing the file.
+ /* check the remove skip list before removing the file.
* see the big comment block in db_find_conflicts() for an
* explanation. */
- int skipit = 0;
- alpm_list_t *j;
- for(j = trans->skiplist; j; j = j->next) {
- if(!strcmp(lp->data, (char*)j->data)) {
- skipit = 1;
- }
- }
- if(skipit) {
- _alpm_log(PM_LOG_WARNING, _("%s has changed ownership, skipping removal"),
- file);
+ if(alpm_list_find_str(trans->skip_remove, file)) {
+ _alpm_log(PM_LOG_DEBUG, _("%s is in trans->skip_remove, skipping removal"), file);
} else if(needbackup) {
/* if the file is flagged, back it up to .pacsave */
if(!(trans->type == PM_TRANS_TYPE_UPGRADE)) {
@@ -301,7 +290,7 @@ int _alpm_remove_commit(pmtrans_t *trans, pmdb_t *db)
if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
for(lp = info->files; lp; lp = lp->next) {
- if(!can_remove_file(lp->data)) {
+ if(!can_remove_file(trans, lp->data)) {
_alpm_log(PM_LOG_DEBUG, _("not removing package '%s', can't remove all files"), info->name);
RET_ERR(PM_ERR_PKG_CANT_REMOVE, -1);
}