Date: Friday, March 9, 2007 @ 00:33:06 Author: aaron Path: /home/cvs-pacman/pacman-lib Modified: lib/libalpm/db.c (1.66 -> 1.67) lib/libalpm/remove.c (1.74 -> 1.75) src/pacman/deptest.c (1.18 -> 1.19) * Two fixes when running under a new root (-r|--root) - Check EACCES in can_remove_file, to verify - we're only checking for a read-only FS here... if write permissions fail, we can still remove it - Switched the message when creating DB directories from an error to a debug message * Fix the dep tests once and for all (it wasn't working for provides=() packages) ----------------------+ lib/libalpm/db.c | 2 +- lib/libalpm/remove.c | 6 +++--- src/pacman/deptest.c | 31 +++++++++++++++---------------- 3 files changed, 19 insertions(+), 20 deletions(-) Index: pacman-lib/lib/libalpm/db.c diff -u pacman-lib/lib/libalpm/db.c:1.66 pacman-lib/lib/libalpm/db.c:1.67 --- pacman-lib/lib/libalpm/db.c:1.66 Mon Mar 5 17:13:34 2007 +++ pacman-lib/lib/libalpm/db.c Fri Mar 9 00:33:06 2007 @@ -183,7 +183,7 @@ /* make sure the database directory exists */ snprintf(path, PATH_MAX, "%s%s/%s", handle->root, handle->dbpath, treename); if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) { - _alpm_log(PM_LOG_ERROR, _("database directory '%s' does not exist, try creating it"), path); + _alpm_log(PM_LOG_DEBUG, _("database directory '%s' does not exist, creating it"), path); if(_alpm_makepath(path) != 0) { RET_ERR(PM_ERR_SYSTEM, NULL); } Index: pacman-lib/lib/libalpm/remove.c diff -u pacman-lib/lib/libalpm/remove.c:1.74 pacman-lib/lib/libalpm/remove.c:1.75 --- pacman-lib/lib/libalpm/remove.c:1.74 Mon Mar 5 17:13:34 2007 +++ pacman-lib/lib/libalpm/remove.c Fri Mar 9 00:33:06 2007 @@ -169,9 +169,9 @@ /* If we fail write permissions due to a read-only filesystem, abort. * Assume all other possible failures are covered somewhere else */ if(access(file, W_OK) == -1) { - if(access(file, F_OK) == 0) { - /* only return failure if the file ACTUALLY exists and we don't have - * permissions */ + if(errno != EACCES && access(file, 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(PM_LOG_ERROR, _("cannot remove file '%s': %s"), file, strerror(errno)); return(0); Index: pacman-lib/src/pacman/deptest.c diff -u pacman-lib/src/pacman/deptest.c:1.18 pacman-lib/src/pacman/deptest.c:1.19 --- pacman-lib/src/pacman/deptest.c:1.18 Wed Mar 7 16:47:52 2007 +++ pacman-lib/src/pacman/deptest.c Fri Mar 9 00:33:06 2007 @@ -38,17 +38,6 @@ extern config_t *config; -static int chk_package(const char *pkgname, pmdepend_t *dep) -{ - pmpkg_t *pkg; - pkg = alpm_db_get_pkg(alpm_option_get_localdb(), pkgname); - - if(!pkg || !alpm_depcmp(pkg, dep)) { - return(1); - } - return(0); -} - int pacman_deptest(alpm_list_t *targets) { int retval = 0; @@ -60,32 +49,42 @@ for(i = targets; i; i = alpm_list_next(i)) { int found = 0; + pmpkg_t *pkg; pmdepend_t *dep; const char *target; alpm_list_t *j, *provides; target = alpm_list_getdata(i); + + /* splitdep modifies the string... we'll compensate for now */ + char *saved_target = NULL; + saved_target = calloc(strlen(target)+1, sizeof(char)); + strncpy(saved_target, target, strlen(target)); + dep = alpm_splitdep(target); - if(chk_package(target, dep) == 0) { + pkg = alpm_db_get_pkg(alpm_option_get_localdb(), target); + if(pkg && alpm_depcmp(pkg, dep)) { found = 1; } else { /* not found, can we find anything that provides this in the local DB? */ provides = alpm_db_whatprovides(alpm_option_get_localdb(), target); for(j = provides; j; j = alpm_list_next(j)) { - const char *provide; - provide = alpm_list_getdata(j); + pmpkg_t *pkg; + pkg = alpm_list_getdata(j); - if(chk_package(provide, dep) == 0) { + if(pkg && alpm_depcmp(pkg, dep)) { found = 1; + break; } } } if(!found) { - MSG(NL, _("requires: %s"), target); + MSG(NL, _("requires: %s"), saved_target); retval = 1; } + free(saved_target); } return(retval); }