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>
[Dan: small coding style touchup]
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Xavier Chantry 2010-10-12 00:42:04 +02:00 committed by Dan McGee
parent 3a9dec1048
commit abefa23341
4 changed files with 7 additions and 11 deletions

View file

@ -158,8 +158,6 @@ Transaction Options (apply to '-S', '-R' and '-U')
*-k, \--dbonly*:: *-k, \--dbonly*::
Adds/Removes the database entry only, leaves all files in place. 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*:: *\--noprogressbar*::
Do not show a progress bar when downloading files. This can be useful Do not show a progress bar when downloading files. This can be useful

View file

@ -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", _alpm_log(PM_LOG_DEBUG, "removing old package first (%s-%s)\n",
oldpkg->name, oldpkg->version); oldpkg->name, oldpkg->version);
if(trans->flags & PM_TRANS_FLAG_DBONLY) {
goto db;
}
/* copy the remove skiplist over */ /* copy the remove skiplist over */
skip_remove = skip_remove =
alpm_list_join(alpm_list_strdup(trans->skip_remove),alpm_list_strdup(handle->noupgrade)); 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); alpm_list_free(newfiles);
FREELIST(skip_remove); FREELIST(skip_remove);
db:
/* remove the package from the database */ /* remove the package from the database */
_alpm_log(PM_LOG_DEBUG, "updating database\n"); _alpm_log(PM_LOG_DEBUG, "updating database\n");
_alpm_log(PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname); _alpm_log(PM_LOG_DEBUG, "removing database entry '%s'\n", pkgname);

View file

@ -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: %s {-R --remove} [%s] <%s>\n", str_usg, myname, str_opt, str_pkg);
printf("%s:\n", str_opt); printf("%s:\n", str_opt);
addlist(_(" -c, --cascade remove packages and all packages that depend on them\n")); 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(_(" -n, --nosave remove configuration files as well\n"));
addlist(_(" -s, --recursive remove dependencies also (that won't break packages)\n" addlist(_(" -s, --recursive remove dependencies also (that won't break packages)\n"
" (-ss includes explicitly installed dependencies too)\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_SYNC:
case PM_OP_UPGRADE: case PM_OP_UPGRADE:
addlist(_(" -f, --force force install, overwrite conflicting files\n")); 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(_(" --asdeps install packages as non-explicitly installed\n"));
addlist(_(" --asexplicit install packages as explicitly installed\n")); addlist(_(" --asexplicit install packages as explicitly installed\n"));
addlist(_(" --ignore <pkg> ignore a package upgrade (can be used more than once)\n")); addlist(_(" --ignore <pkg> 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 */ /* pass through */
case PM_OP_REMOVE: case PM_OP_REMOVE:
addlist(_(" -d, --nodeps skip dependency checks\n")); 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(_(" --noprogressbar do not show a progress bar when downloading files\n"));
addlist(_(" --noscriptlet do not execute the install scriptlet if one exists\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")); addlist(_(" --print only print the targets instead of performing the operation\n"));

View file

@ -21,11 +21,5 @@ self.addrule("PACMAN_RETCODE=0")
self.addrule("PKG_EXIST=dummy") self.addrule("PKG_EXIST=dummy")
self.addrule("PKG_VERSION=dummy|2.0-1") self.addrule("PKG_VERSION=dummy|2.0-1")
for f in lp.files: for f in lp.files:
self.addrule("!FILE_EXIST=%s" % f) 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=bin/dummy2") self.addrule("!FILE_EXIST=bin/dummy2")