mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-11 20:05:07 -05:00
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>
This commit is contained in:
parent
8017b0bb8e
commit
a888f377a5
@ -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,
|
||||
|
@ -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 */
|
||||
|
@ -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));
|
||||
|
@ -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 */
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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")
|
||||
|
@ -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),
|
||||
|
@ -54,6 +54,7 @@ int config_free(config_t *oldconfig)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
FREELIST(oldconfig->holdpkg);
|
||||
FREELIST(oldconfig->syncfirst);
|
||||
free(oldconfig->configfile);
|
||||
free(oldconfig->rootdir);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -539,6 +539,11 @@ static int parseargs(int argc, char *argv[])
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user