1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

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>
This commit is contained in:
Andrew Gregory 2014-10-01 02:06:49 -04:00 committed by Allan McRae
parent 926280cfc7
commit ba0d225d93

View File

@ -286,7 +286,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
len = strlen(filename) + 10; len = strlen(filename) + 10;
MALLOC(checkfile, len, MALLOC(checkfile, len,
errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup); 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)) { if(perform_extraction(handle, archive, entry, checkfile)) {
errors++; errors++;
@ -331,35 +331,21 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
errors++; errors++;
} }
} else { } else {
/* none of the three files matched another, unpack the new file alongside /* none of the three files matched another, leave the unpacked
* the local file */ * file alongside the local file */
char *newpath; alpm_event_pacnew_created_t event = {
size_t newlen = strlen(filename) + strlen(".pacnew") + 1; .type = ALPM_EVENT_PACNEW_CREATED,
.from_noupgrade = 0,
.oldpkg = oldpkg,
.newpkg = newpkg,
.file = filename
};
_alpm_log(handle, ALPM_LOG_DEBUG, _alpm_log(handle, ALPM_LOG_DEBUG,
"action: keeping current file and installing" "action: keeping current file and installing"
" new one with .pacnew ending\n"); " new one with .pacnew ending\n");
EVENT(handle, &event);
MALLOC(newpath, newlen, alpm_logaction(handle, ALPM_CALLER_PREFIX,
errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup); "warning: %s installed as %s\n", filename, checkfile);
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);
} }
needbackup_cleanup: needbackup_cleanup: