1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-10-31 15:45:03 -04:00

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>
This commit is contained in:
Andrew Gregory 2014-10-01 01:57:44 -04:00 committed by Allan McRae
parent a82a5cf3f7
commit 926280cfc7
14 changed files with 35 additions and 104 deletions

4
README
View File

@ -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()

View File

@ -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,

View File

@ -1,5 +1,5 @@
#!/bin/bash
# pacdiff : a simple pacnew/pacorig/pacsave updater
# pacdiff : a simple pacnew/pacsave updater
#
# Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com>
# Copyright (c) 2013-2014 Pacman Development Team <pacman-dev@archlinux.org>
@ -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]

View File

@ -484,8 +484,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

View File

@ -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");
_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);
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);
}
free(newpath);
if(try_rename(handle, checkfile, newpath)) {
errors++;
} 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);
}
}
free(newpath);
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:

View File

@ -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. */

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")