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>2011-06-16 13:15:11 -0500
committerDan McGee <dan@archlinux.org>2011-06-22 12:31:12 -0500
commit54ef162a1a9e27e362732d873f0739bc0a2cf1bf (patch)
treee4ec6ba0ab94965c754a40d52a680f9fd69c4e37 /lib/libalpm/remove.c
parent886a31ef205923fd5b29012ee75932a2e2dec4bd (diff)
Convert backup list to new pmbackup_t type
This allows us to separate the name and hash elements in one place and not scatter different parsing code all over the place, including both the frontend and backend. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/remove.c')
-rw-r--r--lib/libalpm/remove.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 9f075016..b6a4c715 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -254,16 +254,14 @@ static void unlink_file(pmhandle_t *handle, pmpkg_t *info, const char *filename,
}
} else {
/* if the file needs backup and has been modified, back it up to .pacsave */
- char *pkghash = _alpm_needbackup(filename, alpm_pkg_get_backup(info));
- if(pkghash) {
+ pmbackup_t *backup = _alpm_needbackup(filename, alpm_pkg_get_backup(info));
+ if(backup) {
if(nosave) {
_alpm_log(handle, PM_LOG_DEBUG, "transaction is set to NOSAVE, not backing up '%s'\n", file);
- FREE(pkghash);
} else {
char *filehash = alpm_compute_md5sum(file);
- int cmp = filehash ? strcmp(filehash, pkghash) : 0;
+ int cmp = filehash ? strcmp(filehash, backup->hash) : 0;
FREE(filehash);
- FREE(pkghash);
if(cmp != 0) {
char newpath[PATH_MAX];
snprintf(newpath, PATH_MAX, "%s.pacsave", file);
@@ -309,20 +307,20 @@ int _alpm_upgraderemove_package(pmhandle_t *handle,
/* old package backup list */
alpm_list_t *filelist = alpm_pkg_get_files(newpkg);
for(b = alpm_pkg_get_backup(newpkg); b; b = b->next) {
- char *backup = _alpm_backup_file(b->data);
+ const pmbackup_t *backup = b->data;
/* safety check (fix the upgrade026 pactest) */
- if(!alpm_list_find_str(filelist, backup)) {
- FREE(backup);
+ if(!alpm_list_find_str(filelist, backup->name)) {
continue;
}
- _alpm_log(handle, PM_LOG_DEBUG, "adding %s to the skip_remove array\n", backup);
- skip_remove = alpm_list_add(skip_remove, backup);
+ _alpm_log(handle, PM_LOG_DEBUG, "adding %s to the skip_remove array\n",
+ backup->name);
+ skip_remove = alpm_list_add(skip_remove, strdup(backup->name));
}
for(lp = files; lp; lp = lp->next) {
if(!can_remove_file(handle, lp->data, skip_remove)) {
- _alpm_log(handle, PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n",
- pkgname);
+ _alpm_log(handle, PM_LOG_DEBUG,
+ "not removing package '%s', can't remove all files\n", pkgname);
RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1);
}
}