index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | lib/libalpm/remove.c | 45 |
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index 153c0426..5fba0b07 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -1,7 +1,7 @@ /* * remove.c * - * Copyright (c) 2006-2010 Pacman Development Team <pacman-dev@archlinux.org> + * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org> * Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org> * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com> * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu> @@ -42,12 +42,11 @@ #include "backup.h" #include "package.h" #include "db.h" -#include "cache.h" #include "deps.h" #include "handle.h" #include "alpm.h" -int SYMEXPORT alpm_remove_target(char *target) +int SYMEXPORT alpm_remove_target(const char *target) { pmpkg_t *info; pmtrans_t *trans; @@ -299,10 +298,12 @@ static void unlink_file(pmpkg_t *info, char *filename, alpm_list_t *skip_remove, } } -int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *trans) +int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, + pmtrans_t *trans) { alpm_list_t *skip_remove, *b; alpm_list_t *newfiles, *lp; + size_t filenum; alpm_list_t *files = alpm_pkg_get_files(oldpkg); const char *pkgname = alpm_pkg_get_name(oldpkg); @@ -311,9 +312,14 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *tra _alpm_log(PM_LOG_DEBUG, "removing old package first (%s-%s)\n", oldpkg->name, oldpkg->version); + if(trans->flags & PM_TRANS_FLAG_DBONLY) { + goto db; + } + /* copy the remove skiplist over */ - skip_remove = - alpm_list_join(alpm_list_strdup(trans->skip_remove),alpm_list_strdup(handle->noupgrade)); + skip_remove = alpm_list_join( + alpm_list_strdup(trans->skip_remove), + alpm_list_strdup(handle->noupgrade)); /* Add files in the NEW backup array to the skip_remove array * so this removal operation doesn't kill them */ /* old package backup list */ @@ -337,6 +343,9 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *tra } } + filenum = alpm_list_count(files); + _alpm_log(PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum); + /* iterate through the list backwards, unlinking files */ newfiles = alpm_list_reverse(files); for(lp = newfiles; lp; lp = alpm_list_next(lp)) { @@ -345,10 +354,11 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *tra alpm_list_free(newfiles); FREELIST(skip_remove); +db: /* remove the package from the database */ _alpm_log(PM_LOG_DEBUG, "updating database\n"); _alpm_log(PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname); - if(_alpm_db_remove(handle->db_local, oldpkg) == -1) { + if(_alpm_local_db_remove(handle->db_local, oldpkg) == -1) { _alpm_log(PM_LOG_ERROR, _("could not remove database entry %s-%s\n"), pkgname, alpm_pkg_get_version(oldpkg)); } @@ -365,7 +375,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) { pmpkg_t *info; alpm_list_t *targ, *lp; - int pkg_count; + size_t pkg_count; ALPM_LOG_FUNC; @@ -379,7 +389,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) char scriptlet[PATH_MAX]; info = (pmpkg_t*)targ->data; const char *pkgname = NULL; - int targcount = alpm_list_count(targ); + size_t targcount = alpm_list_count(targ); if(handle->trans->state == STATE_INTERRUPTED) { return(0); @@ -402,6 +412,9 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) { alpm_list_t *files = alpm_pkg_get_files(info); + alpm_list_t *newfiles; + size_t filenum; + for(lp = files; lp; lp = lp->next) { if(!can_remove_file(lp->data, NULL)) { _alpm_log(PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n", @@ -410,9 +423,8 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) } } - int filenum = alpm_list_count(files); - alpm_list_t *newfiles; - _alpm_log(PM_LOG_DEBUG, "removing %d files\n", filenum); + filenum = alpm_list_count(files); + _alpm_log(PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum); /* init progress bar */ PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, 0, @@ -421,14 +433,13 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) /* iterate through the list backwards, unlinking files */ newfiles = alpm_list_reverse(files); for(lp = newfiles; lp; lp = alpm_list_next(lp)) { - double percent; + int percent; unlink_file(info, lp->data, NULL, trans->flags & PM_TRANS_FLAG_NOSAVE); /* update progress bar after each file */ - percent = (double)position / (double)filenum; + percent = (position * 100) / filenum; PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, - (double)(percent * 100), pkg_count, - (pkg_count - targcount + 1)); + percent, pkg_count, (pkg_count - targcount + 1)); position++; } alpm_list_free(newfiles); @@ -447,7 +458,7 @@ int _alpm_remove_packages(pmtrans_t *trans, pmdb_t *db) /* remove the package from the database */ _alpm_log(PM_LOG_DEBUG, "updating database\n"); _alpm_log(PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname); - if(_alpm_db_remove(db, info) == -1) { + if(_alpm_local_db_remove(db, info) == -1) { _alpm_log(PM_LOG_ERROR, _("could not remove database entry %s-%s\n"), pkgname, alpm_pkg_get_version(info)); } |