Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/add.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r--lib/libalpm/add.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index f39a0ecf..2b6b019b 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -40,7 +40,6 @@
#include "alpm_list.h"
#include "trans.h"
#include "util.h"
-#include "cache.h"
#include "log.h"
#include "backup.h"
#include "package.h"
@@ -498,7 +497,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
oldpkg = _alpm_pkg_dup(local);
/* make sure all infos are loaded because the database entry
* will be removed soon */
- _alpm_db_read(oldpkg->origin_data.db, oldpkg, INFRQ_ALL);
+ _alpm_local_db_read(oldpkg->origin_data.db, oldpkg, INFRQ_ALL);
EVENT(trans, PM_TRANS_EVT_UPGRADE_START, newpkg, oldpkg);
_alpm_log(PM_LOG_DEBUG, "upgrading package %s-%s\n",
@@ -544,7 +543,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
/* prepare directory for database entries so permission are correct after
changelog/install script installation (FS#12263) */
- if(_alpm_db_prepare(db, newpkg)) {
+ if(_alpm_local_db_prepare(db, newpkg)) {
alpm_logaction("error: could not create database entry %s-%s\n",
alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg));
pm_errno = PM_ERR_DB_WRITE;
@@ -556,6 +555,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
struct archive *archive;
struct archive_entry *entry;
char cwd[PATH_MAX] = "";
+ int restore_cwd = 0;
_alpm_log(PM_LOG_DEBUG, "extracting files\n");
@@ -579,11 +579,16 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
/* save the cwd so we can restore it later */
if(getcwd(cwd, PATH_MAX) == NULL) {
_alpm_log(PM_LOG_ERROR, _("could not get current working directory\n"));
- cwd[0] = 0;
+ } else {
+ restore_cwd = 1;
}
/* libarchive requires this for extracting hard links */
- chdir(handle->root);
+ if(chdir(handle->root) != 0) {
+ _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), handle->root, strerror(errno));
+ ret = -1;
+ goto cleanup;
+ }
/* call PROGRESS once with 0 percent, as we sort-of skip that here */
if(is_upgrade) {
@@ -629,9 +634,9 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
}
archive_read_finish(archive);
- /* restore the old cwd is we have it */
- if(strlen(cwd)) {
- chdir(cwd);
+ /* restore the old cwd if we have it */
+ if(restore_cwd && chdir(cwd) != 0) {
+ _alpm_log(PM_LOG_ERROR, _("could not change directory to %s (%s)\n"), cwd, strerror(errno));
}
if(errors) {
@@ -656,7 +661,7 @@ static int commit_single_pkg(pmpkg_t *newpkg, int pkg_current, int pkg_count,
_alpm_log(PM_LOG_DEBUG, "updating database\n");
_alpm_log(PM_LOG_DEBUG, "adding database entry '%s'\n", newpkg->name);
- if(_alpm_db_write(db, newpkg, INFRQ_ALL)) {
+ if(_alpm_local_db_write(db, newpkg, INFRQ_ALL)) {
_alpm_log(PM_LOG_ERROR, _("could not update database entry %s-%s\n"),
alpm_pkg_get_name(newpkg), alpm_pkg_get_version(newpkg));
alpm_logaction("error: could not update database entry %s-%s\n",