From 926280cfc7da5aa6d8a4e7dc60f9831176758e7e Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Wed, 1 Oct 2014 01:57:44 -0400 Subject: 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 --- README | 4 ++ contrib/README | 2 +- contrib/pacdiff.sh.in | 4 +- doc/pacman.8.txt | 5 ++- lib/libalpm/add.c | 82 ++++++++++++----------------------------- lib/libalpm/alpm.h | 15 +------- src/pacman/callback.c | 16 -------- test/pacman/README | 1 - test/pacman/pmrule.py | 3 -- test/pacman/tests/upgrade015.py | 1 - test/pacman/tests/upgrade016.py | 5 +-- test/pacman/tests/upgrade027.py | 1 - test/pacman/tests/upgrade028.py | 1 - test/pacman/tests/upgrade029.py | 1 - 14 files changed, 36 insertions(+), 105 deletions(-) diff --git a/README b/README index 4aeb8435..8c17d335 100644 --- a/README +++ b/README @@ -568,6 +568,10 @@ API CHANGES BETWEEN 4.2 AND 5.0 [REMOVED] - alpm_siglevel_t - removed members ALPM_SIG_PACKAGE_SET, ALPM_SIG_PACKAGE_TRUST_SET +- ALPM_EVENT_PACORIG_CREATED +- alpm_event_pacorig_created_t +- alpm_event_t.pacorig_created + [ADDED] - pkgbase accessor - alpm_pkg_get_base() diff --git a/contrib/README b/contrib/README index bcb4b853..befd3c1d 100644 --- a/contrib/README +++ b/contrib/README @@ -16,7 +16,7 @@ sync databases (for safety on rolling release distributions). paccache - a flexible package cache cleaning utility that allows greater control over which packages are removed. -pacdiff - a simple pacnew/pacorig/pacsave updater for /etc/. +pacdiff - a simple pacnew/pacsave updater for /etc/. paclist - list all packages installed from a given repository. Useful for seeing which packages you may have installed from the testing repository, diff --git a/contrib/pacdiff.sh.in b/contrib/pacdiff.sh.in index ecb6ae29..3f0a3c69 100644 --- a/contrib/pacdiff.sh.in +++ b/contrib/pacdiff.sh.in @@ -1,5 +1,5 @@ #!/bin/bash -# pacdiff : a simple pacnew/pacorig/pacsave updater +# pacdiff : a simple pacnew/pacsave updater # # Copyright (c) 2007 Aaron Griffin # Copyright (c) 2013-2014 Pacman Development Team @@ -35,7 +35,7 @@ usage() { cat <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. */ diff --git a/src/pacman/callback.c b/src/pacman/callback.c index d566d738..0d87fd35 100644 --- a/src/pacman/callback.c +++ b/src/pacman/callback.c @@ -315,22 +315,6 @@ void cb_event(alpm_event_t *event) } } break; - case ALPM_EVENT_PACORIG_CREATED: - { - alpm_event_pacorig_created_t *e = &event->pacorig_created; - if(on_progress) { - char *string = NULL; - pm_sprintf(&string, ALPM_LOG_WARNING, _("%s saved as %s.pacorig\n"), - e->file, e->file); - if(string != NULL) { - output = alpm_list_add(output, string); - } - } else { - pm_printf(ALPM_LOG_WARNING, _("%s saved as %s.pacorig\n"), - e->file, e->file); - } - } - break; /* all the simple done events, with fallthrough for each */ case ALPM_EVENT_FILECONFLICTS_DONE: case ALPM_EVENT_CHECKDEPS_DONE: diff --git a/test/pacman/README b/test/pacman/README index 8d8354ab..6c601b2f 100644 --- a/test/pacman/README +++ b/test/pacman/README @@ -310,7 +310,6 @@ its DEPENDS field. FILE_TYPE=path/to/file|type (possible types: dir, file, link) FILE_PACNEW=path/to/file FILE_PACSAVE=path/to/file - FILE_PACORIG=path/to/file Example: FILE_EXIST=etc/test.conf diff --git a/test/pacman/pmrule.py b/test/pacman/pmrule.py index c2336c5d..8e6b2c0c 100644 --- a/test/pacman/pmrule.py +++ b/test/pacman/pmrule.py @@ -146,9 +146,6 @@ class pmrule(object): elif case == "PACNEW": if not os.path.isfile("%s.pacnew" % filename): success = 0 - elif case == "PACORIG": - if not os.path.isfile("%s.pacorig" % filename): - success = 0 elif case == "PACSAVE": if not os.path.isfile("%s.pacsave" % filename): success = 0 diff --git a/test/pacman/tests/upgrade015.py b/test/pacman/tests/upgrade015.py index ea6046cb..64fe2813 100644 --- a/test/pacman/tests/upgrade015.py +++ b/test/pacman/tests/upgrade015.py @@ -12,4 +12,3 @@ self.addrule("PACMAN_RETCODE=0") self.addrule("PKG_EXIST=dummy") self.addrule("FILE_MODIFIED=etc/dummy.conf") self.addrule("!FILE_PACNEW=etc/dummy.conf") -self.addrule("!FILE_PACORIG=etc/dummy.conf") diff --git a/test/pacman/tests/upgrade016.py b/test/pacman/tests/upgrade016.py index b6b3f3ae..ddf57e8c 100644 --- a/test/pacman/tests/upgrade016.py +++ b/test/pacman/tests/upgrade016.py @@ -11,6 +11,5 @@ self.args = "-U --force %s" % p.filename() self.addrule("PACMAN_RETCODE=0") self.addrule("PKG_EXIST=dummy") -self.addrule("FILE_MODIFIED=etc/dummy.conf") -self.addrule("!FILE_PACNEW=etc/dummy.conf") -self.addrule("FILE_PACORIG=etc/dummy.conf") +self.addrule("!FILE_MODIFIED=etc/dummy.conf") +self.addrule("FILE_PACNEW=etc/dummy.conf") diff --git a/test/pacman/tests/upgrade027.py b/test/pacman/tests/upgrade027.py index 99087f34..3dd694af 100644 --- a/test/pacman/tests/upgrade027.py +++ b/test/pacman/tests/upgrade027.py @@ -18,5 +18,4 @@ self.addrule("PACMAN_RETCODE=0") self.addrule("PKG_VERSION=dummy|1.0-2") self.addrule("FILE_PACNEW=etc/dummy.conf") self.addrule("!FILE_PACSAVE=etc/dummy.conf") -self.addrule("!FILE_PACORIG=etc/dummy.conf") self.addrule("FILE_EXIST=etc/dummy.conf") diff --git a/test/pacman/tests/upgrade028.py b/test/pacman/tests/upgrade028.py index 18a10f57..1e31aa31 100644 --- a/test/pacman/tests/upgrade028.py +++ b/test/pacman/tests/upgrade028.py @@ -18,5 +18,4 @@ self.addrule("PACMAN_RETCODE=0") self.addrule("PKG_VERSION=dummy|1.0-2") self.addrule("!FILE_PACNEW=etc/dummy.conf") self.addrule("!FILE_PACSAVE=etc/dummy.conf") -self.addrule("!FILE_PACORIG=etc/dummy.conf") self.addrule("FILE_EXIST=etc/dummy.conf") diff --git a/test/pacman/tests/upgrade029.py b/test/pacman/tests/upgrade029.py index c308f426..eef5c700 100644 --- a/test/pacman/tests/upgrade029.py +++ b/test/pacman/tests/upgrade029.py @@ -20,5 +20,4 @@ self.addrule("PACMAN_RETCODE=1") self.addrule("PKG_VERSION=dummy|1.0-1") self.addrule("!FILE_PACNEW=etc/dummy.conf") self.addrule("!FILE_PACSAVE=etc/dummy.conf") -self.addrule("!FILE_PACORIG=etc/dummy.conf") self.addrule("FILE_EXIST=etc/dummy.conf") -- cgit v1.2.3-24-g4f1b