summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNagy Gabor <ngaba@bibl.u-szeged.hu>2008-08-24 23:24:53 +0200
committerDan McGee <dan@archlinux.org>2009-01-13 05:44:00 +0100
commita888f377a5c805f1da24b556e6a4a9e3678d8eb3 (patch)
tree70ffd810a0b240429d2dfaa0d7266e228b6212f2
parent8017b0bb8ec5364f8a3999caffc6b3c3ea991810 (diff)
downloadpacman-a888f377a5c805f1da24b556e6a4a9e3678d8eb3.tar.gz
pacman-a888f377a5c805f1da24b556e6a4a9e3678d8eb3.tar.xz
HoldPkg rework
The HoldPkg feature is even more important when the packages to be held are pulled automatically by pacman, in a -Rc and -Rs operation. Before, it only applied when the packages were explicitly requested by the user to be removed. This patch extends holdpkg to -Rc and -Rs by doing the HoldPkg check just before trans_commit. Additionally, the whole HoldPkg stuff was moved to the front-end. I changed the default behavior to "don't remove", so I modified remove030.py pactest as well. See also: FS#9173. Original-work-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--lib/libalpm/alpm.h10
-rw-r--r--lib/libalpm/error.c3
-rw-r--r--lib/libalpm/handle.c32
-rw-r--r--lib/libalpm/handle.h1
-rw-r--r--lib/libalpm/remove.c10
-rw-r--r--pactest/tests/remove030.py6
-rw-r--r--src/pacman/callback.c4
-rw-r--r--src/pacman/conf.c1
-rw-r--r--src/pacman/conf.h1
-rw-r--r--src/pacman/pacman.c7
-rw-r--r--src/pacman/remove.c15
11 files changed, 26 insertions, 64 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index eda35d30..ecce02f9 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -132,11 +132,6 @@ void alpm_option_add_ignorepkg(const char *pkg);
void alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs);
int alpm_option_remove_ignorepkg(const char *pkg);
-alpm_list_t *alpm_option_get_holdpkgs();
-void alpm_option_add_holdpkg(const char *pkg);
-void alpm_option_set_holdpkgs(alpm_list_t *holdpkgs);
-int alpm_option_remove_holdpkg(const char *pkg);
-
alpm_list_t *alpm_option_get_ignoregrps();
void alpm_option_add_ignoregrp(const char *grp);
void alpm_option_set_ignoregrps(alpm_list_t *ignoregrps);
@@ -376,9 +371,7 @@ typedef enum _pmtransconv_t {
PM_TRANS_CONV_REPLACE_PKG = 0x02,
PM_TRANS_CONV_CONFLICT_PKG = 0x04,
PM_TRANS_CONV_CORRUPTED_PKG = 0x08,
- PM_TRANS_CONV_LOCAL_NEWER = 0x10,
- /* 0x20 flag can go here */
- PM_TRANS_CONV_REMOVE_HOLDPKG = 0x40
+ PM_TRANS_CONV_LOCAL_NEWER = 0x10
} pmtransconv_t;
/* Transaction Progress */
@@ -522,7 +515,6 @@ enum _pmerrno_t {
PM_ERR_INTERNAL_ERROR,
PM_ERR_DB_SYNC,
PM_ERR_RETRIEVE,
- PM_ERR_PKG_HOLD,
PM_ERR_INVALID_REGEX,
/* External library errors */
PM_ERR_LIBARCHIVE,
diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c
index df93cb7d..1f605806 100644
--- a/lib/libalpm/error.c
+++ b/lib/libalpm/error.c
@@ -140,9 +140,6 @@ const char SYMEXPORT *alpm_strerror(int err)
return _("user aborted the operation");
case PM_ERR_INTERNAL_ERROR:
return _("internal error");
- case PM_ERR_PKG_HOLD:
- /* TODO wow this is not descriptive at all... what does this mean? */
- return _("not confirmed");
case PM_ERR_INVALID_REGEX:
return _("invalid regular expression");
/* Errors from external libraries- our own wrapper error */
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 7dc01223..813f4399 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -83,7 +83,6 @@ void _alpm_handle_free(pmhandle_t *handle)
FREELIST(handle->noupgrade);
FREELIST(handle->noextract);
FREELIST(handle->ignorepkg);
- FREELIST(handle->holdpkg);
FREELIST(handle->ignoregrp);
FREE(handle);
}
@@ -196,15 +195,6 @@ alpm_list_t SYMEXPORT *alpm_option_get_ignorepkgs()
return handle->ignorepkg;
}
-alpm_list_t SYMEXPORT *alpm_option_get_holdpkgs()
-{
- if (handle == NULL) {
- pm_errno = PM_ERR_HANDLE_NULL;
- return NULL;
- }
- return handle->holdpkg;
-}
-
alpm_list_t SYMEXPORT *alpm_option_get_ignoregrps()
{
if (handle == NULL) {
@@ -507,28 +497,6 @@ int SYMEXPORT alpm_option_remove_ignorepkg(const char *pkg)
return(0);
}
-void SYMEXPORT alpm_option_add_holdpkg(const char *pkg)
-{
- handle->holdpkg = alpm_list_add(handle->holdpkg, strdup(pkg));
-}
-
-void SYMEXPORT alpm_option_set_holdpkgs(alpm_list_t *holdpkgs)
-{
- if(handle->holdpkg) FREELIST(handle->holdpkg);
- if(holdpkgs) handle->holdpkg = holdpkgs;
-}
-
-int SYMEXPORT alpm_option_remove_holdpkg(const char *pkg)
-{
- char *vdata = NULL;
- handle->holdpkg = alpm_list_remove_str(handle->holdpkg, pkg, &vdata);
- if(vdata != NULL) {
- FREE(vdata);
- return(1);
- }
- return(0);
-}
-
void SYMEXPORT alpm_option_add_ignoregrp(const char *grp)
{
handle->ignoregrp = alpm_list_add(handle->ignoregrp, strdup(grp));
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index bec0a6f1..ad7666dc 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -52,7 +52,6 @@ typedef struct _pmhandle_t {
alpm_list_t *noupgrade; /* List of packages NOT to be upgraded */
alpm_list_t *noextract; /* List of files NOT to extract */
alpm_list_t *ignorepkg; /* List of packages to ignore */
- alpm_list_t *holdpkg; /* List of packages which 'hold' pacman */
alpm_list_t *ignoregrp; /* List of groups to ignore */
/* options */
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 76bb5525..9dfff9c3 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -65,16 +65,6 @@ int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
}
- /* ignore holdpkgs on upgrade */
- if((trans == handle->trans)
- && alpm_list_find_str(handle->holdpkg, info->name)) {
- int resp = 0;
- QUESTION(trans, PM_TRANS_CONV_REMOVE_HOLDPKG, info, NULL, NULL, &resp);
- if(!resp) {
- RET_ERR(PM_ERR_PKG_HOLD, -1);
- }
- }
-
_alpm_log(PM_LOG_DEBUG, "adding %s in the targets list\n", info->name);
trans->packages = alpm_list_add(trans->packages, _alpm_pkg_dup(info));
diff --git a/pactest/tests/remove030.py b/pactest/tests/remove030.py
index 9e2b9da5..e975a4ba 100644
--- a/pactest/tests/remove030.py
+++ b/pactest/tests/remove030.py
@@ -7,7 +7,5 @@ self.option["HoldPkg"] = ["dummy"]
self.args = "-R %s" % p1.name
-self.addrule("PACMAN_RETCODE=0")
-self.addrule("!PKG_EXIST=dummy")
-self.addrule("!FILE_EXIST=etc/dummy.conf")
-self.addrule("!FILE_PACSAVE=etc/dummy.conf")
+self.addrule("PACMAN_RETCODE=1")
+self.addrule("PKG_EXIST=dummy")
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 9f1cca89..6e7930cb 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -258,10 +258,6 @@ void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
alpm_pkg_get_name(data1));
}
break;
- case PM_TRANS_CONV_REMOVE_HOLDPKG:
- *response = yesno(_(":: %s is designated as a HoldPkg. Remove anyway?"),
- alpm_pkg_get_name(data1));
- break;
case PM_TRANS_CONV_REPLACE_PKG:
*response = yesno(_(":: Replace %s with %s/%s?"),
alpm_pkg_get_name(data1),
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 5853facc..ca5cd123 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -54,6 +54,7 @@ int config_free(config_t *oldconfig)
return(-1);
}
+ FREELIST(oldconfig->holdpkg);
FREELIST(oldconfig->syncfirst);
free(oldconfig->configfile);
free(oldconfig->rootdir);
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 8ea66629..466d9832 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -69,6 +69,7 @@ typedef struct __config_t {
* downloaded of the total download list */
unsigned short totaldownload;
unsigned short cleanmethod; /* select -Sc behavior */
+ alpm_list_t *holdpkg;
alpm_list_t *syncfirst;
} config_t;
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 3255cdf0..59916d62 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -540,6 +540,11 @@ static int parseargs(int argc, char *argv[])
}
/* helper for being used with setrepeatingoption */
+static void option_add_holdpkg(const char *name) {
+ config->holdpkg = alpm_list_add(config->holdpkg, strdup(name));
+}
+
+/* helper for being used with setrepeatingoption */
static void option_add_syncfirst(const char *name) {
config->syncfirst = alpm_list_add(config->syncfirst, strdup(name));
}
@@ -702,7 +707,7 @@ static int _parseconfig(const char *file, const char *givensection,
} else if(strcmp(key, "IgnoreGroup") == 0) {
setrepeatingoption(ptr, "IgnoreGroup", alpm_option_add_ignoregrp);
} else if(strcmp(key, "HoldPkg") == 0) {
- setrepeatingoption(ptr, "HoldPkg", alpm_option_add_holdpkg);
+ setrepeatingoption(ptr, "HoldPkg", option_add_holdpkg);
} else if(strcmp(key, "SyncFirst") == 0) {
setrepeatingoption(ptr, "SyncFirst", option_add_syncfirst);
} else if(strcmp(key, "DBPath") == 0) {
diff --git a/src/pacman/remove.c b/src/pacman/remove.c
index b70f7035..841a08bb 100644
--- a/src/pacman/remove.c
+++ b/src/pacman/remove.c
@@ -121,6 +121,21 @@ int pacman_remove(alpm_list_t *targets)
goto cleanup;
}
+ /* Search for holdpkg in target list */
+ int holdpkg = 0;
+ for(i = alpm_trans_get_pkgs(); i; i = alpm_list_next(i)) {
+ pmpkg_t *pkg = alpm_list_getdata(i);
+ if(alpm_list_find_str(config->holdpkg, alpm_pkg_get_name(pkg))) {
+ pm_printf(PM_LOG_WARNING, _("%s is designated as a HoldPkg.\n"),
+ alpm_pkg_get_name(pkg));
+ holdpkg = 1;
+ }
+ }
+ if(holdpkg && (noyes(_("HoldPkg was found in target list. Do you want to continue?")) == 0)) {
+ retval = 1;
+ goto cleanup;
+ }
+
/* Warn user in case of dangerous operation */
if(config->flags & PM_TRANS_FLAG_RECURSE ||
config->flags & PM_TRANS_FLAG_CASCADE) {