index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2014-10-01 01:57:44 -0400 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2015-01-21 14:27:47 +1000 |
commit | 926280cfc7da5aa6d8a4e7dc60f9831176758e7e (patch) | |
tree | 4465c6d1d69d744af94fc4b80ad2da2b2db4ce16 /lib/libalpm/add.c | |
parent | a82a5cf3f71e38c54a5ac1b5eaf3c83374d0e515 (diff) |
-rw-r--r-- | lib/libalpm/add.c | 82 |
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index f6f62f32..d4f77185 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -333,69 +333,33 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive, } 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; - if(oldpkg) { - char *newpath; - size_t newlen = strlen(filename) + strlen(".pacnew") + 1; - - _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); - } + _alpm_log(handle, ALPM_LOG_DEBUG, + "action: keeping current file and installing" + " new one with .pacnew ending\n"); - free(newpath); - } else { - char *newpath; - size_t newlen = strlen(filename) + strlen(".pacorig") + 1; - - _alpm_log(handle, ALPM_LOG_DEBUG, - "action: saving existing file with a .pacorig ending" - " and installing a new one\n"); - - MALLOC(newpath, newlen, - errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup); - snprintf(newpath, newlen, "%s.pacorig", filename); - - /* move the existing file to the "pacorig" */ - if(try_rename(handle, filename, newpath)) { - errors++; /* failed rename filename -> filename.pacorig */ - errors++; /* failed rename checkfile -> filename */ - } else { - /* rename the file we extracted to the real name */ - if(try_rename(handle, checkfile, filename)) { - errors++; - } else { - alpm_event_pacorig_created_t event = { - .type = ALPM_EVENT_PACORIG_CREATED, - .newpkg = newpkg, - .file = filename - }; - EVENT(handle, &event); - alpm_logaction(handle, ALPM_CALLER_PREFIX, - "warning: %s saved as %s\n", filename, newpath); - } - } + MALLOC(newpath, newlen, + errors++; handle->pm_errno = ALPM_ERR_MEMORY; goto needbackup_cleanup); + snprintf(newpath, newlen, "%s.pacnew", filename); - free(newpath); + 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: |