summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2014-10-01 07:57:44 +0200
committerAllan McRae <allan@archlinux.org>2015-01-21 05:27:47 +0100
commit926280cfc7da5aa6d8a4e7dc60f9831176758e7e (patch)
tree4465c6d1d69d744af94fc4b80ad2da2b2db4ce16 /lib/libalpm
parenta82a5cf3f71e38c54a5ac1b5eaf3c83374d0e515 (diff)
downloadpacman-926280cfc7da5aa6d8a4e7dc60f9831176758e7e.tar.gz
pacman-926280cfc7da5aa6d8a4e7dc60f9831176758e7e.tar.xz
remove support for .pacorig files
Leave user files in place and save new config files with a .pacnew extension. This reduces the complexity of file extraction and respects the principle that pacman shouldn't modify files it didn't create. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c82
-rw-r--r--lib/libalpm/alpm.h15
2 files changed, 24 insertions, 73 deletions
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:
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 53793b4b..23ec2427 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -442,10 +442,7 @@ typedef enum _alpm_event_type_t {
ALPM_EVENT_PACNEW_CREATED,
/** A .pacsave file was created; See alpm_event_pacsave_created_t for
* arguments */
- ALPM_EVENT_PACSAVE_CREATED,
- /** A .pacorig file was created; See alpm_event_pacorig_created_t for
- * arguments */
- ALPM_EVENT_PACORIG_CREATED
+ ALPM_EVENT_PACSAVE_CREATED
} alpm_event_type_t;
typedef struct _alpm_event_any_t {
@@ -536,15 +533,6 @@ typedef struct _alpm_event_pacsave_created_t {
const char *file;
} alpm_event_pacsave_created_t;
-typedef struct _alpm_event_pacorig_created_t {
- /** Type of event. */
- alpm_event_type_t type;
- /** New package. */
- alpm_pkg_t *newpkg;
- /** Filename of the file without the .pacorig suffix. */
- const char *file;
-} alpm_event_pacorig_created_t;
-
/** Events.
* This is an union passed to the callback, that allows the frontend to know
* which type of event was triggered (via type). It is then possible to
@@ -561,7 +549,6 @@ typedef union _alpm_event_t {
alpm_event_pkgdownload_t pkgdownload;
alpm_event_pacnew_created_t pacnew_created;
alpm_event_pacsave_created_t pacsave_created;
- alpm_event_pacorig_created_t pacorig_created;
} alpm_event_t;
/** Event callback. */