summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2014-10-01 08:06:49 +0200
committerAllan McRae <allan@archlinux.org>2015-01-21 05:27:47 +0100
commitba0d225d93d4254e08e48b97ca6b55861cc8e54f (patch)
tree02f2c868bbfa14a9a18b8f10531fbb376ad34c3c /lib/libalpm
parent926280cfc7da5aa6d8a4e7dc60f9831176758e7e (diff)
downloadpacman-ba0d225d93d4254e08e48b97ca6b55861cc8e54f.tar.gz
pacman-ba0d225d93d4254e08e48b97ca6b55861cc8e54f.tar.xz
extract_single_file: use .pacnew for check files
Prevents the need to rename the file if we end up keeping it and ensures that pacnew files always reflect the most recent version by overwriting stale copies. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index d4f77185..0a63566b 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -286,7 +286,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
len = strlen(filename) + 10;
MALLOC(checkfile, len,
errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
- snprintf(checkfile, len, "%s.paccheck", filename);
+ snprintf(checkfile, len, "%s.pacnew", filename);
if(perform_extraction(handle, archive, entry, checkfile)) {
errors++;
@@ -331,35 +331,21 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
errors++;
}
} else {
- /* none of the three files matched another, unpack the new file alongside
- * the local file */
- char *newpath;
- size_t newlen = strlen(filename) + strlen(".pacnew") + 1;
-
+ /* none of the three files matched another, leave the unpacked
+ * file alongside the local file */
+ alpm_event_pacnew_created_t event = {
+ .type = ALPM_EVENT_PACNEW_CREATED,
+ .from_noupgrade = 0,
+ .oldpkg = oldpkg,
+ .newpkg = newpkg,
+ .file = filename
+ };
_alpm_log(handle, ALPM_LOG_DEBUG,
"action: keeping current file and installing"
" new one with .pacnew ending\n");
-
- MALLOC(newpath, newlen,
- errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup);
- snprintf(newpath, newlen, "%s.pacnew", filename);
-
- if(try_rename(handle, checkfile, newpath)) {
- errors++;
- } else {
- alpm_event_pacnew_created_t event = {
- .type = ALPM_EVENT_PACNEW_CREATED,
- .from_noupgrade = 0,
- .oldpkg = oldpkg,
- .newpkg = newpkg,
- .file = filename
- };
- EVENT(handle, &event);
- alpm_logaction(handle, ALPM_CALLER_PREFIX,
- "warning: %s installed as %s\n", filename, newpath);
- }
-
- free(newpath);
+ EVENT(handle, &event);
+ alpm_logaction(handle, ALPM_CALLER_PREFIX,
+ "warning: %s installed as %s\n", filename, checkfile);
}
needbackup_cleanup: