summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/remove.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/remove.c')
-rw-r--r--lib/libalpm/remove.c120
1 files changed, 60 insertions, 60 deletions
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index d967780c..59374dcb 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -52,20 +52,20 @@ int SYMEXPORT alpm_remove_pkg(alpm_handle_t *handle, alpm_pkg_t *pkg)
/* Sanity checks */
CHECK_HANDLE(handle, return -1);
- ASSERT(pkg != NULL, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
- ASSERT(handle == pkg->handle, RET_ERR(handle, PM_ERR_WRONG_ARGS, -1));
+ ASSERT(pkg != NULL, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
+ ASSERT(handle == pkg->handle, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
trans = handle->trans;
- ASSERT(trans != NULL, RET_ERR(handle, PM_ERR_TRANS_NULL, -1));
+ ASSERT(trans != NULL, RET_ERR(handle, ALPM_ERR_TRANS_NULL, -1));
ASSERT(trans->state == STATE_INITIALIZED,
- RET_ERR(handle, PM_ERR_TRANS_NOT_INITIALIZED, -1));
+ RET_ERR(handle, ALPM_ERR_TRANS_NOT_INITIALIZED, -1));
pkgname = pkg->name;
if(_alpm_pkg_find(trans->remove, pkgname)) {
- RET_ERR(handle, PM_ERR_TRANS_DUP_TARGET, -1);
+ RET_ERR(handle, ALPM_ERR_TRANS_DUP_TARGET, -1);
}
- _alpm_log(handle, PM_LOG_DEBUG, "adding package %s to the transaction remove list\n",
+ _alpm_log(handle, ALPM_LOG_DEBUG, "adding package %s to the transaction remove list\n",
pkgname);
trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(pkg));
return 0;
@@ -82,12 +82,12 @@ static void remove_prepare_cascade(alpm_handle_t *handle, alpm_list_t *lp)
alpm_pkg_t *info = _alpm_db_get_pkgfromcache(handle->db_local, miss->target);
if(info) {
if(!_alpm_pkg_find(trans->remove, alpm_pkg_get_name(info))) {
- _alpm_log(handle, PM_LOG_DEBUG, "pulling %s in target list\n",
+ _alpm_log(handle, ALPM_LOG_DEBUG, "pulling %s in target list\n",
alpm_pkg_get_name(info));
trans->remove = alpm_list_add(trans->remove, _alpm_pkg_dup(info));
}
} else {
- _alpm_log(handle, PM_LOG_ERROR, _("could not find %s in database -- skipping\n"),
+ _alpm_log(handle, ALPM_LOG_ERROR, _("could not find %s in database -- skipping\n"),
miss->target);
}
}
@@ -116,7 +116,7 @@ static void remove_prepare_keep_needed(alpm_handle_t *handle, alpm_list_t *lp)
&vpkg);
pkg = vpkg;
if(pkg) {
- _alpm_log(handle, PM_LOG_WARNING, _("removing %s from target list\n"),
+ _alpm_log(handle, ALPM_LOG_WARNING, _("removing %s from target list\n"),
alpm_pkg_get_name(pkg));
_alpm_pkg_free(pkg);
}
@@ -141,22 +141,22 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
alpm_trans_t *trans = handle->trans;
alpm_db_t *db = handle->db_local;
- if((trans->flags & PM_TRANS_FLAG_RECURSE) && !(trans->flags & PM_TRANS_FLAG_CASCADE)) {
- _alpm_log(handle, PM_LOG_DEBUG, "finding removable dependencies\n");
+ if((trans->flags & ALPM_TRANS_FLAG_RECURSE) && !(trans->flags & ALPM_TRANS_FLAG_CASCADE)) {
+ _alpm_log(handle, ALPM_LOG_DEBUG, "finding removable dependencies\n");
_alpm_recursedeps(db, trans->remove,
- trans->flags & PM_TRANS_FLAG_RECURSEALL);
+ trans->flags & ALPM_TRANS_FLAG_RECURSEALL);
}
- if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
- EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
+ if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
+ EVENT(trans, ALPM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
- _alpm_log(handle, PM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
+ _alpm_log(handle, ALPM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(db), trans->remove, NULL, 1);
if(lp != NULL) {
- if(trans->flags & PM_TRANS_FLAG_CASCADE) {
+ if(trans->flags & ALPM_TRANS_FLAG_CASCADE) {
remove_prepare_cascade(handle, lp);
- } else if(trans->flags & PM_TRANS_FLAG_UNNEEDED) {
+ } else if(trans->flags & ALPM_TRANS_FLAG_UNNEEDED) {
/* Remove needed packages (which would break dependencies)
* from target list */
remove_prepare_keep_needed(handle, lp);
@@ -167,26 +167,26 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
alpm_list_free_inner(lp, (alpm_list_fn_free)_alpm_depmiss_free);
alpm_list_free(lp);
}
- RET_ERR(handle, PM_ERR_UNSATISFIED_DEPS, -1);
+ RET_ERR(handle, ALPM_ERR_UNSATISFIED_DEPS, -1);
}
}
}
/* re-order w.r.t. dependencies */
- _alpm_log(handle, PM_LOG_DEBUG, "sorting by dependencies\n");
+ _alpm_log(handle, ALPM_LOG_DEBUG, "sorting by dependencies\n");
lp = _alpm_sortbydeps(handle, trans->remove, 1);
/* free the old alltargs */
alpm_list_free(trans->remove);
trans->remove = lp;
/* -Rcs == -Rc then -Rs */
- if((trans->flags & PM_TRANS_FLAG_CASCADE) && (trans->flags & PM_TRANS_FLAG_RECURSE)) {
- _alpm_log(handle, PM_LOG_DEBUG, "finding removable dependencies\n");
- _alpm_recursedeps(db, trans->remove, trans->flags & PM_TRANS_FLAG_RECURSEALL);
+ if((trans->flags & ALPM_TRANS_FLAG_CASCADE) && (trans->flags & ALPM_TRANS_FLAG_RECURSE)) {
+ _alpm_log(handle, ALPM_LOG_DEBUG, "finding removable dependencies\n");
+ _alpm_recursedeps(db, trans->remove, trans->flags & ALPM_TRANS_FLAG_RECURSEALL);
}
- if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
- EVENT(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
+ if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
+ EVENT(trans, ALPM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);
}
return 0;
@@ -209,7 +209,7 @@ static int can_remove_file(alpm_handle_t *handle, const alpm_file_t *file,
if(errno != EACCES && errno != ETXTBSY && access(filepath, F_OK) == 0) {
/* only return failure if the file ACTUALLY exists and we can't write to
* it - ignore "chmod -w" simple permission failures */
- _alpm_log(handle, PM_LOG_ERROR, _("cannot remove file '%s': %s\n"),
+ _alpm_log(handle, ALPM_LOG_ERROR, _("cannot remove file '%s': %s\n"),
filepath, strerror(errno));
return 0;
}
@@ -232,7 +232,7 @@ static void unlink_file(alpm_handle_t *handle, alpm_pkg_t *info,
* see the big comment block in db_find_fileconflicts() for an
* explanation. */
if(alpm_list_find_str(skip_remove, fileobj->name)) {
- _alpm_log(handle, PM_LOG_DEBUG, "%s is in skip_remove, skipping removal\n",
+ _alpm_log(handle, ALPM_LOG_DEBUG, "%s is in skip_remove, skipping removal\n",
file);
return;
}
@@ -242,23 +242,23 @@ static void unlink_file(alpm_handle_t *handle, alpm_pkg_t *info,
* filesystem, we want to work with the linked directory instead of the
* actual symlink */
if(lstat(file, &buf)) {
- _alpm_log(handle, PM_LOG_DEBUG, "file %s does not exist\n", file);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "file %s does not exist\n", file);
return;
}
if(S_ISDIR(buf.st_mode)) {
if(rmdir(file)) {
/* this is okay, other packages are probably using it (like /usr) */
- _alpm_log(handle, PM_LOG_DEBUG, "keeping directory %s\n", file);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "keeping directory %s\n", file);
} else {
- _alpm_log(handle, PM_LOG_DEBUG, "removing directory %s\n", file);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "removing directory %s\n", file);
}
} else {
/* if the file needs backup and has been modified, back it up to .pacsave */
alpm_backup_t *backup = _alpm_needbackup(fileobj->name, 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);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "transaction is set to NOSAVE, not backing up '%s'\n", file);
} else {
char *filehash = alpm_compute_md5sum(file);
int cmp = filehash ? strcmp(filehash, backup->hash) : 0;
@@ -267,17 +267,17 @@ static void unlink_file(alpm_handle_t *handle, alpm_pkg_t *info,
char newpath[PATH_MAX];
snprintf(newpath, PATH_MAX, "%s.pacsave", file);
rename(file, newpath);
- _alpm_log(handle, PM_LOG_WARNING, _("%s saved as %s\n"), file, newpath);
+ _alpm_log(handle, ALPM_LOG_WARNING, _("%s saved as %s\n"), file, newpath);
alpm_logaction(handle, "warning: %s saved as %s\n", file, newpath);
return;
}
}
}
- _alpm_log(handle, PM_LOG_DEBUG, "unlinking %s\n", file);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "unlinking %s\n", file);
if(unlink(file) == -1) {
- _alpm_log(handle, PM_LOG_ERROR, _("cannot remove file '%s': %s\n"),
+ _alpm_log(handle, ALPM_LOG_ERROR, _("cannot remove file '%s': %s\n"),
file, strerror(errno));
}
}
@@ -291,10 +291,10 @@ int _alpm_upgraderemove_package(alpm_handle_t *handle,
alpm_list_t *files = alpm_pkg_get_files(oldpkg);
const char *pkgname = alpm_pkg_get_name(oldpkg);
- _alpm_log(handle, PM_LOG_DEBUG, "removing old package first (%s-%s)\n",
+ _alpm_log(handle, ALPM_LOG_DEBUG, "removing old package first (%s-%s)\n",
oldpkg->name, oldpkg->version);
- if(handle->trans->flags & PM_TRANS_FLAG_DBONLY) {
+ if(handle->trans->flags & ALPM_TRANS_FLAG_DBONLY) {
goto db;
}
@@ -312,21 +312,21 @@ int _alpm_upgraderemove_package(alpm_handle_t *handle,
if(!_alpm_filelist_contains(filelist, backup->name)) {
continue;
}
- _alpm_log(handle, PM_LOG_DEBUG, "adding %s to the skip_remove array\n",
+ _alpm_log(handle, ALPM_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,
+ _alpm_log(handle, ALPM_LOG_DEBUG,
"not removing package '%s', can't remove all files\n", pkgname);
- RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1);
+ RET_ERR(handle, ALPM_ERR_PKG_CANT_REMOVE, -1);
}
filenum++;
}
- _alpm_log(handle, PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
/* iterate through the list backwards, unlinking files */
for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(files, lp)) {
@@ -336,15 +336,15 @@ int _alpm_upgraderemove_package(alpm_handle_t *handle,
db:
/* remove the package from the database */
- _alpm_log(handle, PM_LOG_DEBUG, "updating database\n");
- _alpm_log(handle, PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "updating database\n");
+ _alpm_log(handle, ALPM_LOG_DEBUG, "removing database entry '%s'\n", pkgname);
if(_alpm_local_db_remove(handle->db_local, oldpkg) == -1) {
- _alpm_log(handle, PM_LOG_ERROR, _("could not remove database entry %s-%s\n"),
+ _alpm_log(handle, ALPM_LOG_ERROR, _("could not remove database entry %s-%s\n"),
pkgname, alpm_pkg_get_version(oldpkg));
}
/* remove the package from the cache */
if(_alpm_db_remove_pkgfromcache(handle->db_local, oldpkg) == -1) {
- _alpm_log(handle, PM_LOG_ERROR, _("could not remove entry '%s' from cache\n"),
+ _alpm_log(handle, ALPM_LOG_ERROR, _("could not remove entry '%s' from cache\n"),
pkgname);
}
@@ -376,72 +376,72 @@ int _alpm_remove_packages(alpm_handle_t *handle)
snprintf(scriptlet, PATH_MAX, "%s%s-%s/install",
_alpm_db_path(handle->db_local), pkgname, alpm_pkg_get_version(info));
- EVENT(trans, PM_TRANS_EVT_REMOVE_START, info, NULL);
- _alpm_log(handle, PM_LOG_DEBUG, "removing package %s-%s\n",
+ EVENT(trans, ALPM_TRANS_EVT_REMOVE_START, info, NULL);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "removing package %s-%s\n",
pkgname, alpm_pkg_get_version(info));
/* run the pre-remove scriptlet if it exists */
- if(alpm_pkg_has_scriptlet(info) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
+ if(alpm_pkg_has_scriptlet(info) && !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
_alpm_runscriptlet(handle, scriptlet, "pre_remove",
alpm_pkg_get_version(info), NULL);
}
- if(!(trans->flags & PM_TRANS_FLAG_DBONLY)) {
+ if(!(trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
alpm_list_t *files = alpm_pkg_get_files(info);
size_t filenum = 0;
for(lp = files; lp; lp = lp->next) {
if(!can_remove_file(handle, lp->data, NULL)) {
- _alpm_log(handle, PM_LOG_DEBUG, "not removing package '%s', can't remove all files\n",
+ _alpm_log(handle, ALPM_LOG_DEBUG, "not removing package '%s', can't remove all files\n",
pkgname);
- RET_ERR(handle, PM_ERR_PKG_CANT_REMOVE, -1);
+ RET_ERR(handle, ALPM_ERR_PKG_CANT_REMOVE, -1);
}
filenum++;
}
- _alpm_log(handle, PM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "removing %ld files\n", (unsigned long)filenum);
/* init progress bar */
- PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name, 0,
+ PROGRESS(trans, ALPM_TRANS_PROGRESS_REMOVE_START, info->name, 0,
pkg_count, (pkg_count - targcount + 1));
/* iterate through the list backwards, unlinking files */
for(lp = alpm_list_last(files); lp; lp = alpm_list_previous(files, lp)) {
int percent;
- unlink_file(handle, info, lp->data, NULL, trans->flags & PM_TRANS_FLAG_NOSAVE);
+ unlink_file(handle, info, lp->data, NULL, trans->flags & ALPM_TRANS_FLAG_NOSAVE);
/* update progress bar after each file */
percent = (position * 100) / filenum;
- PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, info->name,
+ PROGRESS(trans, ALPM_TRANS_PROGRESS_REMOVE_START, info->name,
percent, pkg_count, (pkg_count - targcount + 1));
position++;
}
}
/* set progress to 100% after we finish unlinking files */
- PROGRESS(trans, PM_TRANS_PROGRESS_REMOVE_START, pkgname, 100,
+ PROGRESS(trans, ALPM_TRANS_PROGRESS_REMOVE_START, pkgname, 100,
pkg_count, (pkg_count - targcount + 1));
/* run the post-remove script if it exists */
- if(alpm_pkg_has_scriptlet(info) && !(trans->flags & PM_TRANS_FLAG_NOSCRIPTLET)) {
+ if(alpm_pkg_has_scriptlet(info) && !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
_alpm_runscriptlet(handle, scriptlet, "post_remove",
alpm_pkg_get_version(info), NULL);
}
/* remove the package from the database */
- _alpm_log(handle, PM_LOG_DEBUG, "updating database\n");
- _alpm_log(handle, PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname);
+ _alpm_log(handle, ALPM_LOG_DEBUG, "updating database\n");
+ _alpm_log(handle, ALPM_LOG_DEBUG, "removing database entry '%s'\n", pkgname);
if(_alpm_local_db_remove(handle->db_local, info) == -1) {
- _alpm_log(handle, PM_LOG_ERROR, _("could not remove database entry %s-%s\n"),
+ _alpm_log(handle, ALPM_LOG_ERROR, _("could not remove database entry %s-%s\n"),
pkgname, alpm_pkg_get_version(info));
}
/* remove the package from the cache */
if(_alpm_db_remove_pkgfromcache(handle->db_local, info) == -1) {
- _alpm_log(handle, PM_LOG_ERROR, _("could not remove entry '%s' from cache\n"),
+ _alpm_log(handle, ALPM_LOG_ERROR, _("could not remove entry '%s' from cache\n"),
pkgname);
}
- EVENT(trans, PM_TRANS_EVT_REMOVE_DONE, info, NULL);
+ EVENT(trans, ALPM_TRANS_EVT_REMOVE_DONE, info, NULL);
}
/* run ldconfig if it exists */