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 <[email protected]>
---
 contrib/README                  |  2 +-
 contrib/pacdiff.sh.in           |  9 ++---
 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 -
 13 files changed, 34 insertions(+), 108 deletions(-)

diff --git a/contrib/README b/contrib/README
index ae33bb2..8b5dd3c 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 ecb6ae2..d94754c 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 <[email protected]>
 #   Copyright (c) 2013-2014 Pacman Development Team <[email protected]>
@@ -35,7 +35,7 @@ usage() {
        cat <<EOF
 ${myname} (pacman) v${myver}
 
-A simple program to merge or remove pacnew/pacorig/pacsave files.
+A simple program to merge or remove pacnew/pacsave files.
 
 Usage: $myname [-l | -f | -p] [--nocolor]
 
@@ -77,9 +77,9 @@ print_existing_pacsave(){
 
 cmd() {
        if (( USE_LOCATE )); then
-               locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave 
'*.pacsave.[0-9]*'
+               locate -0 -e -b \*.pacnew \*.pacsave '*.pacsave.[0-9]*'
        elif (( USE_FIND )); then
-               find $diffsearchpath \( -name \*.pacnew -o -name \*.pacorig -o 
-name \*.pacsave -o -name '*.pacsave.[0-9]*' \) -print0
+               find $diffsearchpath \( -name \*.pacnew -o -name \*.pacsave -o 
-name '*.pacsave.[0-9]*' \) -print0
        elif (( USE_PACDB )); then
                awk '/^%BACKUP%$/ {
                while (getline) {
@@ -88,7 +88,6 @@ cmd() {
                        }
                }' "${pac_db}"/*/files | while read -r bkup; do
                        print_existing "/$bkup.pacnew"
-                       print_existing "/$bkup.pacorig"
                        print_existing_pacsave "/$bkup.pacsave"
                done
        fi
diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt
index 152b261..4c05167 100644
--- a/doc/pacman.8.txt
+++ b/doc/pacman.8.txt
@@ -454,8 +454,9 @@ original=X, current=Y, new=Z::
 
 original=NULL, current=Y, new=Z::
        The package was not previously installed, and the file already exists 
on the
-       file system. Save the current file with a '.pacorig' extension, install 
the
-       new file, and warn the user.
+       file system. Install the new file with a '.pacnew' extension and warn 
the
+       user. The user must then manually merge any necessary changes into the
+       original file.
 
 
 Examples
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index ee92414..74c1595 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -334,69 +334,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 1cfd4f5..7c64f34 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -445,10 +445,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 {
@@ -539,15 +536,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
@@ -564,7 +552,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 4993382..6e3fbbe 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -313,22 +313,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 8d8354a..6c601b2 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 0eec8ea..57f1786 100644
--- a/test/pacman/pmrule.py
+++ b/test/pacman/pmrule.py
@@ -148,9 +148,6 @@ def check(self, test):
             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 ea6046c..64fe281 100644
--- a/test/pacman/tests/upgrade015.py
+++ b/test/pacman/tests/upgrade015.py
@@ -12,4 +12,3 @@
 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 b6b3f3a..ddf57e8 100644
--- a/test/pacman/tests/upgrade016.py
+++ b/test/pacman/tests/upgrade016.py
@@ -11,6 +11,5 @@
 
 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 99087f3..3dd694a 100644
--- a/test/pacman/tests/upgrade027.py
+++ b/test/pacman/tests/upgrade027.py
@@ -18,5 +18,4 @@
 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 18a10f5..1e31aa3 100644
--- a/test/pacman/tests/upgrade028.py
+++ b/test/pacman/tests/upgrade028.py
@@ -18,5 +18,4 @@
 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 c308f42..eef5c70 100644
--- a/test/pacman/tests/upgrade029.py
+++ b/test/pacman/tests/upgrade029.py
@@ -20,5 +20,4 @@
 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")
-- 
2.1.1

Reply via email to