From abefa23341caa995cc0d155d30baa7faeb7a6c0e Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Tue, 12 Oct 2010 00:42:04 +0200 Subject: 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 [Dan: small coding style touchup] Signed-off-by: Dan McGee --- doc/pacman.8.txt | 2 -- lib/libalpm/remove.c | 5 +++++ src/pacman/pacman.c | 3 +-- test/pacman/tests/database012.py | 8 +------- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 9f540df1..2b47a88c 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -158,8 +158,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 b2137b19..0bcf5521 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -310,6 +310,10 @@ 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)); @@ -344,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 ae349a35..5ba798b4 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -132,7 +132,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); addlist(_(" -c, --cascade remove packages and all packages that depend on them\n")); - addlist(_(" -k, --dbonly only remove database entries, do not remove files\n")); addlist(_(" -n, --nosave remove configuration files as well\n")); addlist(_(" -s, --recursive remove dependencies also (that won't break packages)\n" " (-ss includes explicitly installed dependencies too)\n")); @@ -180,7 +179,6 @@ static void usage(int op, const char * const myname) case PM_OP_SYNC: case PM_OP_UPGRADE: addlist(_(" -f, --force force install, overwrite conflicting files\n")); - addlist(_(" -k, --dbonly add database entries, do not install or keep existing files\n")); addlist(_(" --asdeps install packages as non-explicitly installed\n")); addlist(_(" --asexplicit install packages as explicitly installed\n")); addlist(_(" --ignore ignore a package upgrade (can be used more than once)\n")); @@ -189,6 +187,7 @@ static void usage(int op, const char * const myname) /* pass through */ case PM_OP_REMOVE: addlist(_(" -d, --nodeps skip dependency checks\n")); + addlist(_(" -k, --dbonly only modify database entries, not package files\n")); addlist(_(" --noprogressbar do not show a progress bar when downloading files\n")); addlist(_(" --noscriptlet do not execute the install scriptlet if one exists\n")); addlist(_(" --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 a1f86980..52813ec6 100644 --- a/test/pacman/tests/database012.py +++ b/test/pacman/tests/database012.py @@ -21,11 +21,5 @@ self.addrule("PACMAN_RETCODE=0") 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") -- cgit v1.2.3-70-g09d2