[pacman-dev] [PATCH] alpm/remove.c : respect --dbonly during remove-upgrade
When a -Sk or -Uk operation induced a removal of an existing local package, --dbonly was not in effect and the files were all removed. Fixing this behavior was already marked as TODO in database012 pactest << TODO: I honestly think the above should NOT delete the original les, it hould upgrade the DB entry without touching anything on the file stem. E.g. this test should be the same as: pacman -R --dbonly dummy && pacman -U --dbonly dummy.pkg.tar.gz
Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> --- doc/pacman.8.txt | 2 -- lib/libalpm/remove.c | 4 ++++ src/pacman/pacman.c | 3 +-- test/pacman/tests/database012.py | 8 +------- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index f389dfd..866c5a2 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -155,8 +155,6 @@ Transaction Options (apply to '-S', '-R' and '-U') *-k, \--dbonly*:: Adds/Removes the database entry only, leaves all files in place. - On an upgrade operation, the existing package and all files - will be removed and the database entry for the new package will be added. *\--noprogressbar*:: Do not show a progress bar when downloading files. This can be useful diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index dfaba03..e0099fb 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -311,6 +311,9 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *tra _alpm_log(PM_LOG_DEBUG, "removing old package first (%s-%s)\n", oldpkg->name, oldpkg->version); + if(trans->flags & PM_TRANS_FLAG_DBONLY) + goto db; + /* copy the remove skiplist over */ skip_remove = alpm_list_join(alpm_list_strdup(trans->skip_remove),alpm_list_strdup(handle->noupgrade)); @@ -345,6 +348,7 @@ int _alpm_upgraderemove_package(pmpkg_t *oldpkg, pmpkg_t *newpkg, pmtrans_t *tra alpm_list_free(newfiles); FREELIST(skip_remove); +db: /* remove the package from the database */ _alpm_log(PM_LOG_DEBUG, "updating database\n"); _alpm_log(PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname); diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 933698e..4bf2613 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -90,7 +90,6 @@ static void usage(int op, const char * const myname) printf("%s: %s {-R --remove} [%s] <%s>\n", str_usg, myname, str_opt, str_pkg); printf("%s:\n", str_opt); printf(_(" -c, --cascade remove packages and all packages that depend on them\n")); - printf(_(" -k, --dbonly only remove database entries, do not remove files\n")); printf(_(" -n, --nosave remove configuration files as well\n")); printf(_(" -s, --recursive remove dependencies also (that won't break packages)\n" " (-ss includes explicitly installed dependencies too)\n")); @@ -138,7 +137,6 @@ static void usage(int op, const char * const myname) case PM_OP_SYNC: case PM_OP_UPGRADE: printf(_(" -f, --force force install, overwrite conflicting files\n")); - printf(_(" -k, --dbonly add database entries, do not install or keep existing files\n")); printf(_(" --asdeps install packages as non-explicitly installed\n")); printf(_(" --asexplicit install packages as explicitly installed\n")); printf(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n")); @@ -147,6 +145,7 @@ static void usage(int op, const char * const myname) /* pass through */ case PM_OP_REMOVE: printf(_(" -d, --nodeps skip dependency checks\n")); + printf(_(" -k, --dbonly only modify database entries, not package files\n")); printf(_(" --noprogressbar do not show a progress bar when downloading files\n")); printf(_(" --noscriptlet do not execute the install scriptlet if one exists\n")); printf(_(" --print only print the targets instead of performing the operation\n")); diff --git a/test/pacman/tests/database012.py b/test/pacman/tests/database012.py index a1f8698..52813ec 100644 --- a/test/pacman/tests/database012.py +++ b/test/pacman/tests/database012.py @@ -21,11 +21,5 @@ self.addrule("PKG_EXIST=dummy") self.addrule("PKG_VERSION=dummy|2.0-1") for f in lp.files: - self.addrule("!FILE_EXIST=%s" % f) -# TODO: I honestly think the above should NOT delete the original files, it -# should upgrade the DB entry without touching anything on the file system. -# E.g. this test should be the same as: -# pacman -R --dbonly dummy && pacman -U --dbonly dummy.pkg.tar.gz -#for f in lp.files: -# self.addrule("FILE_EXIST=%s" % f) + self.addrule("FILE_EXIST=%s" % f) self.addrule("!FILE_EXIST=bin/dummy2") -- 1.7.3.1
participants (1)
-
Xavier Chantry