mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-21 23:38:49 -05:00
only remove pacnew file if it is new
Check if we overwrote an exiting pacnew file before unlinking it. Otherwise, updating to a version with an unchanged file would delete existing pacnew files. FS#47993 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
169287e494
commit
fd936c9e73
@ -178,7 +178,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
|
||||
char filename[PATH_MAX]; /* the actual file we're extracting */
|
||||
int needbackup = 0, notouch = 0;
|
||||
const char *hash_orig = NULL;
|
||||
int errors = 0;
|
||||
int isnewfile = 0, errors = 0;
|
||||
struct stat lsbuf;
|
||||
size_t filename_len;
|
||||
|
||||
@ -226,7 +226,8 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
|
||||
* 6- skip extraction, dir already exists.
|
||||
*/
|
||||
|
||||
if(llstat(filename, &lsbuf) != 0) {
|
||||
isnewfile = llstat(filename, &lsbuf) != 0;
|
||||
if(isnewfile) {
|
||||
/* cases 1,2: file doesn't exist, skip all backup checks */
|
||||
} else if(S_ISDIR(lsbuf.st_mode) && S_ISDIR(entrymode)) {
|
||||
#if 0
|
||||
@ -301,6 +302,7 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
|
||||
return 1;
|
||||
}
|
||||
strcpy(filename + filename_len, ".pacnew");
|
||||
isnewfile = (llstat(filename, &lsbuf) != 0 && errno == ENOENT);
|
||||
}
|
||||
|
||||
_alpm_log(handle, ALPM_LOG_DEBUG, "extracting %s\n", filename);
|
||||
@ -354,7 +356,9 @@ static int extract_single_file(alpm_handle_t *handle, struct archive *archive,
|
||||
* including any user changes */
|
||||
_alpm_log(handle, ALPM_LOG_DEBUG,
|
||||
"action: leaving existing file in place\n");
|
||||
unlink(filename);
|
||||
if(isnewfile) {
|
||||
unlink(filename);
|
||||
}
|
||||
} else if(hash_orig && hash_local && strcmp(hash_orig, hash_local) == 0) {
|
||||
/* installed file has NOT been changed by user,
|
||||
* update to the new version */
|
||||
|
@ -1,3 +1,4 @@
|
||||
TESTS += test/pacman/tests/backup001.py
|
||||
TESTS += test/pacman/tests/clean001.py
|
||||
TESTS += test/pacman/tests/clean002.py
|
||||
TESTS += test/pacman/tests/clean003.py
|
||||
|
20
test/pacman/tests/backup001.py
Normal file
20
test/pacman/tests/backup001.py
Normal file
@ -0,0 +1,20 @@
|
||||
self.description = "Upgrade a package, with a file in 'backup' (local modified, new unchanged)"
|
||||
|
||||
self.filesystem = ["etc/dummy.conf.pacnew"]
|
||||
|
||||
lp = pmpkg("dummy")
|
||||
lp.files = ["etc/dummy.conf*"]
|
||||
lp.backup = ["etc/dummy.conf"]
|
||||
self.addpkg2db("local", lp)
|
||||
|
||||
p = pmpkg("dummy", "1.0-2")
|
||||
p.files = ["etc/dummy.conf"]
|
||||
p.backup = ["etc/dummy.conf"]
|
||||
self.addpkg(p)
|
||||
|
||||
self.args = "-U %s" % p.filename()
|
||||
|
||||
self.addrule("PACMAN_RETCODE=0")
|
||||
self.addrule("PKG_VERSION=dummy|1.0-2")
|
||||
self.addrule("FILE_PACNEW=etc/dummy.conf")
|
||||
self.addrule("!FILE_MODIFIED=etc/dummy.conf")
|
Loading…
Reference in New Issue
Block a user